From cebb0b8212666a2d8b9f284e0a872ceac5a0692d Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 21 Feb 2010 09:07:09 +0000 Subject: [PATCH] fast piece optimization --- ChangeLog | 1 + src/peer_connection.cpp | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53bde4aa0..41b6b203a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -105,6 +105,7 @@ * added info_hash to torrent_deleted_alert * improved LSD performance and made the interval configurable * improved UDP tracker support by caching connect tokens + * fast piece optimization * fixed issue with disk read cache not being cleared when removing torrents release 0.14.9 diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 50ae37986..e53a7d309 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -559,6 +559,15 @@ namespace libtorrent return; } + if (upload_only()) + { +#ifdef TORRENT_VERBOSE_LOGGING + (*m_logger) << time_now_string() + << " *** SKIPPING ALLOWED SET BECAUSE PEER IS UPLOAD ONLY\n"; +#endif + return; + } + int num_allowed_pieces = m_ses.settings().allowed_fast_set_size; if (num_allowed_pieces == 0) return; @@ -571,9 +580,13 @@ namespace libtorrent // an allowed fast message for every single piece for (int i = 0; i < num_pieces; ++i) { + // there's no point in offering fast pieces + // that the peer already has + if (has_piece(i)) continue; + #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() - << " ==> ALLOWED_FAST [ " << i << " ]\n"; + (*m_logger) << time_now_string() + << " ==> ALLOWED_FAST [ " << i << " ]\n"; #endif write_allow_fast(i); TORRENT_ASSERT(std::find(m_accept_fast.begin()