From 4600dae248e232bd7992bb5e4ec9d631e84564b9 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 3 Oct 2010 01:22:11 +0000 Subject: [PATCH] more attempts to fix and catch invariant failure in download_queue --- src/peer_connection.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 0b42d9a05..bdaf06634 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2058,7 +2058,8 @@ namespace libtorrent // if this is not in the request queue, we have to // assume our outstanding bytes includes this piece too - if (!in_req_queue) + // if we're disconnecting, we shouldn't add pieces + if (!in_req_queue && !m_disconnecting) { for (std::vector::iterator i = m_request_queue.begin() , end(m_request_queue.end()); i != end; ++i) @@ -3287,6 +3288,11 @@ namespace libtorrent t->remove_peer(this); m_torrent.reset(); } + else + { + TORRENT_ASSERT(m_download_queue.empty()); + TORRENT_ASSERT(m_request_queue.empty()); + } #if defined TORRENT_DEBUG && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS // since this connection doesn't have a torrent reference