From 752149e34184220e82260696edd874d44cfddbbc Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 10 Feb 2008 20:36:48 +0000 Subject: [PATCH] fixed bug in write cache flush logic --- src/disk_io_thread.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index f0f6782ad..2d5acfffd 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -228,9 +228,10 @@ namespace libtorrent std::vector::iterator i = std::min_element( m_pieces.begin(), m_pieces.end() , bind(&cached_piece_entry::last_write, _1) - < bind(&cached_piece_entry::last_write, _1)); + < bind(&cached_piece_entry::last_write, _2)); if (i == m_pieces.end()) return; - if (total_seconds(now - i->last_write) < m_cache_expiry) return; + int age = total_seconds(now - i->last_write); + if (age < m_cache_expiry) return; flush_and_remove(i, l); } } @@ -241,7 +242,7 @@ namespace libtorrent std::vector::iterator i = std::min_element( m_pieces.begin(), m_pieces.end() , bind(&cached_piece_entry::last_write, _1) - < bind(&cached_piece_entry::last_write, _1)); + < bind(&cached_piece_entry::last_write, _2)); if (i == m_pieces.end()) return; flush_and_remove(i, l); }