From c66dda1c9f40803942bdaffea050228a13600ded Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 27 May 2009 16:50:46 +0000 Subject: [PATCH] fixed bug in disk cache flush, largest contiguous function --- src/disk_io_thread.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 36c6e6811..8042eaaea 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -549,6 +549,7 @@ namespace libtorrent current = 0; } } + if (current > ret) ret = current; return ret; } @@ -576,8 +577,13 @@ namespace libtorrent start = i + 1; } } + if (current > len) + { + len = current; + pos = start; + } - if (len < lower_limit) return 0; + if (len < lower_limit || len <= 0) return 0; len = flush_range(e, pos, pos + len, l); if (e->num_blocks == 0) m_pieces.erase(e); return len; @@ -642,6 +648,9 @@ namespace libtorrent , int start, int end, mutex_t::scoped_lock& l) { INVARIANT_CHECK; + + TORRENT_ASSERT(start < end); + // TODO: copy *e and unlink it before unlocking cached_piece_entry& p = *e; int piece_size = p.storage->info()->piece_size(p.piece);