diff --git a/libtorrent/include/libtorrent/torrent.hpp b/libtorrent/include/libtorrent/torrent.hpp index 35390111..5cc50f34 100644 --- a/libtorrent/include/libtorrent/torrent.hpp +++ b/libtorrent/include/libtorrent/torrent.hpp @@ -529,6 +529,8 @@ namespace libtorrent // only once per piece void we_have(int index, boost::uint32_t post_flags); + void we_dont_have(int index); + int num_have() const { return has_picker() diff --git a/libtorrent/src/peer_connection.cpp b/libtorrent/src/peer_connection.cpp index a6ddb2d0..a54fd4f9 100644 --- a/libtorrent/src/peer_connection.cpp +++ b/libtorrent/src/peer_connection.cpp @@ -4571,6 +4571,11 @@ namespace libtorrent if (ret <= 0) { + if (t->has_picker() && t->have_piece(j.piece) ) { + printf("on_disk_read_complete: read error (database corrupt?) - setting we_dont_have(%d)\n", j.piece); + t->we_dont_have(j.piece); + } + if (ret == -3) { #if defined TORRENT_VERBOSE_LOGGING diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index 2cd04592..ba8a3ae1 100644 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -944,7 +944,7 @@ namespace libtorrent pieces->push_back( std::string(j.buffer, ret)); } else { printf("piece read error (database corrupt?) - setting we_dont_have(%d)\n", j.piece); - m_picker->we_dont_have(j.piece); + we_dont_have(j.piece); } (*reqs)--; @@ -3113,6 +3113,16 @@ namespace libtorrent m_picker->we_have(index, post_flags); } + void torrent::we_dont_have(int index) + { + TORRENT_ASSERT(m_ses.is_network_thread()); + // update m_file_progress + TORRENT_ASSERT(m_picker); + + m_picker->we_dont_have(index); + } + + void torrent::piece_passed(int index, boost::uint32_t post_flags) { // INVARIANT_CHECK;