Changeset 10924


Ignore:
Timestamp:
Jul 1, 2010, 5:09:13 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #1521 "memory cache to reduce disk IO" -- improved revision from sadface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/cache.c

    r10923 r10924  
    9696
    9797/* return the starting index of the longest contiguous run of blocks BUT:
    98  *   1 - Length of run must be even.
    99  *   2 - Run must begin with a even block.
    100  *   3 - Oldest run is preferred.
     98 *   - Run should begin with a even block and length of run should be even.
     99 *   - Oldest run is preferred.
    101100 */
    102101static int
     
    108107    unsigned bestlen = 1;
    109108    unsigned jump;
    110     time_t oldest_time = ~0;
     109    time_t oldest_time = tr_time() + 1;
    111110    struct run_info run;
    112111
     
    122121        /* check alignment */
    123122        if( len % 2 == 0 ) {
    124             if( !run.is_aligned )
     123            if( !run.is_aligned ) {
    125124                /* Let it grow. Otherwise we contribute to fragmentation */
     125                if( bestlen == 1) {
     126                    /* But if all other blocks are non-contiguous, we prefer this one */
     127                    bestpos = pos;
     128                    oldest_time = cache->maxBlocks - len;
     129                }
    126130                continue;
     131            }
    127132        } else {
    128133            if( len != 1 ) {
Note: See TracChangeset for help on using the changeset viewer.