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
|
@ -151,6 +151,11 @@ namespace net_load_tests
|
|||
bool handle_new_connection(const boost::uuids::uuid& connection_id, bool ignore_close_fails = false)
|
||||
{
|
||||
size_t idx = m_next_opened_conn_idx.fetch_add(1, std::memory_order_relaxed);
|
||||
if (idx >= m_connections.size())
|
||||
{
|
||||
LOG_PRINT_L0("ERROR: connections overflow");
|
||||
exit(1);
|
||||
}
|
||||
m_connections[idx] = connection_id;
|
||||
|
||||
size_t prev_connection_count = m_opened_connection_count.fetch_add(1, std::memory_order_relaxed);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue