Merge pull request #493 from arvidn/web-seed-race-1.1

attempt to fix race when closing a web seed while it's receiving data
This commit is contained in:
Arvid Norberg 2016-02-24 21:18:27 -05:00
commit 81568724e8
1 changed files with 4 additions and 0 deletions

View File

@ -937,6 +937,8 @@ void web_peer_connection::incoming_payload(char const* buf, int len)
received_bytes(len, 0); received_bytes(len, 0);
m_received_body += len; m_received_body += len;
if (is_disconnecting()) return;
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log(peer_log_alert::incoming_message, "INCOMING_PAYLOAD", "%d bytes", len); peer_log(peer_log_alert::incoming_message, "INCOMING_PAYLOAD", "%d bytes", len);
#endif #endif
@ -944,6 +946,8 @@ void web_peer_connection::incoming_payload(char const* buf, int len)
// deliver all complete bittorrent requests to the bittorrent engine // deliver all complete bittorrent requests to the bittorrent engine
while (len > 0) while (len > 0)
{ {
if (m_requests.empty()) return;
TORRENT_ASSERT(!m_requests.empty()); TORRENT_ASSERT(!m_requests.empty());
peer_request const& front_request = m_requests.front(); peer_request const& front_request = m_requests.front();
int const piece_size = int(m_piece.size()); int const piece_size = int(m_piece.size());