diff options
author | luigi1111 <luigi1111w@gmail.com> | 2022-09-09 12:53:51 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2022-09-09 12:53:51 -0500 |
commit | ed150fa821759bcd200deb9d845a61e613a0be96 (patch) | |
tree | ccb6136edaaeccee2439390973055d1e0461f9fc /tests | |
parent | Merge pull request #8519 (diff) | |
parent | Fix shared_ptr cycle in test_epee_connection.test_lifetime (diff) | |
download | monero-ed150fa821759bcd200deb9d845a61e613a0be96.tar.xz |
Merge pull request #8538
3987827 Fix shared_ptr cycle in test_epee_connection.test_lifetime (Lee Clagett)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit_tests/epee_boosted_tcp_server.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/unit_tests/epee_boosted_tcp_server.cpp b/tests/unit_tests/epee_boosted_tcp_server.cpp index c08a86a5e..70f1b966f 100644 --- a/tests/unit_tests/epee_boosted_tcp_server.cpp +++ b/tests/unit_tests/epee_boosted_tcp_server.cpp @@ -212,11 +212,14 @@ TEST(test_epee_connection, test_lifetime) server.get_config_shared()->set_handler(new command_handler_t, &command_handler_t::destroy); io_context.post([&io_context, &work, &endpoint, &server]{ - auto scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&work]{ + shared_state_ptr shared_state; + auto scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&work, &shared_state]{ work.reset(); + if (shared_state) + shared_state->set_handler(nullptr, nullptr); }); - shared_state_ptr shared_state(std::make_shared<shared_state_t>()); + shared_state = std::make_shared<shared_state_t>(); shared_state->set_handler(new command_handler_t, &command_handler_t::destroy); auto create_connection = [&io_context, &endpoint, &shared_state] { |