mirror of
https://github.com/monero-project/monero.git
synced 2025-05-04 20:24:59 -04: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
|
@ -187,9 +187,11 @@ namespace
|
|||
|
||||
typedef std::unique_ptr<test_connection> test_connection_ptr;
|
||||
|
||||
async_protocol_handler_test()
|
||||
async_protocol_handler_test():
|
||||
m_pcommands_handler(new test_levin_commands_handler()),
|
||||
m_commands_handler(*m_pcommands_handler)
|
||||
{
|
||||
m_handler_config.m_pcommands_handler = &m_commands_handler;
|
||||
m_handler_config.set_handler(m_pcommands_handler, [](epee::levin::levin_commands_handler<test_levin_connection_context> *handler) { delete handler; });
|
||||
m_handler_config.m_invoke_timeout = invoke_timeout;
|
||||
m_handler_config.m_max_packet_size = max_packet_size;
|
||||
}
|
||||
|
@ -212,7 +214,7 @@ namespace
|
|||
protected:
|
||||
boost::asio::io_service m_io_service;
|
||||
test_levin_protocol_handler_config m_handler_config;
|
||||
test_levin_commands_handler m_commands_handler;
|
||||
test_levin_commands_handler *m_pcommands_handler, &m_commands_handler;
|
||||
};
|
||||
|
||||
class positive_test_connection_to_levin_protocol_handler_calls : public async_protocol_handler_test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue