From 9c5bb25d6570ddbc98308499086c5073d6482749 Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Sat, 12 Mar 2016 10:03:20 -0800 Subject: [PATCH] always clear outstanding_flush after attempting to flush a cached write Also clear outstanding_flush before calling kick_hasher because kick_hasher may unlock the cache mutex which can allow more dirty blocks to be added which may require another flush_hashed job be added. --- src/disk_io_thread.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index f864f5b0f..24e79b133 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -2905,6 +2905,9 @@ namespace libtorrent cached_piece_entry* pe = m_disk_cache.find_piece(j); if (pe == NULL) return 0; + + pe->outstanding_flush = 0; + if (pe->num_dirty == 0) return 0; // if multiple threads are flushing this piece, this assert may fire @@ -2942,8 +2945,6 @@ namespace libtorrent TORRENT_ASSERT(l.locked()); -// TORRENT_PIECE_ASSERT(pe->outstanding_flush == 1, pe); - pe->outstanding_flush = 0; --pe->piece_refcount; m_disk_cache.maybe_free_piece(pe);