aboutsummaryrefslogtreecommitdiff
path: root/tests/net_load_tests/srv.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-10-09 16:46:42 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-10-09 16:46:42 +0100
commit7dbf76d0da5c78b8e987ce3fe1bf25781b02b82e (patch)
tree831f55935dba7a8c88fb2e0abc9c350c7184a215 /tests/net_load_tests/srv.cpp
parentMerge pull request #2548 (diff)
downloadmonero-7dbf76d0da5c78b8e987ce3fe1bf25781b02b82e.tar.xz
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.
Diffstat (limited to 'tests/net_load_tests/srv.cpp')
-rw-r--r--tests/net_load_tests/srv.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/net_load_tests/srv.cpp b/tests/net_load_tests/srv.cpp
index e6dee1639..f0b0889ea 100644
--- a/tests/net_load_tests/srv.cpp
+++ b/tests/net_load_tests/srv.cpp
@@ -224,8 +224,8 @@ int main(int argc, char** argv)
if (!tcp_server.init_server(srv_port, "127.0.0.1"))
return 1;
- srv_levin_commands_handler commands_handler(tcp_server);
- tcp_server.get_config_object().m_pcommands_handler = &commands_handler;
+ srv_levin_commands_handler *commands_handler = new srv_levin_commands_handler(tcp_server);
+ tcp_server.get_config_object().set_handler(commands_handler, [](epee::levin::levin_commands_handler<test_connection_context> *handler) { delete handler; });
tcp_server.get_config_object().m_invoke_timeout = 10000;
//tcp_server.get_config_object().m_max_packet_size = max_packet_size;