diff --git a/src/session_impl.cpp b/src/session_impl.cpp index b8c1b5672..12629b4ad 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2235,7 +2235,6 @@ retry: TORRENT_ASSERT(!m_abort); m_listen_sockets.push_back(s); - async_accept(s.sock, s.ssl); } #ifdef TORRENT_USE_OPENSSL @@ -2250,7 +2249,6 @@ retry: { TORRENT_ASSERT(!m_abort); m_listen_sockets.push_back(s); - async_accept(s.sock, s.ssl); } } #endif @@ -2266,7 +2264,6 @@ retry: { TORRENT_ASSERT(!m_abort); m_listen_sockets.push_back(s); - async_accept(s.sock, s.ssl); } #ifdef TORRENT_USE_OPENSSL @@ -2282,7 +2279,6 @@ retry: { TORRENT_ASSERT(!m_abort); m_listen_sockets.push_back(s); - async_accept(s.sock, s.ssl); } } #endif // TORRENT_USE_OPENSSL @@ -2314,7 +2310,6 @@ retry: { TORRENT_ASSERT(!m_abort); m_listen_sockets.push_back(s); - async_accept(s.sock, s.ssl); if (m_listen_interface.address().is_v6()) m_ipv6_interface = m_listen_interface; @@ -2334,7 +2329,6 @@ retry: { TORRENT_ASSERT(!m_abort); m_listen_sockets.push_back(s); - async_accept(s.sock, s.ssl); } } #endif @@ -2350,6 +2344,7 @@ retry: if (m_listen_port_retries > 0) { m_listen_interface.port(m_listen_interface.port() + 1); + --m_listen_port_retries; goto retry; } if (m_alerts.should_post()) @@ -2368,6 +2363,11 @@ retry: #endif ec.clear(); + // initiate accepting on the listen sockets + for (std::list::iterator i = m_listen_sockets.begin() + , end(m_listen_sockets.end()); i != end; ++i) + async_accept(i->sock, i->ssl); + open_new_incoming_socks_connection(); #if TORRENT_USE_I2P open_new_incoming_i2p_connection(); diff --git a/src/utp_socket_manager.cpp b/src/utp_socket_manager.cpp index f58e0d7fc..b51a5ec11 100644 --- a/src/utp_socket_manager.cpp +++ b/src/utp_socket_manager.cpp @@ -296,13 +296,15 @@ namespace libtorrent if (m_utp_sockets.size() > m_sett.connections_limit * 2) return false; - // create the new socket with this ID - m_new_connection = id; - // UTP_LOGV("not found, new connection id:%d\n", m_new_connection); boost::shared_ptr c(new (std::nothrow) socket_type(m_sock.get_io_service())); if (!c) return false; + + TORRENT_ASSERT(m_new_connection == -1); + // create the new socket with this ID + m_new_connection = id; + instantiate_connection(m_sock.get_io_service(), proxy_settings(), *c, 0, this); utp_stream* str = c->get(); TORRENT_ASSERT(str);