From 7ae866bf10dc4e4d5abaf5c532114535fea7f425 Mon Sep 17 00:00:00 2001 From: Daniel Wallin Date: Fri, 5 Dec 2003 10:10:06 +0000 Subject: [PATCH] *** empty log message *** --- examples/client_test.cpp | 2 +- include/libtorrent/storage.hpp | 2 ++ src/storage.cpp | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 179520c0e..4126f4e1d 100755 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -152,7 +152,7 @@ int main(int argc, char* argv[]) using namespace libtorrent; // TEMPORARY -// boost::filesystem::path::default_name_check(boost::filesystem::no_check); + boost::filesystem::path::default_name_check(boost::filesystem::no_check); if (argc < 2) { diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index cc6f7bb07..e90609df1 100755 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -171,6 +171,8 @@ namespace libtorrent private: + void libtorrent::storage::invariant() const; + // total number of bytes left to be downloaded entry::integer_type m_bytes_left; diff --git a/src/storage.cpp b/src/storage.cpp index a5a74a361..9a11f9690 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -1339,6 +1339,21 @@ void libtorrent::storage::initialize_pieces(torrent* t, print_bitmask(m_have_piece); std::cout << "\n"; std::cout << std::count(m_have_piece.begin(), m_have_piece.end(), true) << "\n"; + + invariant(); +} + +void libtorrent::storage::invariant() const +{ + // synchronization ------------------------------------------------------ + boost::recursive_mutex::scoped_lock lock(m_mutex); + // ---------------------------------------------------------------------- + + for (int i = 0; i < m_torrent_file->num_pieces(); ++i) + { + if (m_allocated_pieces[i] != m_torrent_file->piece_length() * i) + assert(m_slot_to_piece[i] < 0); + } } #if 0 // OLD STORAGE