mirror of
https://github.com/transmission/transmission
synced 2025-03-15 16:29:34 +00:00
don't log BT protocol messages in UL/DL speed -- only log piece data transfers.
This commit is contained in:
parent
83f4509a0c
commit
75ff12faba
5 changed files with 33 additions and 52 deletions
|
@ -52,9 +52,6 @@ struct tr_peerIo
|
|||
unsigned int isIncoming : 1;
|
||||
unsigned int peerIdIsSet : 1;
|
||||
|
||||
tr_ratecontrol * rateToPeer;
|
||||
tr_ratecontrol * rateToClient;
|
||||
|
||||
tr_can_read_cb canRead;
|
||||
tr_did_write_cb didWrite;
|
||||
tr_net_error_cb gotError;
|
||||
|
@ -120,8 +117,6 @@ tr_peerIoNew( struct tr_handle * handle,
|
|||
c->in_addr = *in_addr;
|
||||
c->port = port;
|
||||
c->socket = socket;
|
||||
c->rateToPeer = tr_rcInit( );
|
||||
c->rateToClient = tr_rcInit( );
|
||||
c->isIncoming = isIncoming ? 1 : 0;
|
||||
c->bufev = bufferevent_new( c->socket,
|
||||
canReadWrapper,
|
||||
|
@ -174,9 +169,6 @@ tr_peerIoFree( tr_peerIo * c )
|
|||
bufferevent_free( c->bufev );
|
||||
tr_netClose( c->socket );
|
||||
|
||||
tr_rcClose( c->rateToClient );
|
||||
tr_rcClose( c->rateToPeer );
|
||||
|
||||
tr_cryptoFree( c->crypto );
|
||||
|
||||
tr_free( c );
|
||||
|
@ -398,7 +390,6 @@ tr_peerIoWrite( tr_peerIo * io,
|
|||
int writeme_len )
|
||||
{
|
||||
tr_bufferevent_write( io->handle, io->bufev, writeme, writeme_len );
|
||||
tr_rcTransferred( io->rateToPeer, writeme_len );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -502,14 +493,12 @@ tr_peerIoReadBytes( tr_peerIo * io,
|
|||
case PEER_ENCRYPTION_NONE:
|
||||
/*fprintf( stderr, "reading %d plaintext bytes from inbuf...\n", byteCount );*/
|
||||
evbuffer_remove( inbuf, bytes, byteCount );
|
||||
tr_rcTransferred( io->rateToClient, byteCount );
|
||||
break;
|
||||
|
||||
case PEER_ENCRYPTION_RC4:
|
||||
/*fprintf( stderr, "reading AND DECRYPTING %d bytes from inbuf...\n", byteCount );*/
|
||||
evbuffer_remove( inbuf, bytes, byteCount );
|
||||
tr_cryptoDecrypt( io->crypto, byteCount, bytes, bytes );
|
||||
tr_rcTransferred( io->rateToClient, byteCount );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -554,21 +543,3 @@ tr_peerIoDrain( tr_peerIo * io,
|
|||
tr_peerIoReadBytes( io, inbuf, tmp, byteCount );
|
||||
tr_free( tmp );
|
||||
}
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
||||
float
|
||||
tr_peerIoGetRateToClient( const tr_peerIo * io )
|
||||
{
|
||||
return io==NULL ? 0.0f : tr_rcRate( io->rateToClient );
|
||||
|
||||
}
|
||||
|
||||
float
|
||||
tr_peerIoGetRateToPeer( const tr_peerIo * io )
|
||||
{
|
||||
return io==NULL ? 0.0f : tr_rcRate( io->rateToPeer );
|
||||
}
|
||||
|
||||
|
|
|
@ -121,10 +121,6 @@ void tr_peerIoWriteBuf( tr_peerIo * io,
|
|||
struct evbuffer * buf );
|
||||
|
||||
|
||||
float tr_peerIoGetRateToClient( const tr_peerIo * io );
|
||||
|
||||
float tr_peerIoGetRateToPeer( const tr_peerIo * io );
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
|
|
@ -55,6 +55,9 @@ typedef struct tr_peer
|
|||
|
||||
struct tr_peermsgs * msgs;
|
||||
tr_publisher_tag msgsTag;
|
||||
|
||||
struct tr_ratecontrol * rateToClient;
|
||||
struct tr_ratecontrol * rateToPeer;
|
||||
}
|
||||
tr_peer;
|
||||
|
||||
|
|
|
@ -61,8 +61,13 @@ enum
|
|||
/* this is arbitrary and, hopefully, temporary until we come up
|
||||
* with a better idea for managing the connection limits */
|
||||
MAX_CONNECTED_PEERS_PER_TORRENT = 60,
|
||||
|
||||
|
||||
ADDED_F_ENCRYPTION_FLAG = 1,
|
||||
ADDED_F_SEED_FLAG = 2
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
@ -70,7 +75,7 @@ enum
|
|||
/* We keep one of these for every peer we know about, whether
|
||||
* it's connected or not, so the struct must be small.
|
||||
* When our current connections underperform, we dip back
|
||||
* int this list for new ones. */
|
||||
* into this list for new ones. */
|
||||
struct peer_atom
|
||||
{
|
||||
uint8_t from;
|
||||
|
@ -271,6 +276,8 @@ getPeer( Torrent * torrent, const struct in_addr * in_addr )
|
|||
if( peer == NULL )
|
||||
{
|
||||
peer = tr_new0( tr_peer, 1 );
|
||||
peer->rateToClient = tr_rcInit( );
|
||||
peer->rateToPeer = tr_rcInit( );
|
||||
memcpy( &peer->in_addr, in_addr, sizeof(struct in_addr) );
|
||||
tr_ptrArrayInsertSorted( torrent->peers, peer, peerCompare );
|
||||
}
|
||||
|
@ -307,6 +314,8 @@ static void
|
|||
freePeer( tr_peer * peer )
|
||||
{
|
||||
disconnectPeer( peer );
|
||||
tr_rcClose( peer->rateToClient );
|
||||
tr_rcClose( peer->rateToPeer );
|
||||
tr_free( peer->client );
|
||||
tr_free( peer );
|
||||
}
|
||||
|
@ -825,13 +834,13 @@ msgsCallbackFunc( void * vpeer, void * vevent, void * vt )
|
|||
tr_torrentRecheckCompleteness( t->tor );
|
||||
break;
|
||||
|
||||
case TR_PEERMSG_PEER_PROGRESS: { /* if we're both seeds, then disconnect. */
|
||||
#if 0
|
||||
const int clientIsSeed = tr_cpGetStatus( t->tor->completion ) != TR_CP_INCOMPLETE;
|
||||
case TR_PEERMSG_PEER_PROGRESS: {
|
||||
struct peer_atom * atom = getExistingAtom( t, &peer->in_addr );
|
||||
const int peerIsSeed = e->progress >= 1.0;
|
||||
if( clientIsSeed && peerIsSeed )
|
||||
peer->doPurge = 1;
|
||||
#endif
|
||||
if( peerIsSeed )
|
||||
atom->flags |= ADDED_F_SEED_FLAG;
|
||||
else
|
||||
atom->flags &= ~ADDED_F_SEED_FLAG;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1095,8 +1104,8 @@ tr_peerMgrGetPeers( tr_peerMgr * manager,
|
|||
walk->port = peer->port;
|
||||
|
||||
walk->flags = 0;
|
||||
if( peerPrefersCrypto(peer) ) walk->flags |= 1;
|
||||
if( peer->progress >= 1.0 ) walk->flags |= 2;
|
||||
if( peerPrefersCrypto(peer) ) walk->flags |= ADDED_F_ENCRYPTION_FLAG;
|
||||
if( peer->progress >= 1.0 ) walk->flags |= ADDED_F_SEED_FLAG;
|
||||
}
|
||||
|
||||
assert( ( walk - pex ) == peerCount );
|
||||
|
@ -1295,10 +1304,10 @@ tr_peerMgrTorrentStats( const tr_peerMgr * manager,
|
|||
|
||||
++setmePeersFrom[atom->from];
|
||||
|
||||
if( tr_peerIoGetRateToPeer( peer->io ) > 0.01 )
|
||||
if( tr_rcRate( peer->rateToPeer ) > 0.01 )
|
||||
++*setmePeersGettingFromUs;
|
||||
|
||||
if( tr_peerIoGetRateToClient( peer->io ) > 0.01 )
|
||||
if( tr_rcRate( peer->rateToClient ) > 0.01 )
|
||||
++*setmePeersSendingToUs;
|
||||
}
|
||||
|
||||
|
@ -1335,8 +1344,8 @@ tr_peerMgrPeerStats( const tr_peerMgr * manager,
|
|||
stat->client = peer->client;
|
||||
stat->progress = peer->progress;
|
||||
stat->isEncrypted = tr_peerIoIsEncrypted( peer->io ) ? 1 : 0;
|
||||
stat->uploadToRate = tr_peerIoGetRateToPeer( peer->io );
|
||||
stat->downloadFromRate = tr_peerIoGetRateToClient( peer->io );
|
||||
stat->uploadToRate = tr_rcRate( peer->rateToPeer );
|
||||
stat->downloadFromRate = tr_rcRate( peer->rateToClient );
|
||||
stat->isDownloading = stat->uploadToRate > 0.01;
|
||||
stat->isUploading = stat->downloadFromRate > 0.01;
|
||||
}
|
||||
|
@ -1416,7 +1425,8 @@ rechokeLeech( Torrent * t )
|
|||
node->peer = peer;
|
||||
node->preferred = peer->peerIsInterested && !clientIsSnubbedBy(peer);
|
||||
node->randomKey = tr_rand( INT_MAX );
|
||||
node->rate = tr_peerIoGetRateToClient( peer->io );
|
||||
node->rate = (3*tr_rcRate(peer->rateToPeer))
|
||||
+ (1*tr_rcRate(peer->rateToClient));
|
||||
}
|
||||
|
||||
qsort( choke, size, sizeof(ChokeData), compareChoke );
|
||||
|
@ -1515,8 +1525,8 @@ getWeakConnections( Torrent * t, int * setmeSize )
|
|||
int isWeak;
|
||||
const int peerIsSeed = peer->progress >= 1.0;
|
||||
const struct peer_atom * atom = getExistingAtom( t, &peer->in_addr );
|
||||
const double throughput = (2*tr_peerIoGetRateToPeer( peer->io ))
|
||||
+ tr_peerIoGetRateToClient( peer->io );
|
||||
const double throughput = (3*tr_rcRate(peer->rateToPeer))
|
||||
+ (1*tr_rcRate(peer->rateToClient));
|
||||
|
||||
assert( atom != NULL );
|
||||
|
||||
|
@ -1579,7 +1589,7 @@ getPeerCandidates( Torrent * t, int * setmeSize )
|
|||
}
|
||||
|
||||
/* no need to connect if we're both seeds... */
|
||||
if( seed && ( atom->flags & 2 ) ) {
|
||||
if( seed && (atom->flags & ADDED_F_SEED_FLAG) ) {
|
||||
fprintf( stderr, "RECONNECT peer %d (%s) is a seed and so are we...\n", i, tr_peerIoAddrStr(&atom->addr,atom->port) );
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -488,8 +488,7 @@ tr_peerMsgsAddRequest( tr_peermsgs * msgs,
|
|||
if( !tr_bitfieldHas( msgs->info->have, index ) )
|
||||
return TR_ADDREQ_MISSING;
|
||||
|
||||
maxSize = MIN( 2 + (int)(tr_peerIoGetRateToClient(msgs->io)/10), 100 );
|
||||
//if( ( time(NULL) - msgs->lastReqAddedAt <= 5 ) && ( tr_list_size( msgs->clientAskedFor) >= maxSize ) )
|
||||
maxSize = MIN( 3 + (int)(tr_rcRate(msgs->info->rateToClient)/10), 100 );
|
||||
if( tr_list_size( msgs->clientAskedFor) >= maxSize )
|
||||
return TR_ADDREQ_FULL;
|
||||
|
||||
|
@ -965,6 +964,7 @@ clientGotBytes( tr_peermsgs * msgs, uint32_t byteCount )
|
|||
tr_torrent * tor = msgs->torrent;
|
||||
tor->activityDate = tr_date( );
|
||||
tor->downloadedCur += byteCount;
|
||||
tr_rcTransferred( msgs->info->rateToClient, byteCount );
|
||||
tr_rcTransferred( tor->download, byteCount );
|
||||
tr_rcTransferred( tor->handle->download, byteCount );
|
||||
}
|
||||
|
@ -975,6 +975,7 @@ peerGotBytes( tr_peermsgs * msgs, uint32_t byteCount )
|
|||
tr_torrent * tor = msgs->torrent;
|
||||
tor->activityDate = tr_date( );
|
||||
tor->uploadedCur += byteCount;
|
||||
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