mirror of
https://github.com/transmission/transmission
synced 2025-03-12 15:14:12 +00:00
make the peer manager a little greedier w.r.t. keeping connections alive.
This commit is contained in:
parent
f4901211ca
commit
3dbaa7d673
3 changed files with 19 additions and 10 deletions
|
@ -49,9 +49,9 @@ typedef struct tr_peer
|
|||
/* the client name from the `v' string in LTEP's handshake dictionary */
|
||||
char * client;
|
||||
|
||||
time_t clientSentPieceDataAt;
|
||||
time_t peerSentPieceDataAt;
|
||||
time_t chokeChangedAt;
|
||||
time_t pieceDataActivityDate;
|
||||
|
||||
struct tr_peermsgs * msgs;
|
||||
tr_publisher_tag msgsTag;
|
||||
|
|
|
@ -520,15 +520,15 @@ tr_peerMgrFree( tr_peerMgr * manager )
|
|||
{
|
||||
managerLock( manager );
|
||||
|
||||
/* free the torrents. */
|
||||
tr_ptrArrayFree( manager->torrents, (PtrArrayForeachFunc)torrentDestructor );
|
||||
|
||||
/* free the handshakes. Abort invokes handshakeDoneCB(), which removes
|
||||
* the item from manager->handshakes, so this is a little roundabout... */
|
||||
while( !tr_ptrArrayEmpty( manager->incomingHandshakes ) )
|
||||
tr_handshakeAbort( tr_ptrArrayNth( manager->incomingHandshakes, 0 ) );
|
||||
tr_ptrArrayFree( manager->incomingHandshakes, NULL );
|
||||
|
||||
/* free the torrents. */
|
||||
tr_ptrArrayFree( manager->torrents, (PtrArrayForeachFunc)torrentDestructor );
|
||||
|
||||
managerUnlock( manager );
|
||||
tr_free( manager );
|
||||
}
|
||||
|
@ -1466,7 +1466,7 @@ struct tr_connection
|
|||
double throughput;
|
||||
};
|
||||
|
||||
#define LAISSEZ_FAIRE_PERIOD_SECS 60
|
||||
#define LAISSEZ_FAIRE_PERIOD_SECS 90
|
||||
|
||||
static int
|
||||
compareConnections( const void * va, const void * vb )
|
||||
|
@ -1500,16 +1500,23 @@ getWeakConnections( Torrent * t, int * setmeSize )
|
|||
|
||||
assert( atom != NULL );
|
||||
|
||||
if( peer->doPurge )
|
||||
if( throughput >= 3 )
|
||||
isWeak = FALSE;
|
||||
else if( peer->doPurge )
|
||||
isWeak = TRUE;
|
||||
if( peerIsSeed && clientIsSeed && (now-atom->time >= 30) ) /* pex time */
|
||||
else if( peerIsSeed && clientIsSeed && (now-atom->time >= 30) ) /* pex time */
|
||||
isWeak = TRUE;
|
||||
else if( ( now - atom->time ) < LAISSEZ_FAIRE_PERIOD_SECS )
|
||||
isWeak = FALSE;
|
||||
else if( throughput >= 5 )
|
||||
isWeak = FALSE;
|
||||
#if 0
|
||||
else
|
||||
isWeak = TRUE;
|
||||
#else
|
||||
else if( now - peer->pieceDataActivityDate > 180 )
|
||||
isWeak = TRUE;
|
||||
else
|
||||
isWeak = FALSE;
|
||||
#endif
|
||||
|
||||
if( isWeak )
|
||||
{
|
||||
|
@ -1603,7 +1610,7 @@ reconnectPulse( void * vtorrent )
|
|||
tr_peerIoAddrStr( &connections[i].peer->in_addr, connections[i].peer->port ), connections[i].throughput );
|
||||
|
||||
/* disconnect some peers */
|
||||
for( i=0; i<nConnections && i<(peerCount-5); ++i ) {
|
||||
for( i=0; i<nConnections && i<(peerCount-5) && i<MAX_RECONNECTIONS_PER_PULSE; ++i ) {
|
||||
const double throughput = connections[i].throughput;
|
||||
tr_peer * peer = connections[i].peer;
|
||||
tordbg( t, "RECONNECT culling peer %s, whose throughput was %f\n",
|
||||
|
|
|
@ -972,6 +972,7 @@ clientGotBytes( tr_peermsgs * msgs, uint32_t byteCount )
|
|||
tr_torrent * tor = msgs->torrent;
|
||||
tor->activityDate = tr_date( );
|
||||
tor->downloadedCur += byteCount;
|
||||
msgs->info->pieceDataActivityDate = time( NULL );
|
||||
tr_rcTransferred( msgs->info->rateToClient, byteCount );
|
||||
tr_rcTransferred( tor->download, byteCount );
|
||||
tr_rcTransferred( tor->handle->download, byteCount );
|
||||
|
@ -983,6 +984,7 @@ peerGotBytes( tr_peermsgs * msgs, uint32_t byteCount )
|
|||
tr_torrent * tor = msgs->torrent;
|
||||
tor->activityDate = tr_date( );
|
||||
tor->uploadedCur += byteCount;
|
||||
msgs->info->pieceDataActivityDate = time( NULL );
|
||||
tr_rcTransferred( msgs->info->rateToPeer, byteCount );
|
||||
tr_rcTransferred( tor->upload, byteCount );
|
||||
tr_rcTransferred( tor->handle->upload, byteCount );
|
||||
|
|
Loading…
Add table
Reference in a new issue