diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 81aa74e3c..c3778ecb4 100755 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -949,7 +949,18 @@ namespace libtorrent { namespace detail continue; } - c.keep_alive(); + try + { + c.keep_alive(); + } + catch (std::exception& exc) + { +#ifdef TORRENT_VERBOSE_LOGGING + (*c.m_logger) << "**ERROR**: " << exc.what() << "\n"; +#endif + c.set_failed(); + c.disconnect(); + } } // check each torrent for tracker updates @@ -981,7 +992,6 @@ namespace libtorrent { namespace detail } m_stat.second_tick(tick_interval); - // distribute the maximum upload rate among the torrents assert(m_max_uploads >= -1); diff --git a/src/torrent.cpp b/src/torrent.cpp index 1de10dd43..4f181c11e 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -2454,13 +2454,25 @@ namespace libtorrent } for (peer_iterator i = m_connections.begin(); - i != m_connections.end(); ++i) + i != m_connections.end();) { peer_connection* p = i->second; + ++i; m_stat += p->statistics(); // updates the peer connection's ul/dl bandwidth // resource requests - p->second_tick(tick_interval); + try + { + p->second_tick(tick_interval); + } + catch (std::exception& e) + { +#ifdef TORRENT_VERBOSE_LOGGING + (*p->m_logger) << "**ERROR**: " << e.what() << "\n"; +#endif + p->set_failed(); + p->disconnect(); + } } accumulator += m_stat; m_stat.second_tick(tick_interval);