From 8961d095d789c378a4a33635981fb669684a1707 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 1 Jul 2010 17:09:13 +0000 Subject: [PATCH] (trunk libT) #1521 "memory cache to reduce disk IO" -- improved revision from sadface --- libtransmission/cache.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libtransmission/cache.c b/libtransmission/cache.c index b5fd15084..b8342304b 100644 --- a/libtransmission/cache.c +++ b/libtransmission/cache.c @@ -95,9 +95,8 @@ getBlockRun( const tr_cache * cache, int pos, struct run_info * info ) } /* return the starting index of the longest contiguous run of blocks BUT: - * 1 - Length of run must be even. - * 2 - Run must begin with a even block. - * 3 - Oldest run is preferred. + * - Run should begin with a even block and length of run should be even. + * - Oldest run is preferred. */ static int findChunk2Discard( tr_cache * cache, int * setme_n ) @@ -107,7 +106,7 @@ findChunk2Discard( tr_cache * cache, int * setme_n ) int bestpos = 0; unsigned bestlen = 1; unsigned jump; - time_t oldest_time = ~0; + time_t oldest_time = tr_time() + 1; struct run_info run; for( pos=0; posmaxBlocks - len; + } continue; + } } else { if( len != 1 ) { --len;