fix stalled pieces on disk-full errors

This commit is contained in:
arvidn
2021-10-18 16:25:05 +02:00
committed by Arvid Norberg
parent d7c81f5b14
commit 6274094069
3 changed files with 13 additions and 3 deletions

View File

@ -1,3 +1,4 @@
* fix stalled pieces on disk-full errors
* fix build configuration issue on NetBSD, OpenBSD and DragonFly
* make UTF-8 sanitization a bit stricter. This will re-write invalid UTF-8
code points encoding surrogate pairs

View File

@ -1056,7 +1056,7 @@ namespace libtorrent {
std::cerr << "[" << this << "] " << "restore_piece(" << index << ")" << std::endl;
#endif
auto const download_state = m_piece_map[index].download_queue();
TORRENT_ASSERT(download_state != piece_pos::piece_open);
// if the piece was cancelled, it may have been removed
if (download_state == piece_pos::piece_open) return;
auto i = find_dl_piece(download_state, index);
@ -3407,7 +3407,7 @@ get_out:
// TODO: 2 it would be nice if this could be folded into lock_piece()
// the main distinction is that this also maintains the m_num_passed
// counter and the passed_hash_check member
// Is there ever a case where we call write filed without also locking
// Is there ever a case where we call write failed without also locking
// the piece? Perhaps write_failed() should imply locking it.
void piece_picker::write_failed(piece_block const block)
{

View File

@ -1234,10 +1234,19 @@ bool is_downloading_state(int const st)
pause();
}
void torrent::on_piece_fail_sync(piece_index_t, piece_block) try
void torrent::on_piece_fail_sync(piece_index_t const piece, piece_block) try
{
if (m_abort) return;
// the user may have called force_recheck, which clears
// the piece picker
if (has_picker())
{
// unlock the piece and restore it, as if no block was
// ever downloaded for it.
m_picker->restore_piece(piece);
}
update_gauge();
// some peers that previously was no longer interesting may
// now have become interesting, since we lack this one piece now.