From d359e84b34ee6b4a3dbbd9bcede46dc994c23bb7 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 1 Nov 2008 01:38:14 +0000 Subject: [PATCH] fix connection_queue::close --- src/connection_queue.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/connection_queue.cpp b/src/connection_queue.cpp index d5228a66a..661bb7656 100644 --- a/src/connection_queue.cpp +++ b/src/connection_queue.cpp @@ -119,19 +119,14 @@ namespace libtorrent m_timer.cancel(ec); m_abort = true; - // make a copy of the list to go through, so - // that connections removing themseleves won't - // interfere with the iteration - std::list closing_entries = m_queue; - - // we don't want to call the timeout callback while we're locked - // since that is a recepie for dead-locks - l.unlock(); - - for (std::list::iterator i = closing_entries.begin() - , end(closing_entries.end()); i != end; ++i) + while (!m_queue.empty()) { - try { i->on_timeout(); } catch (std::exception&) {} + // we don't want to call the timeout callback while we're locked + // since that is a recepie for dead-locks + l.unlock(); + try { m_queue.front().on_timeout(); } catch (std::exception&) {} + l.lock(); + m_queue.pop_front(); } }