mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
#426 0.91rc1: if pex is disabled on a stopped torrent, pressing "resume" causes pex to be re-enabled. (reported by pea)
This commit is contained in:
parent
17eec5bd6c
commit
caa4170271
4 changed files with 34 additions and 7 deletions
|
@ -522,8 +522,33 @@ fastResumeLoadOld( tr_torrent * tor,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
internalIdToPublicBitfield( uint8_t id )
|
||||
{
|
||||
uint64_t ret = 0;
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case FR_ID_PROGRESS_SLOTS: ret = 0; break;
|
||||
case FR_ID_DOWNLOADED: ret = TR_FR_DOWNLOADED; break;
|
||||
case FR_ID_UPLOADED: ret = TR_FR_UPLOADED; break;
|
||||
case FR_ID_PEERS_OLD: ret = TR_FR_PEERS; break;
|
||||
case FR_ID_PROGRESS: ret = TR_FR_PROGRESS; break;
|
||||
case FR_ID_PRIORITY: ret = TR_FR_PRIORITY; break;
|
||||
case FR_ID_SPEED: ret = TR_FR_SPEEDLIMIT; break;
|
||||
case FR_ID_RUN: ret = TR_FR_RUN; break;
|
||||
case FR_ID_CORRUPT: ret = TR_FR_CORRUPT; break;
|
||||
case FR_ID_PEERS: ret = TR_FR_PEERS; break;
|
||||
case FR_ID_DESTINATION: ret = TR_FR_DESTINATION; break;
|
||||
case FR_ID_PEX: ret = TR_FR_PEX; break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
fastResumeLoadImpl ( tr_torrent * tor,
|
||||
uint64_t fieldsToLoad,
|
||||
tr_bitfield * uncheckedPieces,
|
||||
const char * destination,
|
||||
int argIsFallback )
|
||||
|
@ -574,7 +599,7 @@ fastResumeLoadImpl ( tr_torrent * tor,
|
|||
/* read each block of data */
|
||||
while( 1 == fread( &id, 1, 1, file ) && 1 == fread( &len, 4, 1, file ) )
|
||||
{
|
||||
switch( id )
|
||||
if( fieldsToLoad & internalIdToPublicBitfield( id ) ) switch( id )
|
||||
{
|
||||
case FR_ID_PROGRESS:
|
||||
/* read progress data */
|
||||
|
@ -773,11 +798,12 @@ fastResumeLoadImpl ( tr_torrent * tor,
|
|||
|
||||
uint64_t
|
||||
tr_fastResumeLoad( tr_torrent * tor,
|
||||
uint64_t fieldsToLoad,
|
||||
tr_bitfield * uncheckedPieces,
|
||||
const char * destination,
|
||||
int argIsFallback )
|
||||
{
|
||||
const uint64_t ret = fastResumeLoadImpl( tor, uncheckedPieces, destination, argIsFallback );
|
||||
const uint64_t ret = fastResumeLoadImpl( tor, fieldsToLoad, uncheckedPieces, destination, argIsFallback );
|
||||
|
||||
if( ! ( ret & TR_FR_PROGRESS ) )
|
||||
tr_bitfieldAddRange( uncheckedPieces, 0, tor->info.pieceCount );
|
||||
|
|
|
@ -45,6 +45,7 @@ enum
|
|||
* Returns a bitwise-or'ed set of the data loaded from fastresume
|
||||
*/
|
||||
uint64_t tr_fastResumeLoad( tr_torrent * tor,
|
||||
uint64_t fieldsToLoad,
|
||||
struct tr_bitfield * uncheckedPieces,
|
||||
const char * destination,
|
||||
int destinationIsFallback );
|
||||
|
|
|
@ -1363,15 +1363,14 @@ tr_peerMgrPeerStats( const tr_peerMgr * manager,
|
|||
{
|
||||
int i, size;
|
||||
const Torrent * t;
|
||||
const tr_peer ** peers;
|
||||
tr_peer ** peers;
|
||||
tr_peer_stat * ret;
|
||||
|
||||
assert( manager != NULL );
|
||||
managerLock( (tr_peerMgr*)manager );
|
||||
|
||||
t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
|
||||
peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &size );
|
||||
|
||||
peers = getConnectedPeers( (Torrent*)t, &size );
|
||||
ret = tr_new0( tr_peer_stat, size );
|
||||
|
||||
for( i=0; i<size; ++i )
|
||||
|
@ -1393,6 +1392,7 @@ tr_peerMgrPeerStats( const tr_peerMgr * manager,
|
|||
}
|
||||
|
||||
*setmeCount = size;
|
||||
tr_free( peers );
|
||||
|
||||
managerUnlock( (tr_peerMgr*)manager );
|
||||
return ret;
|
||||
|
|
|
@ -338,7 +338,7 @@ torrentRealInit( tr_handle * h,
|
|||
|
||||
uncheckedPieces = tr_bitfieldNew( tor->info.pieceCount );
|
||||
|
||||
loaded = tr_fastResumeLoad( tor, uncheckedPieces, destination, destinationIsFallback );
|
||||
loaded = tr_fastResumeLoad( tor, ~0, uncheckedPieces, destination, destinationIsFallback );
|
||||
assert( tor->destination != NULL );
|
||||
|
||||
/* the `paused' flag has highest precedence...
|
||||
|
@ -1030,7 +1030,7 @@ tr_torrentStart( tr_torrent * tor )
|
|||
{
|
||||
if( !tor->uncheckedPieces )
|
||||
tor->uncheckedPieces = tr_bitfieldNew( tor->info.pieceCount );
|
||||
tr_fastResumeLoad( tor, tor->uncheckedPieces, tor->destination, FALSE );
|
||||
tr_fastResumeLoad( tor, TR_FR_PROGRESS, tor->uncheckedPieces, tor->destination, FALSE );
|
||||
tor->isRunning = 1;
|
||||
tr_ioRecheckAdd( tor, checkAndStartCB );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue