Changeset 10751


Ignore:
Timestamp:
Jun 14, 2010, 12:01:50 PM (12 years ago)
Author:
charles
Message:

(trunk libT) as long as I'm committing these CPU tweaks, might as well throw in #3289 too. To undo all this, we can revert to r10745

Location:
trunk/libtransmission
Files:
3 edited

Legend:

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

    r10750 r10751  
    119119    uint8_t     uploadOnly;         /* UPLOAD_ONLY_ */
    120120    int8_t      seedProbability;    /* how likely is this to be a seed... [0..100] or -1 for unknown */
     121    int8_t      blocklisted;        /* -1 for unknown, TRUE for blocklisted, FALSE for not blocklisted */
    121122
    122123    tr_port     port;
     
    544545    return peer->peerIsInterested && !peer->peerIsChoked;
    545546}
     547
     548/***
     549****
     550***/
     551
     552void
     553tr_peerMgrOnBlocklistChanged( tr_peerMgr * mgr )
     554{
     555    tr_torrent * tor = NULL;
     556    tr_session * session = mgr->session;
     557
     558    /* we cache whether or not a peer is blocklisted...
     559       since the blocklist has changed, erase that cached value */
     560    while(( tor = tr_torrentNext( session, tor )))
     561    {
     562        int i;
     563        Torrent * t = tor->torrentPeers;
     564        const int n = tr_ptrArraySize( &t->pool );
     565        for( i=0; i<n; ++i ) {
     566            struct peer_atom * atom = tr_ptrArrayNth( &t->pool, i );
     567            atom->blocklisted = -1;
     568        }
     569    }
     570}
     571
     572static tr_bool
     573isAtomBlocklisted( tr_session * session, struct peer_atom * atom )
     574{
     575    if( atom->blocklisted < 0 )
     576        atom->blocklisted = tr_sessionIsAddressBlocked( session, &atom->addr );
     577
     578    assert( tr_isBool( atom->blocklisted ) );
     579    return atom->blocklisted;
     580}
     581
    546582
    547583/***
     
    15401576        a->from = from;
    15411577        a->shelf_date = tr_time( ) + getDefaultShelfLife( from ) + jitter;
     1578        a->blocklisted = -1;
    15421579        atomSetSeedProbability( a, seedProbability );
    15431580        tr_ptrArrayInsertSorted( &t->pool, a, compareAtomsByAddress );
     
    32453282/* is this atom someone that we'd want to initiate a connection to? */
    32463283static tr_bool
    3247 isPeerCandidate( const tr_torrent * tor, const struct peer_atom * atom, const time_t now )
     3284isPeerCandidate( const tr_torrent * tor, struct peer_atom * atom, const time_t now )
    32483285{
    32493286    /* not if they're banned... */
     
    32613298 
    32623299    /* not if they're blocklisted */
    3263     /* FIXME: maybe we should remove this atom altogether? */
    3264     if( tr_sessionIsAddressBlocked( tor->session, &atom->addr ) )
     3300    if( isAtomBlocklisted( tor->session, atom ) )
    32653301        return FALSE;
    32663302
  • trunk/libtransmission/peer-mgr.h

    r10500 r10751  
    214214struct tr_bitfield* tr_peerMgrGetAvailable( const tr_torrent * tor );
    215215
     216void tr_peerMgrOnBlocklistChanged( tr_peerMgr * manager );
     217
    216218void tr_peerMgrTorrentStats( tr_torrent * tor,
    217219                             int * setmePeersKnown,
  • trunk/libtransmission/session.c

    r10736 r10751  
    19901990    closeBlocklists( session );
    19911991    loadBlocklists( session );
     1992
     1993    tr_peerMgrOnBlocklistChanged( session->peerMgr );
    19921994}
    19931995
Note: See TracChangeset for help on using the changeset viewer.