Changeset 10895


Ignore:
Timestamp:
Jun 27, 2010, 1:24:48 AM (12 years ago)
Author:
charles
Message:

(trunk libT) add randomness to the peer unchoking algorithm

File:
1 edited

Legend:

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

    r10877 r10895  
    1313#include <assert.h>
    1414#include <errno.h> /* error codes ERANGE, ... */
     15#include <limits.h> /* INT_MAX */
    1516#include <string.h> /* memcpy, memcmp, strstr */
    1617#include <stdlib.h> /* qsort */
     
    25802581    tr_bool         isChoked;
    25812582    int             rate;
     2583    int             salt;
    25822584    tr_peer *       peer;
    25832585};
     
    25952597    if( a->isChoked != b->isChoked ) /* prefer unchoked */
    25962598        return a->isChoked ? 1 : -1;
     2599
     2600    if( a->salt != b->salt ) /* random order */
     2601        return a->salt - b->salt;
    25972602
    25982603    return 0;
     
    26662671            n->isChoked     = peer->peerIsChoked;
    26672672            n->rate         = getRate( t->tor, atom, now );
     2673            n->salt         = tr_cryptoWeakRandInt( INT_MAX );
    26682674        }
    26692675    }
Note: See TracChangeset for help on using the changeset viewer.