Skip to content

Commit

Permalink
fix fake mem leak
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Apr 10, 2024
1 parent 6799b0f commit 9ce4f7f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/coro_rpc/tests/test_coro_rpc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ TEST_CASE("testing client") {
std::string port = std::to_string(coro_rpc_server_port);
asio::io_context io_context;
std::promise<void> promise;
auto worker = std::make_unique<asio::io_context::work>(io_context);
auto future = promise.get_future();
std::thread thd([&io_context, &promise] {
asio::io_context::work work(io_context);
promise.set_value();
io_context.run();
});
Expand Down Expand Up @@ -154,7 +154,7 @@ TEST_CASE("testing client") {
}

server.stop();
io_context.stop();
worker = nullptr;
thd.join();
}

Expand All @@ -163,8 +163,8 @@ TEST_CASE("testing client with inject server") {
std::string port = std::to_string(coro_rpc_server_port);
ELOGV(INFO, "inject server port: %d", port.data());
asio::io_context io_context;
auto worker = std::make_unique<asio::io_context::work>(io_context);
std::thread thd([&io_context] {
asio::io_context::work work(io_context);
io_context.run();
});
coro_rpc_server server(2, coro_rpc_server_port);
Expand Down Expand Up @@ -212,7 +212,7 @@ TEST_CASE("testing client with inject server") {
}

server.stop();
io_context.stop();
worker = nullptr;
thd.join();
g_action = inject_action::nothing;
}
Expand Down Expand Up @@ -245,15 +245,15 @@ class SSLClientTester {

std::promise<void> promise;
auto future = promise.get_future();
worker = std::make_unique<asio::io_context::work>(io_context);
thd = std::thread([this, &promise] {
asio::io_context::work work(io_context);
promise.set_value();
io_context.run();
});
future.wait();
}
~SSLClientTester() {
io_context.stop();
worker = nullptr;
thd.join();
}
void inject(std::string msg, std::string& path, ssl_type type) {
Expand Down Expand Up @@ -342,6 +342,7 @@ class SSLClientTester {
ssl_type dh;
asio::io_context io_context;
std::thread thd;
std::unique_ptr<asio::io_context::work> worker;
};

TEST_CASE("testing client with ssl server") {
Expand Down

0 comments on commit 9ce4f7f

Please sign in to comment.