Skip to content

Commit 6c3e848

Browse files
authored
Fix KeepAliveTest.SSLClientReconnectionPost (#1895)
1 parent 390f2c4 commit 6c3e848

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/test.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5167,8 +5167,14 @@ TEST(KeepAliveTest, SSLClientReconnectionPost) {
51675167
res.set_content("Hello World!", "text/plain");
51685168
});
51695169

5170-
auto f = std::async(std::launch::async, [&svr] { svr.listen(HOST, PORT); });
5171-
std::this_thread::sleep_for(std::chrono::milliseconds(200));
5170+
auto listen_thread = std::thread([&svr] { svr.listen(HOST, PORT); });
5171+
auto se = detail::scope_exit([&] {
5172+
svr.stop();
5173+
listen_thread.join();
5174+
ASSERT_FALSE(svr.is_running());
5175+
});
5176+
5177+
svr.wait_until_ready();
51725178

51735179
SSLClient cli(HOST, PORT);
51745180
cli.enable_server_certificate_verification(false);
@@ -5206,9 +5212,6 @@ TEST(KeepAliveTest, SSLClientReconnectionPost) {
52065212
"text/plain");
52075213
ASSERT_TRUE(result);
52085214
EXPECT_EQ(200, result->status);
5209-
5210-
svr.stop();
5211-
f.wait();
52125215
}
52135216
#endif
52145217

0 commit comments

Comments
 (0)