diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-12-22 12:31:22 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-12-22 12:39:02 +0000 |
commit | 1e2f2d7da0ee22e35670856ad964671848e186b4 (patch) | |
tree | bd220d60d507b28e54f217f2eb950520f70220b9 /contrib/epee/include/net/abstract_tcp_server2.h | |
parent | net_node: fix a hang on exit (diff) | |
download | monero-1e2f2d7da0ee22e35670856ad964671848e186b4.tar.xz |
epee: fix hang on exit
When the boost ioservice is stopped, pending work notifications
will not happen. This includes deadline timers, which would
otherwise time out the now cancelled I/O operations. When this
happens just after starting a new connect operation, this can
leave that operations in a state where it won't receive either
the completion notification nor a timeout, causing a hang.
This is fixed by keeping a list of connections corresponding
to the connect operations, and cancelling them before stopping
the boost ioservice.
Note that the list of these connections can grow unbounded, as
they're never cleaned up. Cleaning them up would involve
working out which connections do not have any pending work,
and it's not quite clear yet how to go about this.
Diffstat (limited to 'contrib/epee/include/net/abstract_tcp_server2.h')
-rw-r--r-- | contrib/epee/include/net/abstract_tcp_server2.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/contrib/epee/include/net/abstract_tcp_server2.h b/contrib/epee/include/net/abstract_tcp_server2.h index 8043c0876..77396ade4 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.h +++ b/contrib/epee/include/net/abstract_tcp_server2.h @@ -110,6 +110,8 @@ namespace net_utils bool speed_limit_is_enabled() const; ///< tells us should we be sleeping here (e.g. do not sleep on RPC connections) + + bool cancel(); private: //----------------- i_service_endpoint --------------------- @@ -303,6 +305,9 @@ namespace net_utils /// The next connection to be accepted connection_ptr new_connection_; + std::mutex connections_mutex; + std::deque<connection_ptr> connections_; + }; // class <>boosted_tcp_server |