diff --git a/ChangeLog b/ChangeLog index 19ad579aa..7438867cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -88,6 +88,7 @@ incoming connection * added more detailed instrumentation of the disk I/O thread + * fix for set_piece_deadline * add reset_piece_deadline function * fix merkle tree torrent assert diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 31c296839..4db29c171 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2745,6 +2745,10 @@ namespace libtorrent if ((int)m_download_queue.size() + (int)m_request_queue.size() > m_desired_queue_size * 2) return false; if (on_parole()) return false; + if (m_disconnecting) return false; + boost::shared_ptr t = m_torrent.lock(); + TORRENT_ASSERT(t); + if (t->upload_mode()) return false; return true; } diff --git a/src/torrent.cpp b/src/torrent.cpp index cd1d1a98d..624dedec5 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -7037,6 +7037,8 @@ namespace libtorrent for (std::list::iterator i = m_time_critical_pieces.begin() , end(m_time_critical_pieces.end()); i != end; ++i) { + if (peers.empty()) break; + if (i != m_time_critical_pieces.begin() && i->deadline > now + milliseconds(m_average_piece_time + m_piece_time_deviation * 4)) { @@ -7079,7 +7081,11 @@ namespace libtorrent } else if (!interesting_blocks.empty()) { - c.add_request(interesting_blocks.front(), peer_connection::req_time_critical); + if (!c.add_request(interesting_blocks.front(), peer_connection::req_time_critical)) + { + peers.erase(p); + continue; + } added_request = true; }