Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Commit 3956a2b

Browse files
authored
Fix ServerTest.ClientStop test case (yhirose#1542)
1 parent b33aa52 commit 3956a2b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/test.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,19 +2867,24 @@ TEST_F(ServerTest, GetStreamedEndless) {
28672867
}
28682868

28692869
TEST_F(ServerTest, ClientStop) {
2870+
std::atomic_size_t count{4};
28702871
std::vector<std::thread> threads;
2871-
for (auto i = 0; i < 3; i++) {
2872+
2873+
for (auto i = count.load(); i != 0; --i) {
28722874
threads.emplace_back([&]() {
28732875
auto res = cli_.Get("/streamed-cancel",
28742876
[&](const char *, uint64_t) { return true; });
2877+
2878+
--count;
2879+
28752880
ASSERT_TRUE(!res);
28762881
EXPECT_TRUE(res.error() == Error::Canceled ||
28772882
res.error() == Error::Read || res.error() == Error::Write);
28782883
});
28792884
}
28802885

28812886
std::this_thread::sleep_for(std::chrono::seconds(2));
2882-
while (cli_.is_socket_open()) {
2887+
while (count != 0) {
28832888
cli_.stop();
28842889
std::this_thread::sleep_for(std::chrono::milliseconds(10));
28852890
}

0 commit comments

Comments
 (0)