fix to count download stats when a peer has disconnected or sends an invalid message id

This commit is contained in:
Arvid Norberg 2008-11-06 09:01:27 +00:00
parent 3c1d73ef72
commit 71fb640699
1 changed files with 6 additions and 1 deletions

View File

@ -1339,7 +1339,11 @@ namespace libtorrent
TORRENT_ASSERT(received > 0);
// this means the connection has been closed already
if (associated_torrent().expired()) return false;
if (associated_torrent().expired())
{
m_statistics.received_bytes(0, received);
return false;
}
buffer::const_interval recv_buffer = receive_buffer();
@ -1360,6 +1364,7 @@ namespace libtorrent
}
#endif
m_statistics.received_bytes(0, received);
std::stringstream msg;
msg << "unkown message id: " << packet_type << " size: " << packet_size();
disconnect(msg.str().c_str(), 2);