Changeset 7353


Ignore:
Timestamp:
Dec 11, 2008, 7:04:46 AM (12 years ago)
Author:
charles
Message:

(trunk libT) fix bug which caused libtransmission to hold onto nonproductive peers for longer than it should've

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr-private.h

    r7231 r7353  
    6363    char                   * client;
    6464
    65     time_t                   peerSentPieceDataAt;
    6665    time_t                   chokeChangedAt;
    67     time_t                   pieceDataActivityDate;
    6866
    6967    struct tr_peermsgs     * msgs;
  • trunk/libtransmission/peer-mgr.c

    r7289 r7353  
    4949
    5050    /* when many peers are available, keep idle ones this long */
    51     MIN_UPLOAD_IDLE_SECS = ( 60 * 3 ),
     51    MIN_UPLOAD_IDLE_SECS = ( 30 ),
    5252
    5353    /* when few peers are available, keep idle ones this long */
    54     MAX_UPLOAD_IDLE_SECS = ( 60 * 10 ),
     54    MAX_UPLOAD_IDLE_SECS = ( 60 * 5 ),
    5555
    5656    /* how frequently to decide which peers live and die */
     
    10191019            if( peer ) {
    10201020                struct peer_atom * a = getExistingAtom( t, &peer->addr );
    1021                 a->piece_data_time = now;
     1021                if( e->wasPieceData )
     1022                    a->piece_data_time = now;
    10221023            }
    10231024
     
    10571058            if( peer ) {
    10581059                struct peer_atom * a = getExistingAtom( t, &peer->addr );
    1059                 a->piece_data_time = now;
     1060                if( e->wasPieceData )
     1061                    a->piece_data_time = now;
    10601062            }
    10611063
     
    12411243        atom = getExistingAtom( t, addr );
    12421244        atom->time = time( NULL );
     1245        atom->piece_data_time = 0;
    12431246
    12441247        if( atom->myflags & MYFLAG_BANNED )
     
    20282031        const int lo = MIN_UPLOAD_IDLE_SECS;
    20292032        const int hi = MAX_UPLOAD_IDLE_SECS;
    2030         const int limit = lo + ( ( hi - lo ) * strictness );
    2031         const time_t then = peer->pieceDataActivityDate;
    2032         const int idleTime = then ? ( now - then ) : 0;
     2033        const int limit = hi - ( ( hi - lo ) * strictness );
     2034        const int idleTime = now - MAX( atom->time, atom->piece_data_time );
     2035/*fprintf( stderr, "strictness is %.3f, limit is %d seconds... time since connect is %d, time since piece is %d ... idleTime is %d, doPurge is %d\n", (double)strictness, limit, (int)(now - atom->time), (int)(now - atom->piece_data_time), idleTime, idleTime > limit );*/
    20332036        if( idleTime > limit ) {
    20342037            tordbg( t, "purging peer %s because it's been %d secs since we shared anything",
     
    22202223            tr_peer * peer = connections[i];
    22212224            struct peer_atom * atom = getExistingAtom( t, &peer->addr );
    2222             if( peer->pieceDataActivityDate )
     2225            if( atom->piece_data_time )
    22232226                atom->numFails = 0;
    22242227            else
  • trunk/libtransmission/peer-msgs.c

    r7323 r7353  
    16701670    **/
    16711671
    1672     msgs->info->peerSentPieceDataAt = time( NULL );
    16731672    if(( err = tr_ioWrite( tor, req->index, req->offset, req->length, data )))
    16741673        return err;
Note: See TracChangeset for help on using the changeset viewer.