Changeset 11532


Ignore:
Timestamp:
Dec 14, 2010, 6:33:48 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #3242 "use added.f's 'connectable' flag" -- added.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

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

    r11528 r11532  
    8080    PIECE_LIST_SHELF_LIFE_SECS = 60,
    8181
    82     /* use for bitwise operations w/peer_atom.myflags */
     82    /* use for bitwise operations w/peer_atom.flags2 */
    8383    MYFLAG_BANNED = 1,
    8484
    85     /* use for bitwise operations w/peer_atom.myflags */
     85    /* use for bitwise operations w/peer_atom.flags2 */
    8686    /* unreachable for now... but not banned.
    8787     * if they try to connect to us it's okay */
     
    124124    uint8_t     from;
    125125    uint8_t     flags;              /* these match the added_f flags */
    126     uint8_t     myflags;            /* flags that aren't defined in added_f */
     126    uint8_t     flags2;             /* flags that aren't defined in added_f */
    127127    uint8_t     uploadOnly;         /* UPLOAD_ONLY_ */
    128128    int8_t      seedProbability;    /* how likely is this to be a seed... [0..100] or -1 for unknown */
     
    12421242    {
    12431243        struct peer_atom * atom = peer->atom;
    1244         atom->myflags |= MYFLAG_BANNED;
     1244        atom->flags2 |= MYFLAG_BANNED;
    12451245        peer->doPurge = 1;
    12461246        tordbg( t, "banning peer %s", tr_atomAddrStr( atom ) );
     
    16501650                {
    16511651                    tordbg( t, "marking peer %s as unreachable... numFails is %d", tr_atomAddrStr( atom ), (int)atom->numFails );
    1652                     atom->myflags |= MYFLAG_UNREACHABLE;
     1652                    atom->flags2 |= MYFLAG_UNREACHABLE;
    16531653                }
    16541654            }
     
    16641664        atom->piece_data_time = 0;
    16651665        atom->lastConnectionAt = tr_time( );
    1666         atom->myflags &= ~MYFLAG_UNREACHABLE;
    1667 
    1668         if( atom->myflags & MYFLAG_BANNED )
     1666
     1667        if( !tr_peerIoIsIncoming( io ) )
     1668        {
     1669            atom->flags |= ADDED_F_CONNECTABLE;
     1670            atom->flags2 &= ~MYFLAG_UNREACHABLE;
     1671        }
     1672
     1673        if( atom->flags2 & MYFLAG_BANNED )
    16691674        {
    16701675            tordbg( t, "banned peer %s tried to reconnect",
     
    29322937
    29332938    /* penalize peers that were unreachable the last time we tried */
    2934     if( atom->myflags & MYFLAG_UNREACHABLE )
     2939    if( atom->flags2 & MYFLAG_UNREACHABLE )
    29352940        sec += sec;
    29362941
     
    33773382
    33783383    /* not if they're banned... */
    3379     if( atom->myflags & MYFLAG_BANNED )
     3384    if( atom->flags2 & MYFLAG_BANNED )
    33803385        return FALSE;
    33813386
     
    34343439    /* prefer torrents we're downloading with */
    34353440    i = tr_torrentIsSeed( tor ) ? 1 : 0;
     3441    score = addValToKey( score, 1, i );
     3442
     3443    /* prefer peers that are known to be connectible */
     3444    i = ( atom->flags & ADDED_F_CONNECTABLE ) ? 0 : 1;
    34363445    score = addValToKey( score, 1, i );
    34373446
     
    35613570        tordbg( t, "peerIo not created; marking peer %s as unreachable",
    35623571                tr_atomAddrStr( atom ) );
    3563         atom->myflags |= MYFLAG_UNREACHABLE;
     3572        atom->flags2 |= MYFLAG_UNREACHABLE;
    35643573        atom->numFails++;
    35653574    }
  • trunk/libtransmission/peer-mgr.h

    r11295 r11532  
    3939typedef struct tr_peerMgr tr_peerMgr;
    4040
     41/* added_f's bitwise-or'ed flags */
    4142enum
    4243{
    43     /* corresponds to ut_pex's added.f flags */
     44    /* true if the peer supports encryption */
    4445    ADDED_F_ENCRYPTION_FLAG = 1,
    4546
    46     /* corresponds to ut_pex's added.f flags */
     47    /* true if the peer is a seed or partial seed */
    4748    ADDED_F_SEED_FLAG = 2,
     49
     50    /* true if the peer supports uTP */
     51    ADDED_F_UTP_FLAGS = 4,
     52
     53    /* true if the peer has holepunch support */
     54    ADDED_F_HOLEPUNCH = 8,
     55
     56    /* true if the peer telling us about this peer
     57     * initiated the connection (implying that it is connectible) */
     58   ADDED_F_CONNECTABLE = 16
    4859};
    4960
Note: See TracChangeset for help on using the changeset viewer.