From 067219d14a26eb3bc5be83f3c99259c766551554 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 17 Apr 2007 09:21:53 +0000 Subject: [PATCH] made downloading pieces higher priority. fix in piece picker when blocks in prio 0 pieces were marked as finished --- include/libtorrent/piece_picker.hpp | 4 ++-- src/piece_picker.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 5a5b87626..2fe8b71fa 100755 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -285,8 +285,8 @@ namespace libtorrent int priority(int limit) const { if (filtered() || have()) return 0; - // pieces we are currently downloading are prioritized - int prio = downloading ? peer_count : peer_count * 2; + // pieces we are currently downloading have high priority + int prio = downloading ? 1 : peer_count * 2; // if the peer_count is 0 or 1, the priority cannot be higher if (prio <= 1) return prio; if (prio >= limit * 2) prio = limit * 2; diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index a3d6df068..8106af45c 100755 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -1240,6 +1240,7 @@ namespace libtorrent { p.downloading = 1; if (prio > 0) move(prio, p.index); + else add(block.piece_index); downloading_piece dp; dp.index = block.piece_index;