mirror of
https://github.com/transmission/transmission
synced 2025-03-10 14:13:23 +00:00
(libT) possible fix for the up/down display inconsistency reported by BentMyWookie.
This commit is contained in:
parent
4ba7a222ab
commit
ea668ca9ff
3 changed files with 89 additions and 103 deletions
|
@ -1655,9 +1655,7 @@ tr_peerMgrTorrentStats( const tr_peerMgr * manager,
|
||||||
int * setmeWebseedsSendingToUs,
|
int * setmeWebseedsSendingToUs,
|
||||||
int * setmePeersSendingToUs,
|
int * setmePeersSendingToUs,
|
||||||
int * setmePeersGettingFromUs,
|
int * setmePeersGettingFromUs,
|
||||||
int * setmePeersFrom,
|
int * setmePeersFrom )
|
||||||
double * setmeRateToClient,
|
|
||||||
double * setmeRateToPeers )
|
|
||||||
{
|
{
|
||||||
int i, size;
|
int i, size;
|
||||||
const Torrent * t;
|
const Torrent * t;
|
||||||
|
@ -1675,8 +1673,6 @@ tr_peerMgrTorrentStats( const tr_peerMgr * manager,
|
||||||
*setmePeersGettingFromUs = 0;
|
*setmePeersGettingFromUs = 0;
|
||||||
*setmePeersSendingToUs = 0;
|
*setmePeersSendingToUs = 0;
|
||||||
*setmeWebseedsSendingToUs = 0;
|
*setmeWebseedsSendingToUs = 0;
|
||||||
*setmeRateToClient = 0;
|
|
||||||
*setmeRateToPeers = 0;
|
|
||||||
|
|
||||||
for( i = 0; i < TR_PEER_FROM__MAX; ++i )
|
for( i = 0; i < TR_PEER_FROM__MAX; ++i )
|
||||||
setmePeersFrom[i] = 0;
|
setmePeersFrom[i] = 0;
|
||||||
|
@ -1701,10 +1697,6 @@ tr_peerMgrTorrentStats( const tr_peerMgr * manager,
|
||||||
|
|
||||||
if( atom->flags & ADDED_F_SEED_FLAG )
|
if( atom->flags & ADDED_F_SEED_FLAG )
|
||||||
++ * setmeSeedsConnected;
|
++ * setmeSeedsConnected;
|
||||||
|
|
||||||
*setmeRateToClient += tr_peerIoGetRateToClient( peer->io );
|
|
||||||
|
|
||||||
*setmeRateToPeers += tr_peerIoGetRateToPeer( peer->io );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
webseeds = (const tr_webseed **) tr_ptrArrayPeek( t->webseeds, &size );
|
webseeds = (const tr_webseed **) tr_ptrArrayPeek( t->webseeds, &size );
|
||||||
|
@ -2506,6 +2498,9 @@ allocateBandwidth( tr_peerMgr * mgr,
|
||||||
const size_t used = countPeerBandwidth( t->peers, direction );
|
const size_t used = countPeerBandwidth( t->peers, direction );
|
||||||
countHandshakeBandwidth( t->outgoingHandshakes, direction );
|
countHandshakeBandwidth( t->outgoingHandshakes, direction );
|
||||||
|
|
||||||
|
/* remember this torrent's bytes used */
|
||||||
|
t->tor->rateHistory[direction][pulseNumber] = used;
|
||||||
|
|
||||||
/* add this torrent's bandwidth use to allBytesUsed */
|
/* add this torrent's bandwidth use to allBytesUsed */
|
||||||
allBytesUsed += used;
|
allBytesUsed += used;
|
||||||
|
|
||||||
|
@ -2517,12 +2512,10 @@ allocateBandwidth( tr_peerMgr * mgr,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TR_SPEEDLIMIT_SINGLE:
|
case TR_SPEEDLIMIT_SINGLE:
|
||||||
t->tor->rateHistory[direction][pulseNumber] = used;
|
|
||||||
|
|
||||||
setPeerBandwidth( t->peers, direction,
|
setPeerBandwidth( t->peers, direction,
|
||||||
t->tor->rateHistory[direction],
|
t->tor->rateHistory[direction],
|
||||||
tr_torrentGetSpeedLimit( t->tor,
|
tr_torrentGetSpeedLimit( t->tor,
|
||||||
direction ) );
|
direction ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TR_SPEEDLIMIT_GLOBAL:
|
case TR_SPEEDLIMIT_GLOBAL:
|
||||||
|
|
|
@ -44,115 +44,89 @@ typedef struct tr_pex
|
||||||
}
|
}
|
||||||
tr_pex;
|
tr_pex;
|
||||||
|
|
||||||
int tr_pexCompare( const void * a,
|
int tr_pexCompare( const void * a, const void * b );
|
||||||
const void * b );
|
|
||||||
|
|
||||||
tr_peerMgr* tr_peerMgrNew( struct tr_handle * );
|
tr_peerMgr* tr_peerMgrNew( struct tr_handle * );
|
||||||
|
|
||||||
void tr_peerMgrFree( tr_peerMgr * manager );
|
void tr_peerMgrFree( tr_peerMgr * manager );
|
||||||
|
|
||||||
int tr_peerMgrPeerIsSeed(
|
int tr_peerMgrPeerIsSeed( const tr_peerMgr * mgr,
|
||||||
const tr_peerMgr * mgr,
|
const uint8_t * torrentHash,
|
||||||
const uint8_t *
|
const struct in_addr * addr );
|
||||||
torrentHash,
|
|
||||||
const struct in_addr * addr );
|
|
||||||
|
|
||||||
void tr_peerMgrAddIncoming( tr_peerMgr * manager,
|
void tr_peerMgrAddIncoming( tr_peerMgr * manager,
|
||||||
struct in_addr * addr,
|
struct in_addr * addr,
|
||||||
uint16_t port,
|
uint16_t port,
|
||||||
int socket );
|
int socket );
|
||||||
|
|
||||||
tr_pex * tr_peerMgrCompactToPex( const void * compact,
|
tr_pex * tr_peerMgrCompactToPex( const void * compact,
|
||||||
size_t compactLen,
|
size_t compactLen,
|
||||||
const uint8_t * added_f,
|
const uint8_t * added_f,
|
||||||
size_t added_f_len,
|
size_t added_f_len,
|
||||||
size_t * setme_pex_count );
|
size_t * setme_pex_count );
|
||||||
|
|
||||||
void tr_peerMgrAddPex( tr_peerMgr * manager,
|
void tr_peerMgrAddPex( tr_peerMgr * manager,
|
||||||
const uint8_t * torrentHash,
|
const uint8_t * torrentHash,
|
||||||
uint8_t from,
|
uint8_t from,
|
||||||
const tr_pex * pex );
|
const tr_pex * pex );
|
||||||
|
|
||||||
void tr_peerMgrSetBlame( tr_peerMgr * manager,
|
void tr_peerMgrSetBlame( tr_peerMgr * manager,
|
||||||
const uint8_t * torrentHash,
|
const uint8_t * torrentHash,
|
||||||
tr_piece_index_t pieceIndex,
|
tr_piece_index_t pieceIndex,
|
||||||
int success );
|
int success );
|
||||||
|
|
||||||
int tr_peerMgrGetPeers( tr_peerMgr * manager,
|
int tr_peerMgrGetPeers( tr_peerMgr * manager,
|
||||||
const uint8_t * torrentHash,
|
const uint8_t * torrentHash,
|
||||||
tr_pex ** setme_pex );
|
tr_pex ** setme_pex );
|
||||||
|
|
||||||
void tr_peerMgrStartTorrent( tr_peerMgr * manager,
|
void tr_peerMgrStartTorrent( tr_peerMgr * manager,
|
||||||
const uint8_t * torrentHash );
|
const uint8_t * torrentHash );
|
||||||
|
|
||||||
void tr_peerMgrStopTorrent( tr_peerMgr * manager,
|
void tr_peerMgrStopTorrent( tr_peerMgr * manager,
|
||||||
const uint8_t * torrentHash );
|
const uint8_t * torrentHash );
|
||||||
|
|
||||||
void tr_peerMgrAddTorrent( tr_peerMgr * manager,
|
void tr_peerMgrAddTorrent( tr_peerMgr * manager,
|
||||||
struct tr_torrent * tor );
|
struct tr_torrent * tor );
|
||||||
|
|
||||||
void tr_peerMgrRemoveTorrent( tr_peerMgr * manager,
|
void tr_peerMgrRemoveTorrent( tr_peerMgr * manager,
|
||||||
const uint8_t * torrentHash );
|
const uint8_t * torrentHash );
|
||||||
|
|
||||||
void tr_peerMgrTorrentAvailability(
|
void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
|
||||||
const tr_peerMgr * manager,
|
const uint8_t * torrentHash,
|
||||||
const uint8_t *
|
int8_t * tab,
|
||||||
torrentHash,
|
unsigned int tabCount );
|
||||||
int8_t * tab,
|
|
||||||
unsigned int
|
|
||||||
tabCount );
|
|
||||||
|
|
||||||
struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager,
|
struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager,
|
||||||
const uint8_t * torrentHash );
|
const uint8_t * torrentHash );
|
||||||
|
|
||||||
int tr_peerMgrHasConnections(
|
int tr_peerMgrHasConnections( const tr_peerMgr * manager,
|
||||||
const tr_peerMgr * manager,
|
const uint8_t * torrentHash );
|
||||||
const uint8_t *
|
|
||||||
torrentHash );
|
|
||||||
|
|
||||||
void tr_peerMgrTorrentStats(
|
void tr_peerMgrTorrentStats( const tr_peerMgr * manager,
|
||||||
const tr_peerMgr * manager,
|
const uint8_t * torrentHash,
|
||||||
const uint8_t * torrentHash,
|
int * setmePeersKnown,
|
||||||
int *
|
int * setmePeersConnected,
|
||||||
setmePeersKnown,
|
int * setmeSeedsConnected,
|
||||||
int *
|
int * setmeWebseedsSendingToUs,
|
||||||
setmePeersConnected,
|
int * setmePeersSendingToUs,
|
||||||
int *
|
int * setmePeersGettingFromUs,
|
||||||
setmeSeedsConnected,
|
int * setmePeersFrom ); /* TR_PEER_FROM__MAX */
|
||||||
int *
|
|
||||||
setmeWebseedsSendingToUs,
|
|
||||||
int *
|
|
||||||
setmePeersSendingToUs,
|
|
||||||
int *
|
|
||||||
setmePeersGettingFromUs,
|
|
||||||
int *
|
|
||||||
setmePeersFrom, /* <-- array of
|
|
||||||
TR_PEER_FROM__MAX
|
|
||||||
*/
|
|
||||||
double *
|
|
||||||
setmeRateToClient,
|
|
||||||
double *
|
|
||||||
setmeRateToPeers );
|
|
||||||
|
|
||||||
double tr_peerMgrGetRate( const tr_peerMgr * manager,
|
double tr_peerMgrGetRate( const tr_peerMgr * manager,
|
||||||
tr_direction direction );
|
tr_direction direction );
|
||||||
|
|
||||||
struct tr_peer_stat * tr_peerMgrPeerStats( const tr_peerMgr * manager,
|
struct tr_peer_stat* tr_peerMgrPeerStats( const tr_peerMgr * manager,
|
||||||
const uint8_t * torrentHash,
|
const uint8_t * torrentHash,
|
||||||
int * setmeCount );
|
int * setmeCount );
|
||||||
|
|
||||||
float* tr_peerMgrWebSpeeds( const tr_peerMgr * manager,
|
float* tr_peerMgrWebSpeeds( const tr_peerMgr * manager,
|
||||||
const uint8_t * torrentHash );
|
const uint8_t * torrentHash );
|
||||||
|
|
||||||
|
|
||||||
struct tr_bitfield * tr_peerMgrGenerateAllowedSet(
|
struct tr_bitfield * tr_peerMgrGenerateAllowedSet( const uint32_t setCount,
|
||||||
const uint32_t setCount,
|
const uint32_t pieceCount,
|
||||||
const uint32_t
|
const uint8_t infohash[20],
|
||||||
pieceCount,
|
const struct in_addr * ip );
|
||||||
const uint8_t
|
|
||||||
infohash[20],
|
|
||||||
const struct in_addr *
|
|
||||||
ip );
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -713,6 +713,23 @@ tr_torrentInfo( const tr_torrent * tor )
|
||||||
return tor ? &tor->info : NULL;
|
return tor ? &tor->info : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double
|
||||||
|
tr_torrentGetRate( const tr_torrent * tor,
|
||||||
|
tr_direction direction )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
double bytes = 0;
|
||||||
|
|
||||||
|
assert( tor != NULL );
|
||||||
|
assert( direction == TR_UP || direction == TR_DOWN );
|
||||||
|
|
||||||
|
for( i = 0; i < BANDWIDTH_PULSE_HISTORY; ++i )
|
||||||
|
bytes += tor->rateHistory[direction][i];
|
||||||
|
|
||||||
|
return ( BANDWIDTH_PULSES_PER_SECOND * bytes )
|
||||||
|
/ ( BANDWIDTH_PULSE_HISTORY * 1024 );
|
||||||
|
}
|
||||||
|
|
||||||
const tr_stat *
|
const tr_stat *
|
||||||
tr_torrentStatCached( tr_torrent * tor )
|
tr_torrentStatCached( tr_torrent * tor )
|
||||||
{
|
{
|
||||||
|
@ -777,9 +794,11 @@ tr_torrentStat( tr_torrent * tor )
|
||||||
&s->webseedsSendingToUs,
|
&s->webseedsSendingToUs,
|
||||||
&s->peersSendingToUs,
|
&s->peersSendingToUs,
|
||||||
&s->peersGettingFromUs,
|
&s->peersGettingFromUs,
|
||||||
s->peersFrom,
|
s->peersFrom );
|
||||||
&s->rateDownload,
|
|
||||||
&s->rateUpload );
|
s->rateDownload = tr_torrentGetRate( tor, TR_PEER_TO_CLIENT );
|
||||||
|
|
||||||
|
s->rateUpload = tr_torrentGetRate( tor, TR_CLIENT_TO_PEER );
|
||||||
|
|
||||||
usableSeeds += tor->info.webseedCount;
|
usableSeeds += tor->info.webseedCount;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue