1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

(trunk libT) peerMgr: operate directly on tr_torrent and not peerMgr+torrentHash

This commit is contained in:
Charles Kerr 2009-01-13 21:00:05 +00:00
parent f945058de0
commit 486c55c1ed
8 changed files with 102 additions and 192 deletions

View file

@ -415,9 +415,7 @@ parsePeers( tr_torrent * tor,
{
tr_pex pex;
readBytes( &pex, &buf, sizeof( tr_pex ) );
tr_peerMgrAddPex( tor->session->peerMgr, tor->info.hash,
TR_PEER_FROM_CACHE,
&pex );
tr_peerMgrAddPex( tor, TR_PEER_FROM_CACHE, &pex );
}
tr_tordbg( tor, "Loaded %d peers from resume file", count );

View file

@ -846,9 +846,7 @@ readCryptoProvide( tr_handshake * handshake,
if(( tor = tr_torrentFindFromObfuscatedHash( handshake->session, obfuscatedTorrentHash )))
{
const tr_bool clientIsSeed = tr_torrentIsSeed( tor );
const tr_bool peerIsSeed = tr_peerMgrPeerIsSeed( handshake->session->peerMgr,
tor->info.hash,
tr_peerIoGetAddress( handshake->io, NULL ) );
const tr_bool peerIsSeed = tr_peerMgrPeerIsSeed( tor, tr_peerIoGetAddress( handshake->io, NULL ) );
dbgmsg( handshake, "got INCOMING connection's encrypted handshake for torrent [%s]",
tor->info.name );
tr_peerIoSetTorrentHash( handshake->io, tor->info.hash );

View file

@ -1,3 +1,4 @@
/*
* This file Copyright (C) 2007-2009 Charles Kerr <charles@transmissionbt.com>
*
@ -115,7 +116,7 @@ struct peer_atom
time_t piece_data_time;
};
typedef struct
typedef struct tr_torrent_peers
{
tr_bool isRunning;
@ -138,7 +139,6 @@ Torrent;
struct tr_peerMgr
{
tr_session * session;
tr_ptrArray torrents; /* Torrent */
tr_ptrArray incomingHandshakes; /* tr_handshake */
tr_timer * bandwidthTimer;
};
@ -234,33 +234,13 @@ comparePeerAtoms( const void * va, const void * vb )
***
**/
static int
torrentCompare( const void * va,
const void * vb )
{
const Torrent * a = va;
const Torrent * b = vb;
return memcmp( a->hash, b->hash, SHA_DIGEST_LENGTH );
}
static int
torrentCompareToHash( const void * va,
const void * vb )
{
const Torrent * a = va;
const uint8_t * b_hash = vb;
return memcmp( a->hash, b_hash, SHA_DIGEST_LENGTH );
}
static Torrent*
getExistingTorrent( tr_peerMgr * manager,
const uint8_t * hash )
{
return (Torrent*) tr_ptrArrayFindSorted( &manager->torrents,
hash,
torrentCompareToHash );
tr_torrent * tor = tr_torrentFindFromHash( manager->session, hash );
return tor == NULL ? NULL : tor->torrentPeers;
}
static int
@ -453,7 +433,6 @@ tr_peerMgrNew( tr_session * session )
tr_peerMgr * m = tr_new0( tr_peerMgr, 1 );
m->session = session;
m->torrents = TR_PTR_ARRAY_INIT;
m->incomingHandshakes = TR_PTR_ARRAY_INIT;
m->bandwidthTimer = tr_timerNew( session, bandwidthPulse, m, BANDWIDTH_PERIOD_MSEC );
return m;
@ -473,9 +452,6 @@ tr_peerMgrFree( tr_peerMgr * manager )
tr_ptrArrayDestruct( &manager->incomingHandshakes, NULL );
/* free the torrents. */
tr_ptrArrayDestruct( &manager->torrents, torrentDestructor );
managerUnlock( manager );
tr_free( manager );
}
@ -497,17 +473,13 @@ clientIsUploadingTo( const tr_peer * peer )
***/
tr_bool
tr_peerMgrPeerIsSeed( const tr_peerMgr * mgr,
const uint8_t * torrentHash,
tr_peerMgrPeerIsSeed( const tr_torrent * tor,
const tr_address * addr )
{
tr_bool isSeed = FALSE;
const Torrent * t = NULL;
const struct peer_atom * atom = NULL;
const Torrent * t = tor->torrentPeers;
const struct peer_atom * atom = getExistingAtom( t, addr );
t = getExistingTorrent( (tr_peerMgr*)mgr, torrentHash );
if( t )
atom = getExistingAtom( t, addr );
if( atom )
isSeed = ( atom->flags & ADDED_F_SEED_FLAG ) != 0;
@ -1084,7 +1056,7 @@ peerCallbackFunc( void * vpeer, void * vevent, void * vt )
tr_torrentSetHasPiece( tor, p, ok );
tr_torrentSetPieceChecked( tor, p, TRUE );
tr_peerMgrSetBlame( tor->session->peerMgr, tor->info.hash, p, ok );
tr_peerMgrSetBlame( tor, p, ok );
if( !ok )
{
@ -1333,21 +1305,19 @@ tr_isPex( const tr_pex * pex )
}
void
tr_peerMgrAddPex( tr_peerMgr * manager,
const uint8_t * torrentHash,
tr_peerMgrAddPex( tr_torrent * tor,
uint8_t from,
const tr_pex * pex )
{
if( tr_isPex( pex ) ) /* safeguard against corrupt data */
{
Torrent * t;
managerLock( manager );
Torrent * t = tor->torrentPeers;
managerLock( t->manager );
t = getExistingTorrent( manager, torrentHash );
if( !tr_sessionIsAddressBlocked( t->manager->session, &pex->addr ) )
ensureAtomExists( t, &pex->addr, pex->port, pex->flags, from );
managerUnlock( manager );
managerUnlock( t->manager );
}
}
@ -1429,15 +1399,14 @@ tr_peerMgrArrayToPex( const void * array,
**/
void
tr_peerMgrSetBlame( tr_peerMgr * manager,
const uint8_t * torrentHash,
tr_peerMgrSetBlame( tr_torrent * tor,
tr_piece_index_t pieceIndex,
int success )
{
if( !success )
{
int peerCount, i;
Torrent * t = getExistingTorrent( manager, torrentHash );
Torrent * t = tor->torrentPeers;
tr_peer ** peers;
assert( torrentIsLocked( t ) );
@ -1489,22 +1458,15 @@ peerPrefersCrypto( const tr_peer * peer )
}
int
tr_peerMgrGetPeers( tr_peerMgr * manager,
const uint8_t * torrentHash,
tr_peerMgrGetPeers( tr_torrent * tor,
tr_pex ** setme_pex,
uint8_t af)
{
int peersReturning = 0;
const Torrent * t;
const Torrent * t = tor->torrentPeers;
managerLock( manager );
managerLock( t->manager );
t = getExistingTorrent( manager, torrentHash );
if( t == NULL )
{
*setme_pex = NULL;
}
else
{
int i;
const tr_peer ** peers = (const tr_peer**) tr_ptrArrayBase( &t->peers );
@ -1539,7 +1501,7 @@ tr_peerMgrGetPeers( tr_peerMgr * manager,
*setme_pex = pex;
}
managerUnlock( manager );
managerUnlock( t->manager );
return peersReturning;
}
@ -1548,14 +1510,11 @@ static int reconnectPulse( void * vtorrent );
static int rechokePulse( void * vtorrent );
void
tr_peerMgrStartTorrent( tr_peerMgr * manager,
const uint8_t * torrentHash )
tr_peerMgrStartTorrent( tr_torrent * tor )
{
Torrent * t;
Torrent * t = tor->torrentPeers;
managerLock( manager );
t = getExistingTorrent( manager, torrentHash );
managerLock( t->manager );
assert( t );
assert( ( t->isRunning != 0 ) == ( t->reconnectTimer != NULL ) );
@ -1581,7 +1540,7 @@ tr_peerMgrStartTorrent( tr_peerMgr * manager,
refillSoon( t );
}
managerUnlock( manager );
managerUnlock( t->manager );
}
static void
@ -1604,66 +1563,56 @@ stopTorrent( Torrent * t )
}
void
tr_peerMgrStopTorrent( tr_peerMgr * manager,
const uint8_t * torrentHash )
tr_peerMgrStopTorrent( tr_torrent * tor )
{
managerLock( manager );
Torrent * t = tor->torrentPeers;
stopTorrent( getExistingTorrent( manager, torrentHash ) );
managerLock( t->manager );
managerUnlock( manager );
stopTorrent( t );
managerUnlock( t->manager );
}
void
tr_peerMgrAddTorrent( tr_peerMgr * manager,
tr_torrent * tor )
{
Torrent * t;
managerLock( manager );
assert( tor );
assert( getExistingTorrent( manager, tor->info.hash ) == NULL );
assert( tor->torrentPeers == NULL );
t = torrentConstructor( manager, tor );
tr_ptrArrayInsertSorted( &manager->torrents, t, torrentCompare );
tor->torrentPeers = torrentConstructor( manager, tor );
managerUnlock( manager );
}
void
tr_peerMgrRemoveTorrent( tr_peerMgr * manager,
const uint8_t * torrentHash )
tr_peerMgrRemoveTorrent( tr_torrent * tor )
{
Torrent * t;
tr_torrentLock( tor );
managerLock( manager );
stopTorrent( tor->torrentPeers );
torrentDestructor( tor->torrentPeers );
t = getExistingTorrent( manager, torrentHash );
assert( t );
stopTorrent( t );
tr_ptrArrayRemoveSorted( &manager->torrents, t, torrentCompare );
torrentDestructor( t );
managerUnlock( manager );
tr_torrentUnlock( tor );
}
void
tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
const uint8_t * torrentHash,
int8_t * tab,
tr_peerMgrTorrentAvailability( const tr_torrent * tor,
int8_t * tab,
unsigned int tabCount )
{
tr_piece_index_t i;
const Torrent * t;
const tr_torrent * tor;
float interval;
tr_bool isSeed;
int peerCount;
const tr_peer ** peers;
managerLock( manager );
tr_torrentLock( tor );
t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
t = tor->torrentPeers;
tor = t->tor;
interval = tor->info.pieceCount / (float)tabCount;
isSeed = tor && ( tr_cpGetStatus ( &tor->completion ) == TR_SEED );
@ -1686,29 +1635,27 @@ tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
}
}
managerUnlock( manager );
tr_torrentUnlock( tor );
}
/* Returns the pieces that are available from peers */
tr_bitfield*
tr_peerMgrGetAvailable( const tr_peerMgr * manager,
const uint8_t * torrentHash )
tr_peerMgrGetAvailable( const tr_torrent * tor )
{
int i;
int peerCount;
Torrent * t;
Torrent * t = tor->torrentPeers;
const tr_peer ** peers;
tr_bitfield * pieces;
managerLock( manager );
managerLock( t->manager );
t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
pieces = tr_bitfieldNew( t->tor->info.pieceCount );
peerCount = tr_ptrArraySize( &t->peers );
peers = (const tr_peer**) tr_ptrArrayBase( &t->peers );
for( i=0; i<peerCount; ++i )
tr_bitfieldOr( pieces, peers[i]->have );
managerUnlock( manager );
managerUnlock( t->manager );
return pieces;
}
@ -1728,8 +1675,7 @@ tr_peerMgrHasConnections( const tr_peerMgr * manager,
}
void
tr_peerMgrTorrentStats( const tr_peerMgr * manager,
const uint8_t * torrentHash,
tr_peerMgrTorrentStats( tr_torrent * tor,
int * setmePeersKnown,
int * setmePeersConnected,
int * setmeSeedsConnected,
@ -1739,13 +1685,12 @@ tr_peerMgrTorrentStats( const tr_peerMgr * manager,
int * setmePeersFrom )
{
int i, size;
const Torrent * t;
const Torrent * t = tor->torrentPeers;
const tr_peer ** peers;
const tr_webseed ** webseeds;
managerLock( manager );
managerLock( t->manager );
t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
peers = (const tr_peer **) tr_ptrArrayBase( &t->peers );
size = tr_ptrArraySize( &t->peers );
@ -1787,27 +1732,25 @@ tr_peerMgrTorrentStats( const tr_peerMgr * manager,
if( tr_webseedIsActive( webseeds[i] ) )
++*setmeWebseedsSendingToUs;
managerUnlock( manager );
managerUnlock( t->manager );
}
float*
tr_peerMgrWebSpeeds( const tr_peerMgr * manager,
const uint8_t * torrentHash )
tr_peerMgrWebSpeeds( const tr_torrent * tor )
{
const Torrent * t;
const Torrent * t = tor->torrentPeers;
const tr_webseed ** webseeds;
int i;
int webseedCount;
float * ret;
uint64_t now;
assert( manager );
managerLock( manager );
assert( t->manager );
managerLock( t->manager );
t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
webseeds = (const tr_webseed**) tr_ptrArrayBase( &t->webseeds );
webseedCount = tr_ptrArraySize( &t->webseeds );
assert( webseedCount == t->tor->info.webseedCount );
assert( webseedCount == tor->info.webseedCount );
ret = tr_new0( float, webseedCount );
now = tr_date( );
@ -1815,7 +1758,7 @@ tr_peerMgrWebSpeeds( const tr_peerMgr * manager,
if( !tr_webseedGetSpeed( webseeds[i], now, &ret[i] ) )
ret[i] = -1.0;
managerUnlock( manager );
managerUnlock( t->manager );
return ret;
}
@ -1827,20 +1770,18 @@ tr_peerGetPieceSpeed( const tr_peer * peer, uint64_t now, tr_direction direction
struct tr_peer_stat *
tr_peerMgrPeerStats( const tr_peerMgr * manager,
const uint8_t * torrentHash,
tr_peerMgrPeerStats( const tr_torrent * tor,
int * setmeCount )
{
int i, size;
const Torrent * t;
const Torrent * t = tor->torrentPeers;
const tr_peer ** peers;
tr_peer_stat * ret;
uint64_t now;
assert( manager );
managerLock( manager );
assert( t->manager );
managerLock( t->manager );
t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
size = tr_ptrArraySize( &t->peers );
peers = (const tr_peer**) tr_ptrArrayBase( &t->peers );
ret = tr_new0( tr_peer_stat, size );
@ -1890,7 +1831,7 @@ tr_peerMgrPeerStats( const tr_peerMgr * manager,
*setmeCount = size;
managerUnlock( manager );
managerUnlock( t->manager );
return ret;
}
@ -2370,12 +2311,13 @@ tordbg( t, "nCandidates is %d, MAX_RECONNECTIONS_PER_PULSE is %d, getPeerCount(t
static void
pumpAllPeers( tr_peerMgr * mgr )
{
const int torrentCount = tr_ptrArraySize( &mgr->torrents );
int i, j;
tr_torrent * tor = NULL;
for( i=0; i<torrentCount; ++i )
while(( tor = tr_torrentNext( mgr->session, tor )))
{
Torrent * t = tr_ptrArrayNth( &mgr->torrents, i );
int j;
Torrent * t = tor->torrentPeers;
for( j=0; j<tr_ptrArraySize( &t->peers ); ++j )
{
tr_peer * peer = tr_ptrArrayNth( &t->peers, j );

View file

@ -105,9 +105,8 @@ tr_peerMgr* tr_peerMgrNew( tr_session * );
void tr_peerMgrFree( tr_peerMgr * manager );
tr_bool tr_peerMgrPeerIsSeed( const tr_peerMgr * mgr,
const uint8_t * torrentHash,
const tr_address * addr );
tr_bool tr_peerMgrPeerIsSeed( const tr_torrent * tor,
const tr_address * addr );
void tr_peerMgrAddIncoming( tr_peerMgr * manager,
tr_address * addr,
@ -130,46 +129,37 @@ tr_pex * tr_peerMgrArrayToPex( const void * array,
size_t arrayLen,
size_t * setme_pex_count );
void tr_peerMgrAddPex( tr_peerMgr * manager,
const uint8_t * torrentHash,
void tr_peerMgrAddPex( tr_torrent * tor,
uint8_t from,
const tr_pex * pex );
void tr_peerMgrSetBlame( tr_peerMgr * manager,
const uint8_t * torrentHash,
void tr_peerMgrSetBlame( tr_torrent * tor,
tr_piece_index_t pieceIndex,
int success );
int tr_peerMgrGetPeers( tr_peerMgr * manager,
const uint8_t * torrentHash,
int tr_peerMgrGetPeers( tr_torrent * tor,
tr_pex ** setme_pex,
uint8_t af);
void tr_peerMgrStartTorrent( tr_peerMgr * manager,
const uint8_t * torrentHash );
void tr_peerMgrStartTorrent( tr_torrent * tor );
void tr_peerMgrStopTorrent( tr_peerMgr * manager,
const uint8_t * torrentHash );
void tr_peerMgrStopTorrent( tr_torrent * tor );
void tr_peerMgrAddTorrent( tr_peerMgr * manager,
struct tr_torrent * tor );
void tr_peerMgrRemoveTorrent( tr_peerMgr * manager,
const uint8_t * torrentHash );
void tr_peerMgrRemoveTorrent( tr_torrent * tor );
void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
const uint8_t * torrentHash,
void tr_peerMgrTorrentAvailability( const tr_torrent * tor,
int8_t * tab,
unsigned int tabCount );
struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager,
const uint8_t * torrentHash );
struct tr_bitfield* tr_peerMgrGetAvailable( const tr_torrent * tor );
int tr_peerMgrHasConnections( const tr_peerMgr * manager,
const uint8_t * torrentHash );
void tr_peerMgrTorrentStats( const tr_peerMgr * manager,
const uint8_t * torrentHash,
void tr_peerMgrTorrentStats( tr_torrent * tor,
int * setmePeersKnown,
int * setmePeersConnected,
int * setmeSeedsConnected,
@ -178,12 +168,10 @@ void tr_peerMgrTorrentStats( const tr_peerMgr * manager,
int * setmePeersGettingFromUs,
int * setmePeersFrom ); /* TR_PEER_FROM__MAX */
struct tr_peer_stat* tr_peerMgrPeerStats( const tr_peerMgr * manager,
const uint8_t * torrentHash,
int * setmeCount );
struct tr_peer_stat* tr_peerMgrPeerStats( const tr_torrent * tor,
int * setmeCount );
float* tr_peerMgrWebSpeeds( const tr_peerMgr * manager,
const uint8_t * torrentHash );
float* tr_peerMgrWebSpeeds( const tr_torrent * tor );
double tr_peerGetPieceSpeed( const tr_peer * peer,

View file

@ -1046,7 +1046,7 @@ parseUtPex( tr_peermsgs * msgs, int msglen, struct evbuffer * inbuf )
int loaded = 0;
uint8_t * tmp = tr_new( uint8_t, msglen );
tr_benc val;
const tr_torrent * tor = msgs->torrent;
tr_torrent * tor = msgs->torrent;
const uint8_t * added;
size_t added_len;
@ -1066,8 +1066,7 @@ parseUtPex( tr_peermsgs * msgs, int msglen, struct evbuffer * inbuf )
tr_peerMgrCompactToPex( added, added_len, added_f, added_f_len,
&n );
for( i = 0; i < n; ++i )
tr_peerMgrAddPex( msgs->session->peerMgr, tor->info.hash,
TR_PEER_FROM_PEX, pex + i );
tr_peerMgrAddPex( tor, TR_PEER_FROM_PEX, pex + i );
tr_free( pex );
}
@ -1082,8 +1081,7 @@ parseUtPex( tr_peermsgs * msgs, int msglen, struct evbuffer * inbuf )
tr_peerMgrCompact6ToPex( added, added_len, added_f, added_f_len,
&n );
for( i = 0; i < n; ++i )
tr_peerMgrAddPex( msgs->session->peerMgr, tor->info.hash,
TR_PEER_FROM_PEX, pex + i );
tr_peerMgrAddPex( tor, TR_PEER_FROM_PEX, pex + i );
tr_free( pex );
}
@ -1913,12 +1911,8 @@ sendPex( tr_peermsgs * msgs )
PexDiffs diffs6;
tr_pex * newPex = NULL;
tr_pex * newPex6 = NULL;
const int newCount = tr_peerMgrGetPeers( msgs->session->peerMgr,
msgs->torrent->info.hash,
&newPex, TR_AF_INET );
const int newCount6 = tr_peerMgrGetPeers( msgs->session->peerMgr,
msgs->torrent->info.hash,
&newPex6, TR_AF_INET6 );
const int newCount = tr_peerMgrGetPeers( msgs->torrent, &newPex, TR_AF_INET );
const int newCount6 = tr_peerMgrGetPeers( msgs->torrent, &newPex6, TR_AF_INET6 );
/* build the diffs */
diffs.added = tr_new( tr_pex, newCount );

View file

@ -68,8 +68,7 @@ savePeers( tr_benc * dict,
const tr_torrent * tor )
{
tr_pex * pex = NULL;
int count = tr_peerMgrGetPeers( tor->session->peerMgr,
tor->info.hash, &pex, TR_AF_INET );
int count = tr_peerMgrGetPeers( (tr_torrent*) tor, &pex, TR_AF_INET );
if( count > 0 )
tr_bencDictAddRaw( dict, KEY_PEERS, pex, sizeof( tr_pex ) * count );
@ -77,8 +76,7 @@ savePeers( tr_benc * dict,
tr_free( pex );
pex = NULL;
count = tr_peerMgrGetPeers( tor->session->peerMgr, tor->info.hash, &pex,
TR_AF_INET6 );
count = tr_peerMgrGetPeers( (tr_torrent*) tor, &pex, TR_AF_INET6 );
if( count > 0 )
tr_bencDictAddRaw( dict, KEY_PEERS6, pex, sizeof( tr_pex ) * count );
@ -101,8 +99,7 @@ loadPeers( tr_benc * dict,
{
tr_pex pex;
memcpy( &pex, str + ( i * sizeof( tr_pex ) ), sizeof( tr_pex ) );
tr_peerMgrAddPex( tor->session->peerMgr,
tor->info.hash, TR_PEER_FROM_CACHE, &pex );
tr_peerMgrAddPex( tor, TR_PEER_FROM_CACHE, &pex );
}
tr_tordbg( tor, "Loaded %d IPv4 peers from resume file", count );
ret = TR_FR_PEERS;
@ -116,8 +113,7 @@ loadPeers( tr_benc * dict,
{
tr_pex pex;
memcpy( &pex, str + ( i * sizeof( tr_pex ) ), sizeof( tr_pex ) );
tr_peerMgrAddPex( tor->session->peerMgr,
tor->info.hash, TR_PEER_FROM_CACHE, &pex );
tr_peerMgrAddPex( tor, TR_PEER_FROM_CACHE, &pex );
}
tr_tordbg( tor, "Loaded %d IPv6 peers from resume file", count );
ret = TR_FR_PEERS;

View file

@ -205,8 +205,7 @@ onTrackerResponse( void * tracker UNUSED,
{
if( event->allAreSeeds )
pex[i].flags |= ADDED_F_SEED_FLAG;
tr_peerMgrAddPex( tor->session->peerMgr, tor->info.hash,
TR_PEER_FROM_TRACKER, pex + i );
tr_peerMgrAddPex( tor, TR_PEER_FROM_TRACKER, pex + i );
}
tr_free( pex );
@ -744,8 +743,7 @@ tr_torrentStat( tr_torrent * tor )
&s->seeders,
&s->downloaders );
tr_peerMgrTorrentStats( tor->session->peerMgr,
tor->info.hash,
tr_peerMgrTorrentStats( tor,
&s->peersKnown,
&s->peersConnected,
&usableSeeds,
@ -799,10 +797,7 @@ tr_torrentStat( tr_torrent * tor )
else
{
tr_piece_index_t i;
tr_bitfield * peerPieces = tr_peerMgrGetAvailable(
tor->session->peerMgr,
tor->info.
hash );
tr_bitfield * peerPieces = tr_peerMgrGetAvailable( tor );
s->desiredAvailable = 0;
for( i = 0; i < tor->info.pieceCount; ++i )
if( !tor->info.pieces[i].dnd && tr_bitfieldHas( peerPieces, i ) )
@ -919,8 +914,7 @@ tr_torrentFilesFree( tr_file_stat * files,
float*
tr_torrentWebSpeeds( const tr_torrent * tor )
{
return tor ? tr_peerMgrWebSpeeds( tor->session->peerMgr, tor->info.hash )
: NULL;
return tor ? tr_peerMgrWebSpeeds( tor ) : NULL;
}
tr_peer_stat *
@ -930,8 +924,7 @@ tr_torrentPeers( const tr_torrent * tor,
tr_peer_stat * ret = NULL;
if( tor )
ret = tr_peerMgrPeerStats( tor->session->peerMgr,
tor->info.hash, peerCount );
ret = tr_peerMgrPeerStats( tor, peerCount );
return ret;
}
@ -948,9 +941,7 @@ tr_torrentAvailability( const tr_torrent * tor,
int8_t * tab,
int size )
{
tr_peerMgrTorrentAvailability( tor->session->peerMgr,
tor->info.hash,
tab, size );
tr_peerMgrTorrentAvailability( tor, tab, size );
}
void
@ -1012,7 +1003,7 @@ freeTorrent( tr_torrent * tor )
tr_globalLock( session );
tr_peerMgrRemoveTorrent( session->peerMgr, tor->info.hash );
tr_peerMgrRemoveTorrent( tor );
tr_cpDestruct( &tor->completion );
@ -1065,7 +1056,7 @@ checkAndStartImpl( void * vtor )
tr_torrentSaveResume( tor );
tor->startDate = time( NULL );
tr_trackerStart( tor->tracker );
tr_peerMgrStartTorrent( tor->session->peerMgr, tor->info.hash );
tr_peerMgrStartTorrent( tor );
tr_globalUnlock( tor->session );
}
@ -1154,7 +1145,7 @@ stopTorrent( void * vtor )
tr_torrent * tor = vtor;
tr_verifyRemove( tor );
tr_peerMgrStopTorrent( tor->session->peerMgr, tor->info.hash );
tr_peerMgrStopTorrent( tor );
tr_trackerStop( tor->tracker );
tr_torrentCloseLocalFiles( tor );

View file

@ -24,6 +24,7 @@
struct tr_bandwidth;
struct tr_ratecontrol;
struct tr_torrent_peers;
/**
*** Package-visible ctor API
@ -197,6 +198,8 @@ struct tr_torrent
int uniqueId;
struct tr_bandwidth * bandwidth;
struct tr_torrent_peers * torrentPeers;
};
/* get the index of this piece's first block */