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());