diff --git a/include/libtorrent/disk_buffer_pool.hpp b/include/libtorrent/disk_buffer_pool.hpp index 7cc605f27..2d93c0f22 100644 --- a/include/libtorrent/disk_buffer_pool.hpp +++ b/include/libtorrent/disk_buffer_pool.hpp @@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #endif #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || TORRENT_DISK_STATS -#include +#include #endif namespace libtorrent @@ -129,8 +129,8 @@ namespace libtorrent public: void rename_buffer(char* buf, char const* category); protected: - std::map m_categories; - std::map m_buf_to_category; + boost::unordered_map m_categories; + boost::unordered_map m_buf_to_category; std::ofstream m_log; private: #endif diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 796c5af49..237ebe617 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -5883,6 +5883,7 @@ namespace libtorrent // num_requests[i->block].peers.push_back(&p); } } + piece_picker::downloading_piece last_piece; for (std::map::iterator i = num_requests.begin() , end(num_requests.end()); i != end; ++i) { @@ -5893,12 +5894,18 @@ namespace libtorrent int count_with_nowant = pc.num_peers_with_nowant; (void)count_with_timeouts; (void)count_with_nowant; - int picker_count = t->picker().num_peers(b); - if (!t->picker().is_downloaded(b)) + if (b.piece_index != last_piece.index) + t->picker().piece_info(b.piece_index, last_piece); + + // has b been downloaded? + if ((last_piece.finished == 0 && last_piece.writing == 0) + || (last_piece.info && last_piece.info[b.block_index].state >= piece_picker::block_info::state_writing)) + { + int picker_count = t->picker().num_peers(b); TORRENT_ASSERT(picker_count == count); + } } } -#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS if (m_peer_info && type() == bittorrent_connection) { policy::const_iterator i = t->get_policy().begin_peer(); @@ -5909,7 +5916,6 @@ namespace libtorrent } TORRENT_ASSERT(i != end); } -#endif if (t->has_picker() && !t->is_aborted()) { // make sure that pieces that have completed the download @@ -5930,17 +5936,6 @@ namespace libtorrent complete = false; break; } -/* -// this invariant is not valid anymore since the completion event -// might be queued in the io service - if (complete && !piece_failed) - { - disk_io_job ret = m_ses.m_disk_thread.find_job( - &t->filesystem(), -1, i->index); - TORRENT_ASSERT(ret.action == disk_io_job::hash || ret.action == disk_io_job::write); - TORRENT_ASSERT(ret.piece == i->index); - } -*/ } } diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 326b34975..5eeb60936 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -142,7 +142,7 @@ namespace libtorrent void piece_picker::piece_info(int index, piece_picker::downloading_piece& st) const { #ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS - TORRENT_PIECE_PICKER_INVARIANT_CHECK; +// TORRENT_PIECE_PICKER_INVARIANT_CHECK; #endif TORRENT_ASSERT(index >= 0); @@ -153,7 +153,7 @@ namespace libtorrent std::vector::const_iterator piece = find_dl_piece(index); TORRENT_ASSERT(piece != m_downloads.end()); st = *piece; - st.info = 0; +// st.info = 0; return; } st.info = 0; diff --git a/test/test_utp.cpp b/test/test_utp.cpp index 1bda1edd8..7620d8869 100644 --- a/test/test_utp.cpp +++ b/test/test_utp.cpp @@ -100,7 +100,7 @@ void test_transfer() create_directory("./tmp1_utp", ec); std::ofstream file("./tmp1_utp/temporary"); - boost::intrusive_ptr t = ::create_torrent(&file, 512 * 1024, 20, false); + boost::intrusive_ptr t = ::create_torrent(&file, 128 * 1024, 6, false); file.close(); // for performance testing