From 4926081960b243128034235d6353e54e63809ce4 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 16 Mar 2016 02:22:18 -0400 Subject: [PATCH] fix use_read_cache=false --- include/libtorrent/block_cache.hpp | 1 + src/disk_io_thread.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/libtorrent/block_cache.hpp b/include/libtorrent/block_cache.hpp index be8f50672..f9de386ed 100644 --- a/include/libtorrent/block_cache.hpp +++ b/include/libtorrent/block_cache.hpp @@ -466,6 +466,7 @@ namespace libtorrent void dec_block_refcount(cached_piece_entry* pe, int block, int reason); int pinned_blocks() const { return m_pinned_blocks; } + int read_cache_size() const { return m_read_cache_size; } #if TORRENT_USE_ASSERTS void mark_deleted(file_storage const& fs); diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index e36b1e2b3..8c089879d 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -1070,6 +1070,14 @@ namespace libtorrent // a disk job is executed void disk_io_thread::check_cache_level(mutex::scoped_lock& l, jobqueue_t& completed_jobs) { + // when the read cache is disabled, always try to evict all read cache + // blocks + if (!m_settings.get_bool(settings_pack::use_read_cache)) + { + int const evict = m_disk_cache.read_cache_size(); + m_disk_cache.try_evict_blocks(evict); + } + int evict = m_disk_cache.num_to_evict(0); if (evict > 0) { @@ -2339,6 +2347,10 @@ namespace libtorrent return 0; } } + else if (m_settings.get_bool(settings_pack::use_read_cache) == false) + { + return do_uncached_hash(j); + } if (pe == NULL) {