fixed potential issue where a piece could be checked twice

This commit is contained in:
Arvid Norberg 2010-04-22 01:53:09 +00:00
parent fea3bf2ced
commit d7c30bc01b
3 changed files with 7 additions and 8 deletions

View File

@ -28,6 +28,7 @@
incoming connection
* added more detailed instrumentation of the disk I/O thread
* fixed potential issue where a piece could be checked twice
* fixed build issue on windows related to GetCompressedSize()
* fixed deadlock when starting torrents with certain invalid tracker URLs
* fixed iterator bug in disk I/O thread

View File

@ -2352,6 +2352,7 @@ namespace libtorrent
m_timeout_extend = 0;
}
bool was_finished = picker.is_piece_finished(p.piece);
// did we request this block from any other peers?
bool multi = picker.num_peers(block_finished) > 1;
picker.mark_as_writing(block_finished, peer_info_struct());
@ -2370,7 +2371,7 @@ namespace libtorrent
// did we just finish the piece?
// this means all blocks are either written
// to disk or are in the disk write cache
if (picker.is_piece_finished(p.piece))
if (picker.is_piece_finished(p.piece) && !was_finished)
{
#ifdef TORRENT_DEBUG
check_postcondition post_checker2_(t, false);

View File

@ -677,6 +677,8 @@ namespace libtorrent
// avoid crash trying to access the picker when there is nont
if (is_seed()) return;
if (picker().have_piece(piece)) return;
peer_request p;
p.piece = piece;
p.start = 0;
@ -739,13 +741,6 @@ namespace libtorrent
m_need_save_resume_data = true;
picker().mark_as_finished(block_finished, 0);
// did we just finish the piece?
if (picker().is_piece_finished(p.piece))
{
async_verify_piece(p.piece, bind(&torrent::piece_finished, shared_from_this()
, p.piece, _1));
}
}
void torrent::on_disk_cache_complete(int ret, disk_io_job const& j)
@ -2106,6 +2101,8 @@ namespace libtorrent
TORRENT_ASSERT(valid_metadata());
TORRENT_ASSERT(!m_picker->have_piece(index));
// even though the piece passed the hash-check
// it might still have failed being written to disk
// if so, piece_picker::write_failed() has been