fixed potential problem if there are not enough references to a peer_connection when its disconnected

This commit is contained in:
Arvid Norberg 2009-01-25 02:45:31 +00:00
parent 9888ab62d6
commit c951ab3507
1 changed files with 12 additions and 0 deletions

View File

@ -2618,6 +2618,10 @@ namespace libtorrent
error_code ec;
m_socket->close(ec);
m_ses.close_connection(this, message);
// we should only disconnect while we still have
// at least one reference left to the connection
TORRENT_ASSERT(refcount() > 0);
}
void peer_connection::set_upload_limit(int limit)
@ -3620,6 +3624,10 @@ namespace libtorrent
INVARIANT_CHECK;
// keep ourselves alive in until this function exits in
// case we disconnect
boost::intrusive_ptr<peer_connection> me(self());
TORRENT_ASSERT(m_channel_state[download_channel] == peer_info::bw_network);
m_channel_state[download_channel] = peer_info::bw_idle;
@ -3911,6 +3919,10 @@ namespace libtorrent
INVARIANT_CHECK;
// keep ourselves alive in until this function exits in
// case we disconnect
boost::intrusive_ptr<peer_connection> me(self());
TORRENT_ASSERT(m_channel_state[upload_channel] == peer_info::bw_network);
m_send_buffer.pop_front(bytes_transferred);