fixed bug in add_piece() that would trigger asserts
This commit is contained in:
@@ -2089,7 +2089,7 @@ namespace libtorrent
|
||||
*j = i->peer_count + m_seeds;
|
||||
}
|
||||
|
||||
void piece_picker::mark_as_writing(piece_block block, void* peer)
|
||||
bool piece_picker::mark_as_writing(piece_block block, void* peer)
|
||||
{
|
||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
@@ -2133,7 +2133,10 @@ namespace libtorrent
|
||||
info.peer = peer;
|
||||
if (info.state == block_info::state_requested) --i->requested;
|
||||
TORRENT_ASSERT(i->requested >= 0);
|
||||
TORRENT_ASSERT(info.state != block_info::state_writing);
|
||||
if (info.state == block_info::state_writing
|
||||
|| info.state == block_info::state_finished)
|
||||
return false;
|
||||
|
||||
++i->writing;
|
||||
info.state = block_info::state_writing;
|
||||
|
||||
@@ -2149,6 +2152,7 @@ namespace libtorrent
|
||||
}
|
||||
sort_piece(i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void piece_picker::write_failed(piece_block block)
|
||||
|
Reference in New Issue
Block a user