Changeset 7354


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

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

Location:
branches/1.4x/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.4x/libtransmission/peer-mgr-private.h

    r7176 r7354  
    6565    char                   * client;
    6666
    67     time_t                   peerSentPieceDataAt;
    6867    time_t                   chokeChangedAt;
    69     time_t                   pieceDataActivityDate;
    7068
    7169    struct tr_peermsgs     * msgs;
  • branches/1.4x/libtransmission/peer-mgr.c

    r7176 r7354  
    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 */
     
    10251025            if( peer ) {
    10261026                struct peer_atom * a = getExistingAtom( t, &peer->in_addr );
    1027                 a->piece_data_time = now;
     1027                if( e->wasPieceData )
     1028                    a->piece_data_time = now;
    10281029            }
    10291030
     
    10541055            if( peer ) {
    10551056                struct peer_atom * a = getExistingAtom( t, &peer->in_addr );
    1056                 a->piece_data_time = now;
     1057                if( e->wasPieceData )
     1058                    a->piece_data_time = now;
    10571059            }
    10581060
     
    12501252        atom = getExistingAtom( t, addr );
    12511253        atom->time = time( NULL );
     1254        atom->piece_data_time = 0;
    12521255
    12531256        if( atom->myflags & MYFLAG_BANNED )
     
    20352038     * this is on a sliding scale based on number of available peers... */
    20362039    {
    2037         const int    relaxStrictnessIfFewerThanN =
    2038             (int)( ( getMaxPeerCount( tor ) * 0.9 ) + 0.5 );
     2040        const int relaxStrictnessIfFewerThanN = (int)( ( getMaxPeerCount( tor ) * 0.9 ) + 0.5 );
    20392041        /* if we have >= relaxIfFewerThan, strictness is 100%.
    20402042         * if we have zero connections, strictness is 0% */
    2041         const float  strictness = peerCount >= relaxStrictnessIfFewerThanN
    2042                                   ? 1.0
    2043                                   : peerCount /
    2044                                   (float)relaxStrictnessIfFewerThanN;
    2045         const int    lo = MIN_UPLOAD_IDLE_SECS;
    2046         const int    hi = MAX_UPLOAD_IDLE_SECS;
    2047         const int    limit = lo + ( ( hi - lo ) * strictness );
    2048         const time_t then = peer->pieceDataActivityDate;
    2049         const int    idleTime = then ? ( now - then ) : 0;
    2050         if( idleTime > limit )
    2051         {
    2052             tordbg(
    2053                 t,
    2054                 "purging peer %s because it's been %d secs since we shared anything",
    2055                 tr_peerIoAddrStr( &atom->addr, atom->port ), idleTime );
     2043        const float strictness = peerCount >= relaxStrictnessIfFewerThanN
     2044            ? 1.0
     2045            : peerCount / (float)relaxStrictnessIfFewerThanN;
     2046        const int lo = MIN_UPLOAD_IDLE_SECS;
     2047        const int hi = MAX_UPLOAD_IDLE_SECS;
     2048        const int limit = hi - ( ( hi - lo ) * strictness );
     2049        const int idleTime = now - MAX( atom->time, atom->piece_data_time );
     2050/*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 );*/
     2051        if( idleTime > limit ) {
     2052            tordbg( t, "purging peer %s because it's been %d secs since we shared anything",
     2053                       tr_peerIoAddrStr( &atom->addr, atom->port ), idleTime );
    20562054            return TRUE;
    20572055        }
     
    22572255            tr_peer *          peer = connections[i];
    22582256            struct peer_atom * atom = getExistingAtom( t, &peer->in_addr );
    2259             if( peer->pieceDataActivityDate )
     2257            if( atom->piece_data_time )
    22602258                atom->numFails = 0;
    22612259            else
  • branches/1.4x/libtransmission/peer-msgs.c

    r7322 r7354  
    16361636    **/
    16371637
    1638     msgs->info->peerSentPieceDataAt = time( NULL );
    16391638    if(( err = tr_ioWrite( tor, req->index, req->offset, req->length, data )))
    16401639        return err;
Note: See TracChangeset for help on using the changeset viewer.