mirror of
https://github.com/transmission/transmission
synced 2025-03-04 02:28:03 +00:00
#870: follow PEX conventions agreed upon by Azureus and uTorrent
This commit is contained in:
parent
48e5a660df
commit
8a8b1fedb0
1 changed files with 16 additions and 22 deletions
|
@ -65,7 +65,7 @@ enum
|
||||||
/* idle seconds before we send a keepalive */
|
/* idle seconds before we send a keepalive */
|
||||||
KEEPALIVE_INTERVAL_SECS = 90,
|
KEEPALIVE_INTERVAL_SECS = 90,
|
||||||
|
|
||||||
PEX_INTERVAL = (60 * 1000), /* msec between sendPex() calls */
|
PEX_INTERVAL = (90 * 1000), /* msec between sendPex() calls */
|
||||||
PEER_PULSE_INTERVAL = (100), /* msec between pulse() calls */
|
PEER_PULSE_INTERVAL = (100), /* msec between pulse() calls */
|
||||||
RATE_PULSE_INTERVAL = (250), /* msec between ratePulse() calls */
|
RATE_PULSE_INTERVAL = (250), /* msec between ratePulse() calls */
|
||||||
|
|
||||||
|
@ -1753,8 +1753,10 @@ sendBitfield( tr_peermsgs * msgs )
|
||||||
**/
|
**/
|
||||||
|
|
||||||
/* some peers give us error messages if we send
|
/* some peers give us error messages if we send
|
||||||
more than this many peers in a single pex message */
|
more than this many peers in a single pex message
|
||||||
#define MAX_PEX_DIFFS 200
|
http://wiki.theory.org/BitTorrentPeerExchangeConventions */
|
||||||
|
#define MAX_PEX_ADDED 50
|
||||||
|
#define MAX_PEX_DROPPED 50
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -1764,31 +1766,28 @@ typedef struct
|
||||||
int addedCount;
|
int addedCount;
|
||||||
int droppedCount;
|
int droppedCount;
|
||||||
int elementCount;
|
int elementCount;
|
||||||
int diffCount;
|
|
||||||
}
|
}
|
||||||
PexDiffs;
|
PexDiffs;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pexAddedCb( void * vpex, void * userData )
|
pexAddedCb( void * vpex, void * userData )
|
||||||
{
|
{
|
||||||
PexDiffs * diffs = (PexDiffs *) userData;
|
PexDiffs * diffs = userData;
|
||||||
tr_pex * pex = (tr_pex *) vpex;
|
tr_pex * pex = vpex;
|
||||||
if( diffs->diffCount < MAX_PEX_DIFFS )
|
if( diffs->addedCount < MAX_PEX_ADDED )
|
||||||
{
|
{
|
||||||
diffs->diffCount++;
|
|
||||||
diffs->added[diffs->addedCount++] = *pex;
|
diffs->added[diffs->addedCount++] = *pex;
|
||||||
diffs->elements[diffs->elementCount++] = *pex;
|
diffs->elements[diffs->elementCount++] = *pex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pexRemovedCb( void * vpex, void * userData )
|
pexDroppedCb( void * vpex, void * userData )
|
||||||
{
|
{
|
||||||
PexDiffs * diffs = (PexDiffs *) userData;
|
PexDiffs * diffs = userData;
|
||||||
tr_pex * pex = (tr_pex *) vpex;
|
tr_pex * pex = vpex;
|
||||||
if( diffs->diffCount < MAX_PEX_DIFFS )
|
if( diffs->droppedCount < MAX_PEX_DROPPED )
|
||||||
{
|
{
|
||||||
diffs->diffCount++;
|
|
||||||
diffs->dropped[diffs->droppedCount++] = *pex;
|
diffs->dropped[diffs->droppedCount++] = *pex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1796,13 +1795,9 @@ pexRemovedCb( void * vpex, void * userData )
|
||||||
static void
|
static void
|
||||||
pexElementCb( void * vpex, void * userData )
|
pexElementCb( void * vpex, void * userData )
|
||||||
{
|
{
|
||||||
PexDiffs * diffs = (PexDiffs *) userData;
|
PexDiffs * diffs = userData;
|
||||||
tr_pex * pex = (tr_pex *) vpex;
|
tr_pex * pex = vpex;
|
||||||
if( diffs->diffCount < MAX_PEX_DIFFS )
|
diffs->elements[diffs->elementCount++] = *pex;
|
||||||
{
|
|
||||||
diffs->diffCount++;
|
|
||||||
diffs->elements[diffs->elementCount++] = *pex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1826,11 +1821,10 @@ sendPex( tr_peermsgs * msgs )
|
||||||
diffs.droppedCount = 0;
|
diffs.droppedCount = 0;
|
||||||
diffs.elements = tr_new( tr_pex, newCount + msgs->pexCount );
|
diffs.elements = tr_new( tr_pex, newCount + msgs->pexCount );
|
||||||
diffs.elementCount = 0;
|
diffs.elementCount = 0;
|
||||||
diffs.diffCount = 0;
|
|
||||||
tr_set_compare( msgs->pex, msgs->pexCount,
|
tr_set_compare( msgs->pex, msgs->pexCount,
|
||||||
newPex, newCount,
|
newPex, newCount,
|
||||||
tr_pexCompare, sizeof(tr_pex),
|
tr_pexCompare, sizeof(tr_pex),
|
||||||
pexRemovedCb, pexAddedCb, pexElementCb, &diffs );
|
pexDroppedCb, pexAddedCb, pexElementCb, &diffs );
|
||||||
dbgmsg( msgs, "pex: old peer count %d, new peer count %d, added %d, removed %d", msgs->pexCount, newCount, diffs.addedCount, diffs.droppedCount );
|
dbgmsg( msgs, "pex: old peer count %d, new peer count %d, added %d, removed %d", msgs->pexCount, newCount, diffs.addedCount, diffs.droppedCount );
|
||||||
|
|
||||||
/* update peer */
|
/* update peer */
|
||||||
|
|
Loading…
Add table
Reference in a new issue