mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Fix an object lifetime bug in net load tests
The commands handler must not be destroyed before the config object, or we'll be accessing freed memory. An earlier attempt at using boost::shared_ptr to control object lifetime turned out to be very invasive, though would be a better solution in theory.
This commit is contained in:
parent
86e9de588c
commit
7dbf76d0da
10 changed files with 45 additions and 16 deletions
|
@ -193,7 +193,7 @@ namespace
|
|||
{
|
||||
m_thread_count = (std::max)(min_thread_count, boost::thread::hardware_concurrency() / 2);
|
||||
|
||||
m_tcp_server.get_config_object().m_pcommands_handler = &m_commands_handler;
|
||||
m_tcp_server.get_config_object().set_handler(&m_commands_handler);
|
||||
m_tcp_server.get_config_object().m_invoke_timeout = CONNECTION_TIMEOUT;
|
||||
|
||||
ASSERT_TRUE(m_tcp_server.init_server(clt_port, "127.0.0.1"));
|
||||
|
@ -238,9 +238,10 @@ namespace
|
|||
static void TearDownTestCase()
|
||||
{
|
||||
// Stop server
|
||||
test_levin_commands_handler commands_handler;
|
||||
test_tcp_server tcp_server(epee::net_utils::e_connection_type_NET);
|
||||
tcp_server.get_config_object().m_pcommands_handler = &commands_handler;
|
||||
test_levin_commands_handler *commands_handler_ptr = new test_levin_commands_handler();
|
||||
test_levin_commands_handler &commands_handler = *commands_handler_ptr;
|
||||
test_tcp_server tcp_server(epee::net_utils::e_connection_type_RPC);
|
||||
tcp_server.get_config_object().set_handler(commands_handler_ptr, [](epee::levin::levin_commands_handler<test_connection_context> *handler)->void { delete handler; });
|
||||
tcp_server.get_config_object().m_invoke_timeout = CONNECTION_TIMEOUT;
|
||||
|
||||
if (!tcp_server.init_server(clt_port, "127.0.0.1")) return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue