From 91d6099a5572d741f1eb392d403c7fe510ae1b9f Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 15 May 2008 02:29:26 +0000 Subject: [PATCH] fixed issue with torrents with 0 pieces. Fixes #306 --- src/peer_connection.cpp | 1 + src/storage.cpp | 3 ++- src/torrent.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index a4fa9ba42..363be476d 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -288,6 +288,7 @@ namespace libtorrent void peer_connection::start() { + TORRENT_ASSERT(m_peer_info == 0 || m_peer_info->connection == this); boost::shared_ptr t = m_torrent.lock(); if (!t) diff --git a/src/storage.cpp b/src/storage.cpp index 0596cc1b9..4e5373087 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -2465,7 +2465,8 @@ namespace libtorrent && m_free_slots.empty() && m_state == state_finished) { - TORRENT_ASSERT(m_storage_mode != storage_mode_compact); + TORRENT_ASSERT(m_storage_mode != storage_mode_compact + || m_info->num_pieces() == 0); } if (m_storage_mode != storage_mode_compact) diff --git a/src/torrent.cpp b/src/torrent.cpp index c1bacf534..216d1e6b6 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -2579,6 +2579,7 @@ namespace libtorrent // add the newly connected peer to this torrent's peer list m_connections.insert(boost::get_pointer(c)); m_ses.m_connections.insert(c); + peerinfo->connection = c.get(); c->start(); int timeout = settings().peer_connect_timeout; @@ -2603,7 +2604,6 @@ namespace libtorrent return false; } #endif - peerinfo->connection = c.get(); return true; }