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.
This commit is contained in:
Steven Siloti 2016-03-12 10:03:20 -08:00
parent 82d177472e
commit 9c5bb25d65
1 changed files with 3 additions and 2 deletions

View File

@ -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);