Ignore:
Timestamp:
Aug 14, 2009, 8:55:22 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2335: when verifying local data, pause a few msec between pieces to give the system some breathing room and other processes a shot at the disk IO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/verify.c

    r8878 r8931  
    4747    tr_bool hadPiece = 0;
    4848    uint32_t piecePos = 0;
     49    uint32_t pieceBytesRead = 0;
    4950    tr_file_index_t fileIndex = 0;
    5051    tr_piece_index_t pieceIndex = 0;
     
    9091        if( (fd>=0) && tr_lseek( fd, filePos, SEEK_SET ) != -1 ) {
    9192            const int64_t numRead = read( fd, buffer, bytesThisPass );
     93            if( numRead > 0 )
     94                pieceBytesRead += numRead;
    9295            if( numRead == bytesThisPass )
    9396                SHA1_Update( &sha, buffer, numRead );
     
    121124            tor->anyDate = time( NULL );
    122125
     126            /* going full-throttle on a verify can choke other processes'
     127             * disk IO, so wait a fwe msec between pieces.
     128             * The msec is arbitrary, and the "if" clause is to make sure we
     129             * don't slow down verification of files that don't exist */
     130            if( pieceBytesRead == tr_torPieceCountBytes( tor, pieceIndex ) )
     131                tr_wait( 50 );
     132
    123133            SHA1_Init( &sha );
    124134            ++pieceIndex;
    125135            piecePos = 0;
     136            pieceBytesRead = 0;
    126137        }
    127138
Note: See TracChangeset for help on using the changeset viewer.