aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-12-25 21:21:17 +0200
committerRiccardo Spagni <ric@spagni.net>2017-12-25 21:21:17 +0200
commit6ca30ae666dbd4894bd5e15ffa6fd7182ba26060 (patch)
treefd4cba97d6f62962ce295b0140d1081de49f67f5 /contrib/epee/include
parentMerge pull request #2931 (diff)
parentlevin_protocol_handler_async: another attempt at fixing at exception (diff)
downloadmonero-6ca30ae666dbd4894bd5e15ffa6fd7182ba26060.tar.xz
Merge pull request #2936
cb9aa23c levin_protocol_handler_async: another attempt at fixing at exception (moneromooo-monero) 64d23ce3 Revert "epee: keep a ref to a connection we're deleting" (moneromooo-monero)
Diffstat (limited to 'contrib/epee/include')
-rw-r--r--contrib/epee/include/net/levin_protocol_handler_async.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h
index 65705351d..5b825cef9 100644
--- a/contrib/epee/include/net/levin_protocol_handler_async.h
+++ b/contrib/epee/include/net/levin_protocol_handler_async.h
@@ -750,15 +750,18 @@ 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)
{
- 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();
+ try
+ {
+ auto i = out_connections.begin();
+ async_protocol_handler<t_connection_context> *conn = m_connects.at(*i);
+ del_connection(conn);
+ close(*i);
+ out_connections.erase(i);
+ }
+ catch (const std::out_of_range &e)
+ {
+ MWARNING("Connection not found in m_connects, continuing");
+ }
--count;
}