mirror of
https://github.com/transmission/transmission
synced 2024-12-25 17:17:31 +00:00
peer-msgs: faster upload speeds in situations with few peers. this patch needs wider testing for side-effects wrt speed limits.
This commit is contained in:
parent
c28e59e8b2
commit
3445817a80
3 changed files with 11 additions and 27 deletions
|
@ -994,26 +994,6 @@ ensureAtomExists( Torrent * t, const struct in_addr * addr, uint16_t port, uint8
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
maybeEnsureAtomExists( Torrent * t, const struct in_addr * addr, uint16_t port, uint8_t flags, uint8_t from )
|
||||
{
|
||||
if( tr_blocklistHasAddress( t->manager->handle, addr ) )
|
||||
{
|
||||
char * fmt = NULL;
|
||||
switch( from ) {
|
||||
case TR_PEER_FROM_TRACKER: fmt = _( "Banned IP address \"%s\" was given to us by the tracker" ); break;
|
||||
case TR_PEER_FROM_CACHE: fmt = _( "Banned IP address \"%s\" was found in the cache" ); break;
|
||||
case TR_PEER_FROM_PEX: fmt = _( "Banned IP address \"%s\" was given to us by another peer" ); break;
|
||||
case TR_PEER_FROM_INCOMING: fmt = _( "Banned IP address \"%s\" tried to connect to us" ); break;
|
||||
}
|
||||
tr_torinf( t->tor, fmt, inet_ntoa( *addr ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ensureAtomExists( t, addr, port, flags, from );
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
getMaxPeerCount( const tr_torrent * tor UNUSED )
|
||||
{
|
||||
|
@ -1119,7 +1099,7 @@ tr_peerMgrAddIncoming( tr_peerMgr * manager,
|
|||
|
||||
if( tr_blocklistHasAddress( manager->handle, addr ) )
|
||||
{
|
||||
tr_inf( _( "Banned IP address \"%s\" tried to connect to us" ),
|
||||
tr_dbg( "Banned IP address \"%s\" tried to connect to us",
|
||||
inet_ntoa( *addr ) );
|
||||
tr_netClose( socket );
|
||||
}
|
||||
|
@ -1157,7 +1137,8 @@ tr_peerMgrAddPex( tr_peerMgr * manager,
|
|||
managerLock( manager );
|
||||
|
||||
t = getExistingTorrent( manager, torrentHash );
|
||||
maybeEnsureAtomExists( t, &pex->in_addr, pex->port, pex->flags, from );
|
||||
if( !tr_blocklistHasAddress( t->manager->handle, &pex->in_addr ) )
|
||||
ensureAtomExists( t, &pex->in_addr, pex->port, pex->flags, from );
|
||||
|
||||
managerUnlock( manager );
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ enum
|
|||
RATE_PULSE_INTERVAL = (250), /* msec between ratePulse() calls */
|
||||
|
||||
MAX_QUEUE_SIZE = (100),
|
||||
MAX_OUTBUF_SIZE = (1024),
|
||||
|
||||
/* (fast peers) max number of pieces we fast-allow to another peer */
|
||||
MAX_FAST_ALLOWED_COUNT = 10,
|
||||
|
@ -1600,8 +1599,8 @@ getUploadMax( const tr_peermsgs * msgs )
|
|||
const tr_torrent * tor = msgs->torrent;
|
||||
const int useSwift = isSwiftEnabled( msgs );
|
||||
const size_t swiftLeft = msgs->info->credit;
|
||||
size_t speedLeft;
|
||||
size_t bufLeft;
|
||||
int speedLeft;
|
||||
int bufLeft;
|
||||
size_t ret;
|
||||
|
||||
if( tor->uploadLimitMode == TR_SPEEDLIMIT_GLOBAL )
|
||||
|
@ -1609,9 +1608,12 @@ getUploadMax( const tr_peermsgs * msgs )
|
|||
else if( tor->uploadLimitMode == TR_SPEEDLIMIT_SINGLE )
|
||||
speedLeft = tr_rcBytesLeft( tor->upload );
|
||||
else
|
||||
speedLeft = ~0;
|
||||
speedLeft = INT_MAX;
|
||||
|
||||
bufLeft = MAX_OUTBUF_SIZE - tr_peerIoWriteBytesWaiting( msgs->io );
|
||||
/* this basically says the outbuf shouldn't have more than one block
|
||||
* queued up in it... blocksize, +13 for the size of the BT protocol's
|
||||
* block message overhead */
|
||||
bufLeft = tor->blockSize + 13 - tr_peerIoWriteBytesWaiting( msgs->io );
|
||||
ret = MIN( speedLeft, bufLeft );
|
||||
if( useSwift)
|
||||
ret = MIN( ret, swiftLeft );
|
||||
|
|
|
@ -639,6 +639,7 @@ onScrapeResponse( struct evhttp_request * req, void * vhash )
|
|||
{
|
||||
const int interval = t->scrapeIntervalSec + t->randOffset;
|
||||
dbgmsg( t, "request succeeded. rescraping in %d seconds", interval );
|
||||
tr_ndbg( t->name, "request succeeded. rescraping in %d seconds", interval );
|
||||
t->scrapeAt = time( NULL ) + interval;
|
||||
}
|
||||
else if( 300<=responseCode && responseCode<=399 )
|
||||
|
|
Loading…
Reference in a new issue