From 7ed2d7c87a25971ee41fa1d6c58d5bddda34c52b Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 30 Sep 2008 22:37:50 +0000 Subject: [PATCH] lt sync 2744 --- libtorrent/src/disk_io_thread.cpp | 3 ++- libtorrent/src/http_tracker_connection.cpp | 2 +- libtorrent/src/session_impl.cpp | 3 ++- libtorrent/src/storage.cpp | 1 + libtorrent/src/torrent.cpp | 5 ++++- libtorrent/src/udp_socket.cpp | 1 + 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libtorrent/src/disk_io_thread.cpp b/libtorrent/src/disk_io_thread.cpp index 901834634..31c60171f 100644 --- a/libtorrent/src/disk_io_thread.cpp +++ b/libtorrent/src/disk_io_thread.cpp @@ -636,10 +636,11 @@ namespace libtorrent TORRENT_ASSERT(j.buffer_size <= m_block_size); mutex_t::scoped_lock l(m_queue_mutex); #ifndef NDEBUG + mutex_t::scoped_lock l2(m_piece_mutex); if (j.action == disk_io_job::write) { cache_t::iterator p - = find_cached_piece(m_pieces, j, l); + = find_cached_piece(m_pieces, j, l2); if (p != m_pieces.end()) { int block = j.offset / m_block_size; diff --git a/libtorrent/src/http_tracker_connection.cpp b/libtorrent/src/http_tracker_connection.cpp index f3a647fa8..bfde36e76 100755 --- a/libtorrent/src/http_tracker_connection.cpp +++ b/libtorrent/src/http_tracker_connection.cpp @@ -245,7 +245,7 @@ namespace libtorrent std::string error_str("invalid bencoding of tracker response: \""); for (char const* i = data, *end(data + size); i != end; ++i) { - if (std::isprint(*i)) error_str += *i; + if (*i >= ' ' && *i <= '~') error_str += *i; else error_str += "0x" + boost::lexical_cast((unsigned int)*i) + " "; } error_str += "\""; diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index ae2846e2c..e633a1a1a 100755 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -1136,7 +1136,8 @@ namespace aux { int free_slots = m_half_open.free_slots(); if (!m_torrents.empty() && free_slots > -m_half_open.limit() - && num_connections() < m_max_connections) + && num_connections() < m_max_connections + && !m_abort) { // this is the maximum number of connections we will // attempt this tick diff --git a/libtorrent/src/storage.cpp b/libtorrent/src/storage.cpp index dd6e82201..8466109e3 100755 --- a/libtorrent/src/storage.cpp +++ b/libtorrent/src/storage.cpp @@ -58,6 +58,7 @@ POSSIBILITY OF SUCH DAMAGE. #pragma warning(pop) #endif +#include "libtorrent/config.hpp" #include "libtorrent/storage.hpp" #include "libtorrent/torrent.hpp" #include "libtorrent/hasher.hpp" diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index 49710cf4d..40dbb87c5 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -3053,7 +3053,8 @@ namespace libtorrent { session_impl::mutex_t::scoped_lock l(m_ses.m_mutex); - INVARIANT_CHECK; +// doesn't work with the m_paused -> m_num_peers == 0 condition +// INVARIANT_CHECK; while (!m_connections.empty()) { @@ -3500,6 +3501,8 @@ namespace libtorrent { session_impl::mutex_t::scoped_lock l(m_ses.m_mutex); + if (is_paused()) TORRENT_ASSERT(num_peers() == 0); + if (!m_ses.m_queued_for_checking.empty()) { // if there are torrents waiting to be checked diff --git a/libtorrent/src/udp_socket.cpp b/libtorrent/src/udp_socket.cpp index c36a97530..622cce7e6 100644 --- a/libtorrent/src/udp_socket.cpp +++ b/libtorrent/src/udp_socket.cpp @@ -111,6 +111,7 @@ void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_ s->async_receive_from(asio::buffer(m_v6_buf, sizeof(m_v6_buf)) , m_v6_ep, boost::bind(&udp_socket::on_read, this, s, _1, _2)); + ++m_outstanding; return; }