From 26f114216f814e8b1ecefc12ff2611d88c4592a4 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 30 Mar 2004 19:11:07 +0000 Subject: [PATCH] *** empty log message *** --- include/libtorrent/session.hpp | 2 ++ src/session.cpp | 25 ++++++++++++++++++++++--- src/torrent.cpp | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 3028e3c8d..fb0104826 100755 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -156,6 +156,8 @@ namespace libtorrent struct session_impl: boost::noncopyable { friend class invariant_access; + // TODO: maybe this should be changed to a sorted vector + // using lower_bound? typedef std::map, boost::shared_ptr > connection_map; typedef std::map > torrent_map; diff --git a/src/session.cpp b/src/session.cpp index a7a4c4ee5..c60703430 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -330,11 +330,16 @@ namespace libtorrent { namespace detail { if (e.error_code() == socket::address_not_available) { - std::string msg = "cannot listen on the given interface '" + m_listen_interface.as_string() + "'"; - m_alerts.post_alert(listen_failed_alert(msg)); + if (m_alerts.should_post(alert::fatal)) + { + std::string msg = "cannot listen on the given interface '" + m_listen_interface.as_string() + "'"; + m_alerts.post_alert(listen_failed_alert(msg)); + } #ifndef NDEBUG + std::string msg = "cannot listen on the given interface '" + m_listen_interface.as_string() + "'"; (*m_logger) << msg << "\n"; #endif + assert(m_listen_socket.unique()); m_listen_socket.reset(); break; } @@ -622,6 +627,20 @@ namespace libtorrent { namespace detail p->second->set_failed(); m_connections.erase(p); } + else if (*i == m_listen_socket) + { + if (m_alerts.should_post(alert::fatal)) + { + std::string msg = "cannot listen on the given interface '" + m_listen_interface.as_string() + "'"; + m_alerts.post_alert(listen_failed_alert(msg)); + } +#ifndef NDEBUG + std::string msg = "cannot listen on the given interface '" + m_listen_interface.as_string() + "'"; + (*m_logger) << msg << "\n"; +#endif + assert(m_listen_socket.unique()); + m_listen_socket.reset(); + } } #ifndef NDEBUG @@ -637,7 +656,7 @@ namespace libtorrent { namespace detail // ************************ #ifndef NDEBUG - // std::cout << "\n\nloops: " << loops_per_second << "\n"; + if (loops_per_second > 800) std::cout << "\n\nloops: " << loops_per_second << "\n"; loops_per_second = 0; #endif diff --git a/src/torrent.cpp b/src/torrent.cpp index 1b81c67da..a06ab27f2 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -354,7 +354,6 @@ namespace libtorrent { // we don't trust this peer anymore // ban it. - m_policy->ban_peer(*p->second); if (m_ses.m_alerts.should_post(alert::info)) { m_ses.m_alerts.post_alert(peer_ban_alert( @@ -362,6 +361,8 @@ namespace libtorrent , get_handle() , "banning peer because of too many corrupt pieces")); } + m_policy->ban_peer(*p->second); + p->second->disconnect(); } }