Changeset 6623


Ignore:
Timestamp:
Aug 22, 2008, 2:34:22 AM (13 years ago)
Author:
muks
Message:

Sort piece_data_time in descending order.

Also fix code style in some places.

File:
1 edited

Legend:

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

    r6622 r6623  
    143143    assert( sup > 0 );
    144144
    145     if ( !init )
     145    if( !init )
    146146    {
    147147        srand( tr_date() );
     
    185185compareAddresses( const struct in_addr * a, const struct in_addr * b )
    186186{
    187     if (a->s_addr != b->s_addr)
     187    if( a->s_addr != b->s_addr )
    188188        return a->s_addr < b->s_addr ? -1 : 1;
    189189
     
    453453            uint32_t y = ntohl(*(uint32_t*)(x+j));             /* (6) */
    454454            uint32_t index = y % sz;                           /* (7) */
    455             if ( !tr_bitfieldHas( a, index ) ) {               /* (8) */
     455            if( !tr_bitfieldHas( a, index ) ) {                /* (8) */
    456456                tr_bitfieldAdd( a, index );                    /* (9) */
    457457                ++a_size;
     
    570570
    571571    /* otherwise if one has fewer peers, it goes first */
    572     if (a->peerCount != b->peerCount)
     572    if( a->peerCount != b->peerCount )
    573573        return a->peerCount < b->peerCount ? -1 : 1;
    574574
    575575    /* otherwise go with our random seed */
    576     if (a->random != b->random)
     576    if( a->random != b->random )
    577577        return a->random < b->random ? -1 : 1;
    578578
     
    17781778    const struct peer_atom * b = * (const struct peer_atom**) vb;
    17791779
     1780    /* <Charles> Here we would probably want to try reconnecting to
     1781     * peers that had most recently given us data. Lots of users have
     1782     * trouble with resets due to their routers and/or ISPs. This way we
     1783     * can quickly recover from an unwanted reset. So we sort
     1784     * piece_data_time in descending order.
     1785     */
     1786
    17801787    if( a->piece_data_time != b->piece_data_time )
    1781         return a->piece_data_time < b->piece_data_time ? -1 : 1;
     1788        return a->piece_data_time < b->piece_data_time ? 1 : -1;
    17821789
    17831790    if( a->numFails != b->numFails )
Note: See TracChangeset for help on using the changeset viewer.