mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
(trunk libT) "don't cancel requests for blocks that we're downloading from slow peers" -- fixed in trunk for 1.92
This commit is contained in:
parent
2be28fe9dd
commit
095cc3e05f
4 changed files with 36 additions and 26 deletions
|
@ -1143,9 +1143,9 @@ tr_handshakeAbort( tr_handshake * handshake )
|
|||
static void
|
||||
gotError( tr_peerIo * io UNUSED,
|
||||
short what,
|
||||
void * arg )
|
||||
void * vhandshake )
|
||||
{
|
||||
tr_handshake * handshake = (tr_handshake *) arg;
|
||||
tr_handshake * handshake = vhandshake;
|
||||
|
||||
/* if the error happened while we were sending a public key, we might
|
||||
* have encountered a peer that doesn't do encryption... reconnect and
|
||||
|
|
|
@ -83,7 +83,7 @@ enum
|
|||
MINIMUM_RECONNECT_INTERVAL_SECS = 5,
|
||||
|
||||
/** how long we'll let requests we've made linger before we cancel them */
|
||||
REQUEST_TTL_SECS = 45
|
||||
REQUEST_TTL_SECS = 60
|
||||
};
|
||||
|
||||
|
||||
|
@ -980,6 +980,8 @@ tr_peerMgrGetNextRequests( tr_torrent * tor,
|
|||
|
||||
/* sanity clause */
|
||||
assert( tr_isTorrent( tor ) );
|
||||
assert( peer->clientIsInterested );
|
||||
assert( !peer->clientIsChoked );
|
||||
assert( numwant > 0 );
|
||||
|
||||
/* walk through the pieces and find blocks that should be requested */
|
||||
|
@ -1103,7 +1105,7 @@ refillUpkeep( int foo UNUSED, short bar UNUSED, void * vmgr )
|
|||
|
||||
for( it=t->requests, end=it+n; it!=end; ++it )
|
||||
{
|
||||
if( it->sentAt <= too_old )
|
||||
if( ( it->sentAt <= too_old ) && !tr_peerMsgsIsReadingBlock( it->peer->msgs, it->block ) )
|
||||
cancel[cancelCount++] = *it;
|
||||
else
|
||||
{
|
||||
|
@ -2283,22 +2285,13 @@ compareChoke( const void * va,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* is this a new connection? */
|
||||
static int
|
||||
isNew( const tr_peer * peer )
|
||||
{
|
||||
return peer && peer->io && tr_peerIoGetAge( peer->io ) < 45;
|
||||
}
|
||||
|
||||
static int
|
||||
isSame( const tr_peer * peer )
|
||||
{
|
||||
return peer && peer->client && strstr( peer->client, "Transmission" );
|
||||
}
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
||||
static void
|
||||
rechokeTorrent( Torrent * t, const uint64_t now )
|
||||
{
|
||||
|
@ -2375,7 +2368,6 @@ rechokeTorrent( Torrent * t, const uint64_t now )
|
|||
const tr_peer * peer = choke[i].peer;
|
||||
int x = 1, y;
|
||||
if( isNew( peer ) ) x *= 3;
|
||||
if( isSame( peer ) ) x *= 3;
|
||||
for( y=0; y<x; ++y )
|
||||
tr_ptrArrayAppend( &randPool, &choke[i] );
|
||||
}
|
||||
|
@ -2407,9 +2399,11 @@ rechokePulse( int foo UNUSED, short bar UNUSED, void * vmgr )
|
|||
managerLock( mgr );
|
||||
|
||||
now = tr_date( );
|
||||
while(( tor = tr_torrentNext( mgr->session, tor )))
|
||||
if( tor->isRunning )
|
||||
while(( tor = tr_torrentNext( mgr->session, tor ))) {
|
||||
if( tor->isRunning ) {
|
||||
rechokeTorrent( tor->torrentPeers, now );
|
||||
}
|
||||
}
|
||||
|
||||
tr_timerAddMsec( mgr->rechokeTimer, RECHOKE_PERIOD_MSEC );
|
||||
managerUnlock( mgr );
|
||||
|
@ -3074,7 +3068,7 @@ pumpAllPeers( tr_peerMgr * mgr )
|
|||
static void
|
||||
bandwidthPulse( int foo UNUSED, short bar UNUSED, void * vmgr )
|
||||
{
|
||||
tr_torrent * tor = NULL;
|
||||
tr_torrent * tor;
|
||||
tr_peerMgr * mgr = vmgr;
|
||||
managerLock( mgr );
|
||||
|
||||
|
@ -3086,6 +3080,7 @@ bandwidthPulse( int foo UNUSED, short bar UNUSED, void * vmgr )
|
|||
tr_bandwidthAllocate( mgr->session->bandwidth, TR_DOWN, BANDWIDTH_PERIOD_MSEC );
|
||||
|
||||
/* possibly stop torrents that have seeded enough */
|
||||
tor = NULL;
|
||||
while(( tor = tr_torrentNext( mgr->session, tor ))) {
|
||||
if( tor->needsSeedRatioCheck ) {
|
||||
tor->needsSeedRatioCheck = FALSE;
|
||||
|
|
|
@ -711,18 +711,17 @@ isPeerInteresting( const tr_peermsgs * msgs )
|
|||
}
|
||||
|
||||
static void
|
||||
sendInterest( tr_peermsgs * msgs,
|
||||
int weAreInterested )
|
||||
sendInterest( tr_peermsgs * msgs, tr_bool clientIsInterested )
|
||||
{
|
||||
struct evbuffer * out = msgs->outMessages;
|
||||
|
||||
assert( msgs );
|
||||
assert( weAreInterested == 0 || weAreInterested == 1 );
|
||||
assert( tr_isBool( clientIsInterested ) );
|
||||
|
||||
msgs->peer->clientIsInterested = weAreInterested;
|
||||
dbgmsg( msgs, "Sending %s", weAreInterested ? "Interested" : "Not Interested" );
|
||||
msgs->peer->clientIsInterested = clientIsInterested;
|
||||
dbgmsg( msgs, "Sending %s", clientIsInterested ? "Interested" : "Not Interested" );
|
||||
tr_peerIoWriteUint32( msgs->peer->io, out, sizeof( uint8_t ) );
|
||||
tr_peerIoWriteUint8 ( msgs->peer->io, out, weAreInterested ? BT_INTERESTED : BT_NOT_INTERESTED );
|
||||
tr_peerIoWriteUint8 ( msgs->peer->io, out, clientIsInterested ? BT_INTERESTED : BT_NOT_INTERESTED );
|
||||
|
||||
pokeBatchPeriod( msgs, HIGH_PRIORITY_INTERVAL_SECS );
|
||||
dbgOutMessageLen( msgs );
|
||||
|
@ -1679,6 +1678,17 @@ canRead( tr_peerIo * io, void * vmsgs, size_t * piece )
|
|||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
tr_peerMsgsIsReadingBlock( const tr_peermsgs * msgs, tr_block_index_t block )
|
||||
{
|
||||
if( msgs->state != AWAITING_BT_PIECE )
|
||||
return FALSE;
|
||||
|
||||
return block == _tr_block( msgs->torrent,
|
||||
msgs->incoming.blockReq.index,
|
||||
msgs->incoming.blockReq.offset );
|
||||
}
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
@ -1696,6 +1706,10 @@ updateDesiredRequestCount( tr_peermsgs * msgs, uint64_t now )
|
|||
{
|
||||
msgs->desiredRequestCount = 0;
|
||||
}
|
||||
else if( !msgs->peer->clientIsInterested )
|
||||
{
|
||||
msgs->desiredRequestCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int irate;
|
||||
|
|
|
@ -39,8 +39,9 @@ tr_peermsgs* tr_peerMsgsNew( struct tr_torrent * torrent,
|
|||
tr_publisher_tag * setme );
|
||||
|
||||
|
||||
void tr_peerMsgsSetChoke( tr_peermsgs *,
|
||||
int doChoke );
|
||||
void tr_peerMsgsSetChoke( tr_peermsgs *, int doChoke );
|
||||
|
||||
int tr_peerMsgsIsReadingBlock( const tr_peermsgs * msgs, tr_block_index_t block );
|
||||
|
||||
void tr_peerMsgsHave( tr_peermsgs * msgs,
|
||||
uint32_t pieceIndex );
|
||||
|
|
Loading…
Reference in a new issue