Changeset 5602


Ignore:
Timestamp:
Apr 12, 2008, 11:01:40 PM (14 years ago)
Author:
charles
Message:

#870: follow PEX conventions agreed upon by Azureus and uTorrent

File:
1 edited

Legend:

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

    r5521 r5602  
    6666    KEEPALIVE_INTERVAL_SECS = 90,
    6767
    68     PEX_INTERVAL            = (60 * 1000), /* msec between sendPex() calls */
     68    PEX_INTERVAL            = (90 * 1000), /* msec between sendPex() calls */
    6969    PEER_PULSE_INTERVAL     = (100),       /* msec between pulse() calls */
    7070    RATE_PULSE_INTERVAL     = (250),       /* msec between ratePulse() calls */
     
    17541754
    17551755/* some peers give us error messages if we send
    1756    more than this many peers in a single pex message */
    1757 #define MAX_PEX_DIFFS 200
     1756   more than this many peers in a single pex message
     1757   http://wiki.theory.org/BitTorrentPeerExchangeConventions */
     1758#define MAX_PEX_ADDED 50
     1759#define MAX_PEX_DROPPED 50
    17581760
    17591761typedef struct
     
    17651767    int droppedCount;
    17661768    int elementCount;
    1767     int diffCount;
    17681769}
    17691770PexDiffs;
     
    17721773pexAddedCb( void * vpex, void * userData )
    17731774{
    1774     PexDiffs * diffs = (PexDiffs *) userData;
    1775     tr_pex * pex = (tr_pex *) vpex;
    1776     if( diffs->diffCount < MAX_PEX_DIFFS )
    1777     {
    1778         diffs->diffCount++;
     1775    PexDiffs * diffs = userData;
     1776    tr_pex * pex = vpex;
     1777    if( diffs->addedCount < MAX_PEX_ADDED )
     1778    {
    17791779        diffs->added[diffs->addedCount++] = *pex;
    17801780        diffs->elements[diffs->elementCount++] = *pex;
     
    17831783
    17841784static void
    1785 pexRemovedCb( void * vpex, void * userData )
    1786 {
    1787     PexDiffs * diffs = (PexDiffs *) userData;
    1788     tr_pex * pex = (tr_pex *) vpex;
    1789     if( diffs->diffCount < MAX_PEX_DIFFS )
    1790     {
    1791         diffs->diffCount++;
     1785pexDroppedCb( void * vpex, void * userData )
     1786{
     1787    PexDiffs * diffs = userData;
     1788    tr_pex * pex = vpex;
     1789    if( diffs->droppedCount < MAX_PEX_DROPPED )
     1790    {
    17921791        diffs->dropped[diffs->droppedCount++] = *pex;
    17931792    }
     
    17971796pexElementCb( void * vpex, void * userData )
    17981797{
    1799     PexDiffs * diffs = (PexDiffs *) userData;
    1800     tr_pex * pex = (tr_pex *) vpex;
    1801     if( diffs->diffCount < MAX_PEX_DIFFS )
    1802     {
    1803         diffs->diffCount++;
    1804         diffs->elements[diffs->elementCount++] = *pex;
    1805     }
     1798    PexDiffs * diffs = userData;
     1799    tr_pex * pex = vpex;
     1800    diffs->elements[diffs->elementCount++] = *pex;
    18061801}
    18071802
     
    18271822        diffs.elements = tr_new( tr_pex, newCount + msgs->pexCount );
    18281823        diffs.elementCount = 0;
    1829         diffs.diffCount = 0;
    18301824        tr_set_compare( msgs->pex, msgs->pexCount,
    18311825                        newPex, newCount,
    18321826                        tr_pexCompare, sizeof(tr_pex),
    1833                         pexRemovedCb, pexAddedCb, pexElementCb, &diffs );
     1827                        pexDroppedCb, pexAddedCb, pexElementCb, &diffs );
    18341828        dbgmsg( msgs, "pex: old peer count %d, new peer count %d, added %d, removed %d", msgs->pexCount, newCount, diffs.addedCount, diffs.droppedCount );
    18351829
Note: See TracChangeset for help on using the changeset viewer.