Merge pull request #8538

3987827 Fix shared_ptr cycle in test_epee_connection.test_lifetime (Lee Clagett)
This commit is contained in:
luigi1111 2022-09-09 12:53:51 -05:00
commit ed150fa821
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010

View File

@ -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] {