Changeset 11982


Ignore:
Timestamp:
Feb 19, 2011, 12:32:41 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) #3372 "What happened with closing idle peers?" -- fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r11981 r11982  
    30873087***/
    30883088
    3089 typedef enum
    3090 {
    3091     TR_CAN_KEEP,
    3092     TR_CAN_CLOSE,
    3093     TR_MUST_CLOSE,
    3094 }
    3095 tr_close_type_t;
    3096 
    3097 static tr_close_type_t
     3089static tr_bool
    30983090shouldPeerBeClosed( const Torrent    * t,
    30993091                    const tr_peer    * peer,
     
    31093101        tordbg( t, "purging peer %s because its doPurge flag is set",
    31103102                tr_atomAddrStr( atom ) );
    3111         return TR_MUST_CLOSE;
     3103        return TRUE;
    31123104    }
    31133105
     
    31343126            tordbg( t, "purging peer %s because we're both seeds",
    31353127                    tr_atomAddrStr( atom ) );
    3136             return TR_MUST_CLOSE;
     3128            return TRUE;
    31373129        }
    31383130    }
     
    31553147            tordbg( t, "purging peer %s because it's been %d secs since we shared anything",
    31563148                       tr_atomAddrStr( atom ), idleTime );
    3157             return TR_CAN_CLOSE;
    3158         }
    3159     }
    3160 
    3161     return TR_CAN_KEEP;
     3149            return TRUE;
     3150        }
     3151    }
     3152
     3153    return FALSE;
    31623154}
    31633155
    31643156static tr_peer **
    3165 getPeersToClose( Torrent * t, tr_close_type_t closeType,
    3166                  const time_t now_sec,
    3167                  int * setmeSize )
     3157getPeersToClose( Torrent * t, const time_t now_sec, int * setmeSize )
    31683158{
    31693159    int i, peerCount, outsize;
     
    31743164
    31753165    for( i = outsize = 0; i < peerCount; ++i )
    3176         if( shouldPeerBeClosed( t, peers[i], peerCount, now_sec ) == closeType )
     3166        if( shouldPeerBeClosed( t, peers[i], peerCount, now_sec ) )
    31773167            ret[outsize++] = peers[i];
    31783168
     
    32723262{
    32733263    int i;
    3274     int mustCloseCount;
    3275     struct tr_peer ** mustClose = getPeersToClose( t, TR_MUST_CLOSE, now_sec, &mustCloseCount );
    3276     for( i=0; i<mustCloseCount; ++i )
    3277         closePeer( t, mustClose[i] );
    3278     tr_free( mustClose );
     3264    int peerCount;
     3265    struct tr_peer ** peers = getPeersToClose( t, now_sec, &peerCount );
     3266    for( i=0; i<peerCount; ++i )
     3267        closePeer( t, peers[i] );
     3268    tr_free( peers );
    32793269}
    32803270
Note: See TracChangeset for help on using the changeset viewer.