aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-09-19 09:25:17 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-09-19 09:25:17 +0100
commitf2939bdce8c86b0f96921f731184c361106390c8 (patch)
treea72758cbf3f825366868b4cd8667eeb3ff264699 /contrib
parentMerge pull request #2446 (diff)
downloadmonero-f2939bdce8c86b0f96921f731184c361106390c8.tar.xz
epee: keep a ref to a connection we're deleting
close might end up dropping a ref, ending up removing the connection from m_connects, as the lock is recursive. This'd cause an out of bounds exception and kill the idle connection maker thread
Diffstat (limited to 'contrib')
-rw-r--r--contrib/epee/include/net/levin_protocol_handler_async.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h
index 60a667690..779f4e78f 100644
--- a/contrib/epee/include/net/levin_protocol_handler_async.h
+++ b/contrib/epee/include/net/levin_protocol_handler_async.h
@@ -740,9 +740,15 @@ void async_protocol_handler_config<t_connection_context>::del_out_connections(si
shuffle(out_connections.begin(), out_connections.end(), std::default_random_engine(seed));
while (count > 0 && out_connections.size() > 0)
{
- close(*out_connections.begin());
- del_connection(m_connects.at(*out_connections.begin()));
+ boost::uuids::uuid connection_id = *out_connections.begin();
+ async_protocol_handler<t_connection_context> *connection = find_connection(connection_id);
+ // we temporarily ref the connection so it doesn't drop from the m_connects table
+ // when we close it
+ connection->start_outer_call();
+ close(connection_id);
+ del_connection(m_connects.at(connection_id));
out_connections.erase(out_connections.begin());
+ connection->finish_outer_call();
--count;
}