forked from premiere/premiere-libtorrent
attempt at fixing shut-down hang
This commit is contained in:
parent
d5c715bf96
commit
0f57615ea3
|
@ -737,6 +737,12 @@ namespace libtorrent
|
||||||
// object. It is the complete list of all connected
|
// object. It is the complete list of all connected
|
||||||
// peers.
|
// peers.
|
||||||
connection_map m_connections;
|
connection_map m_connections;
|
||||||
|
|
||||||
|
// this list holds incoming connections while they
|
||||||
|
// are performing SSL handshake. When we shut down
|
||||||
|
// the session, all of these are disconnected, otherwise
|
||||||
|
// they would linger and stall or hang session shutdown
|
||||||
|
std::set<boost::shared_ptr<socket_type> > m_incoming_sockets;
|
||||||
|
|
||||||
// filters incoming connections
|
// filters incoming connections
|
||||||
ip_filter m_ip_filter;
|
ip_filter m_ip_filter;
|
||||||
|
|
|
@ -1811,6 +1811,13 @@ namespace aux {
|
||||||
m_timer.cancel(ec);
|
m_timer.cancel(ec);
|
||||||
m_lsd_announce_timer.cancel(ec);
|
m_lsd_announce_timer.cancel(ec);
|
||||||
|
|
||||||
|
for (std::set<boost::shared_ptr<socket_type> >::iterator i = m_incoming_sockets.begin()
|
||||||
|
, end(m_incoming_sockets.end()); i != end; ++i)
|
||||||
|
{
|
||||||
|
(*i)->close();
|
||||||
|
}
|
||||||
|
m_incoming_sockets.clear();
|
||||||
|
|
||||||
// close the listen sockets
|
// close the listen sockets
|
||||||
for (std::list<listen_socket_t>::iterator i = m_listen_sockets.begin()
|
for (std::list<listen_socket_t>::iterator i = m_listen_sockets.begin()
|
||||||
, end(m_listen_sockets.end()); i != end; ++i)
|
, end(m_listen_sockets.end()); i != end; ++i)
|
||||||
|
@ -2710,6 +2717,7 @@ retry:
|
||||||
#endif
|
#endif
|
||||||
s->get<ssl_stream<stream_socket> >()->async_accept_handshake(
|
s->get<ssl_stream<stream_socket> >()->async_accept_handshake(
|
||||||
boost::bind(&session_impl::ssl_handshake, this, _1, s));
|
boost::bind(&session_impl::ssl_handshake, this, _1, s));
|
||||||
|
m_incoming_sockets.insert(s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -2731,6 +2739,8 @@ retry:
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
#if defined TORRENT_ASIO_DEBUGGING
|
||||||
complete_async("session_impl::ssl_handshake");
|
complete_async("session_impl::ssl_handshake");
|
||||||
#endif
|
#endif
|
||||||
|
m_incoming_sockets.erase(s);
|
||||||
|
|
||||||
error_code e;
|
error_code e;
|
||||||
tcp::endpoint endp = s->remote_endpoint(e);
|
tcp::endpoint endp = s->remote_endpoint(e);
|
||||||
if (e) return;
|
if (e) return;
|
||||||
|
|
Loading…
Reference in New Issue