From c54ffcbb8d3f4c0b1dbe87a2e9fc0927bbdf3c1a Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 1 Jan 2011 17:09:25 +0000 Subject: [PATCH] fix invalid assert --- src/policy.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/policy.cpp b/src/policy.cpp index b6f428c92..bd5199fa9 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -250,11 +250,18 @@ namespace libtorrent TORRENT_ASSERT(p.num_peers(*i) == 0); // don't request pieces we already have in our request queue + // This happens when pieces time out or the peer sends us + // pieces we didn't request. Those aren't marked in the + // piece picker, but we still keep track of them in the + // download queue if (std::find_if(dq.begin(), dq.end(), has_block(*i)) != dq.end() || std::find_if(rq.begin(), rq.end(), has_block(*i)) != rq.end()) { - // this can happen, not sure why. -// TORRENT_ASSERT(false); // this shouldn't happen! +#ifdef TORRENT_DEBUG + std::vector::const_iterator j + = std::find_if(dq.begin(), dq.end(), has_block(*i)); + if (j != dq.end()) TORRENT_ASSERT(j->timed_out || j->not_wanted); +#endif continue; }