From 2936556573cc05273f9507faf8504a13f6f2511d Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 21 Sep 2014 02:06:03 +0000 Subject: [PATCH] fix bug in delay-load feature of torrents --- src/peer_connection.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index d3c95a9f1..b597db9d3 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -1343,7 +1343,11 @@ namespace libtorrent // info_hash and peer_id. If we do. close this connection. t->attach_peer(this); if (m_disconnecting) return; - m_torrent = wpt; + // it's important to assign the torrent after successfully attaching. + // if the peer disconnects while attaching, it's not a proper member + // of the torrent and peer_connection::disconnect() will fail if it + // think it is + m_torrent = t; if (m_exceeded_limit) {