fix bug that tended to disconnect from valid peers when we were seeding. also, follow the BT spec's terminology a little closer.

This commit is contained in:
Charles Kerr 2007-09-23 02:19:59 +00:00
parent 7a54e88d4e
commit 968868debe
3 changed files with 7 additions and 7 deletions

View File

@ -43,8 +43,8 @@ typedef struct tr_peer
/* the client name from the `v' string in LTEP's handshake dictionary */
char * client;
time_t clientSentBlockAt;
time_t peerSentBlockAt;
time_t clientSentPieceDataAt;
time_t peerSentPieceDataAt;
time_t peerSentKeepaliveAt;
time_t chokeChangedAt;
time_t connectionChangedAt;

View File

@ -1066,7 +1066,7 @@ clientIsSnubbedBy( const tr_peer * peer )
{
assert( peer != NULL );
return peer->peerSentBlockAt < (time(NULL) - SNUBBED_SEC);
return peer->peerSentPieceDataAt < (time(NULL) - SNUBBED_SEC);
}
/**
@ -1175,12 +1175,12 @@ shouldPeerBeDisconnected( Torrent * t, tr_peer * peer, int peerCount, int isSeed
else
strictness = peerCount / (double)relaxStrictnessIfFewerThanN;
/* test: has it been too long since we exchanged block data? */
/* test: has it been too long since we exchanged piece data? */
if( ( now - peer->connectionChangedAt ) >= MAX_TRANSFER_IDLE ) {
const uint64_t lo = MIN_TRANSFER_IDLE;
const uint64_t hi = MAX_TRANSFER_IDLE;
const uint64_t limit = lo + ((hi-lo) * strictness);
const uint64_t interval = now - (isSeeding ? peer->clientSentBlockAt : peer->peerSentBlockAt);
const uint64_t interval = now - (isSeeding ? peer->clientSentPieceDataAt : peer->peerSentPieceDataAt);
if( interval > limit )
return TRUE;
}

View File

@ -937,7 +937,7 @@ readBtPiece( tr_peermsgs * msgs, struct evbuffer * inbuf )
/* update our tables accordingly */
assert( inlen >= msgs->blockToUs.length );
msgs->blockToUs.length -= inlen;
msgs->info->peerSentBlockAt = time( NULL );
msgs->info->peerSentPieceDataAt = time( NULL );
clientGotBytes( msgs, inlen );
/* if this was the entire block, save it */
@ -1040,7 +1040,7 @@ pulse( void * vmsgs )
evbuffer_drain( msgs->outBlock, outlen );
peerGotBytes( msgs, outlen );
len -= outlen;
msgs->info->peerSentBlockAt = time( NULL );
msgs->info->clientSentPieceDataAt = time( NULL );
dbgmsg( msgs, "wrote %d bytes; %d left in block", (int)outlen, (int)len );
}
}