From 575c6f5e4f67763a40fa00edf1dbded65f440ee5 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Thu, 23 Aug 2007 01:48:21 +0000 Subject: [PATCH] fix pause, piece picker, and bandwidth limit bugs --- libtorrent/include/libtorrent/bandwidth_manager.hpp | 1 + libtorrent/src/piece_picker.cpp | 2 +- libtorrent/src/session_impl.cpp | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libtorrent/include/libtorrent/bandwidth_manager.hpp b/libtorrent/include/libtorrent/bandwidth_manager.hpp index 75e1f1d4e..b0ff342a4 100644 --- a/libtorrent/include/libtorrent/bandwidth_manager.hpp +++ b/libtorrent/include/libtorrent/bandwidth_manager.hpp @@ -398,6 +398,7 @@ private: block_size = m_limit / (m_limit / max_bandwidth_block_size); } + if (block_size > qe.max_block_size) block_size = qe.max_block_size; } if (amount < block_size / 2) diff --git a/libtorrent/src/piece_picker.cpp b/libtorrent/src/piece_picker.cpp index d326b43bb..8eb79b149 100755 --- a/libtorrent/src/piece_picker.cpp +++ b/libtorrent/src/piece_picker.cpp @@ -639,7 +639,7 @@ namespace libtorrent if (dp == m_downloads.begin()) return; int complete = dp->writing + dp->finished; for (std::vector::iterator i = dp, j(dp-1); - i != m_downloads.begin() && j != m_downloads.begin(); --i, --j) + i != m_downloads.begin(); --i, --j) { assert(j >= m_downloads.begin()); if (j->finished + j->writing >= complete) return; diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index d20cf9668..4d45092cd 100755 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -1068,7 +1068,16 @@ namespace detail && !t->is_seed())) { if (!i->second->is_choked() && t) + { + policy::peer* pi = p->peer_info_struct(); + if (pi && pi->optimistically_unchoked) + { + pi->optimistically_unchoked = false; + // force a new optimistic unchoke + m_optimistic_unchoke_time_scaler = 0; + } t->choke_peer(*i->second); + } continue; } peers.push_back(i->second.get());