fixed a bug where the web seed could be disconnected in the process of a response without noticing. checked in to RC_0_12 and trunk

This commit is contained in:
Arvid Norberg
2007-04-27 02:33:09 +00:00
parent ee1681e2cb
commit 88277fd736

View File

@@ -472,8 +472,14 @@ namespace libtorrent
if (piece_size < front_request.length) if (piece_size < front_request.length)
return; return;
// each call to incoming_piece() may result in us becoming
// a seed. If we become a seed, all seeds we're connected to
// will be disconnected, including this web seed. We need to
// check for the disconnect condition after the call.
m_requests.pop_front(); m_requests.pop_front();
incoming_piece(front_request, &m_piece[0]); incoming_piece(front_request, &m_piece[0]);
if (m_torrent.expired()) return;
m_piece.clear(); m_piece.clear();
} }
@@ -489,6 +495,7 @@ namespace libtorrent
assert(http_body.left() >= r.length); assert(http_body.left() >= r.length);
incoming_piece(r, http_body.begin); incoming_piece(r, http_body.begin);
if (m_torrent.expired()) return;
http_body.begin += r.length; http_body.begin += r.length;
} }