From e48c09176471d7940469d9eedb09f77ae630f3f5 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 16 Sep 2008 02:39:03 +0000 Subject: [PATCH] lt sync 2676 --- .../include/libtorrent/session_settings.hpp | 2 +- libtorrent/src/disk_io_thread.cpp | 2 ++ libtorrent/src/kademlia/rpc_manager.cpp | 18 ++++++++++++++---- libtorrent/src/piece_picker.cpp | 10 +++++----- libtorrent/src/torrent.cpp | 4 ---- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/libtorrent/include/libtorrent/session_settings.hpp b/libtorrent/include/libtorrent/session_settings.hpp index 071e0d5c0..3d48fbbba 100644 --- a/libtorrent/include/libtorrent/session_settings.hpp +++ b/libtorrent/include/libtorrent/session_settings.hpp @@ -115,7 +115,7 @@ namespace libtorrent , max_outstanding_disk_bytes_per_connection(64 * 1024) , handshake_timeout(10) #ifndef TORRENT_DISABLE_DHT - , use_dht_as_fallback(true) + , use_dht_as_fallback(false) #endif , free_torrent_hashes(true) , upnp_ignore_nonrouters(true) diff --git a/libtorrent/src/disk_io_thread.cpp b/libtorrent/src/disk_io_thread.cpp index 2ce06e51a..dd9554d39 100644 --- a/libtorrent/src/disk_io_thread.cpp +++ b/libtorrent/src/disk_io_thread.cpp @@ -38,8 +38,10 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef _WIN32 #include +#ifndef alloca #define alloca(s) _alloca(s) #endif +#endif #ifdef TORRENT_DISK_STATS #include "libtorrent/time.hpp" diff --git a/libtorrent/src/kademlia/rpc_manager.cpp b/libtorrent/src/kademlia/rpc_manager.cpp index 3285577c5..c57059984 100644 --- a/libtorrent/src/kademlia/rpc_manager.cpp +++ b/libtorrent/src/kademlia/rpc_manager.cpp @@ -307,7 +307,9 @@ time_duration rpc_manager::tick() if (m_next_transaction_id == m_oldest_transaction_id) return milliseconds(timeout_ms); - std::vector timeouts; + std::vector timeouts; + + time_duration ret = milliseconds(timeout_ms); for (;m_next_transaction_id != m_oldest_transaction_id; m_oldest_transaction_id = (m_oldest_transaction_id + 1) % max_transactions) @@ -321,8 +323,16 @@ time_duration rpc_manager::tick() time_duration diff = o->sent + milliseconds(timeout_ms) - time_now(); if (diff > seconds(0)) { - if (diff < seconds(1)) return seconds(1); - return diff; + if (diff < seconds(1)) + { + ret = seconds(1); + break; + } + else + { + ret = diff; + break; + } } try @@ -343,7 +353,7 @@ time_duration rpc_manager::tick() // generate new requests. We need to swap, since the // destrutors may add more observers to the m_aborted_transactions std::vector().swap(m_aborted_transactions); - return milliseconds(timeout_ms); + return ret; } unsigned int rpc_manager::new_transaction_id(observer_ptr o) diff --git a/libtorrent/src/piece_picker.cpp b/libtorrent/src/piece_picker.cpp index f2ee3d450..0c480cf25 100755 --- a/libtorrent/src/piece_picker.cpp +++ b/libtorrent/src/piece_picker.cpp @@ -105,9 +105,9 @@ namespace libtorrent for (std::vector::const_iterator i = m_piece_map.begin() + m_cursor , end(m_piece_map.end()); i != end && (i->have() || i->filtered()); ++i, ++m_cursor); - for (std::vector::const_iterator i = m_piece_map.begin() - + m_reverse_cursor - 1; m_reverse_cursor > 0 && (i->have() || i->filtered()); - --i, --m_reverse_cursor); + for (std::vector::const_reverse_iterator i = m_piece_map.rend() + - m_reverse_cursor; m_reverse_cursor > 0 && (i->have() || i->filtered()); + ++i, --m_reverse_cursor); // the piece index is stored in 20 bits, which limits the allowed // number of pieces somewhat @@ -338,8 +338,8 @@ namespace libtorrent index = num_pieces; if (num_pieces > 0) { - for (std::vector::const_iterator i = m_piece_map.begin() - + (index - 1); index > 0 && (i->have() || i->filtered()); --i, --index); + for (std::vector::const_reverse_iterator i = m_piece_map.rend() + - index; index > 0 && (i->have() || i->filtered()); ++i, --index); TORRENT_ASSERT(index == num_pieces || m_piece_map[index].have() || m_piece_map[index].filtered()); diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index 0abcafc4b..33827d4a9 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -754,14 +754,10 @@ namespace libtorrent m_progress = j.piece / float(torrent_file().num_pieces()); - //m_picker->check_invariant(); - TORRENT_ASSERT(m_picker); if (j.offset >= 0 && !m_picker->have_piece(j.offset)) m_picker->we_have(j.offset); - //m_picker->check_invariant(); - // we're not done checking yet // this handler will be called repeatedly until // we're done, or encounter a failure