From d2c53b50d50f7682e8c212b2857d63c66f53ae2d Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 10 Jul 2008 10:35:11 +0000 Subject: [PATCH] timeout incoming connections --- src/session_impl.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 92ad41db6..c2a87c73d 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1022,6 +1022,23 @@ namespace aux { << m_disk_thread.disk_allocations() << "\t" << std::endl; #endif + + // -------------------------------------------------------------- + // check for incoming connections that might have timed out + // -------------------------------------------------------------- + + for (connection_map::iterator i = m_connections.begin(); + i != m_connections.end();) + { + peer_connection* p = (*i).get(); + ++i; + // ignore connections that already have a torrent, since they + // are ticket through the torrents' second_ticket + if (!p->associated_torrent().expired()) continue; + if (m_last_tick - p->connected_time() > seconds(m_settings.peer_connect_timeout)) + p->disconnect("timeout: incoming connection"); + } + // -------------------------------------------------------------- // second_tick every torrent // --------------------------------------------------------------