mirror of
https://github.com/transmission/transmission
synced 2024-12-25 17:17:31 +00:00
when one of the trackers in a multitracker list is successful, bump it to the top of the tier.
This commit is contained in:
parent
c5eed39275
commit
d561187227
3 changed files with 32 additions and 8 deletions
|
@ -291,6 +291,35 @@ tr_torrentInitFilePieces( tr_torrent * tor )
|
|||
tor->info.pieces[pp].priority = calculatePiecePriority( tor, pp, -1 );
|
||||
}
|
||||
|
||||
int
|
||||
tr_torrentPromoteTracker( tr_torrent * tor, int pos )
|
||||
{
|
||||
int i;
|
||||
int tier;
|
||||
|
||||
assert( tor != NULL );
|
||||
assert( 0 <= pos && pos < tor->info.trackerCount );
|
||||
|
||||
tier = tor->info.trackers[pos].tier;
|
||||
|
||||
/* find the index of the first tracker in that tier */
|
||||
for( i=0; i<tor->info.trackerCount; ++i )
|
||||
if( tor->info.trackers[i].tier == tier )
|
||||
break;
|
||||
|
||||
assert( i < tor->info.trackerCount );
|
||||
|
||||
/* swap them if they're not the same */
|
||||
if( i != pos ) {
|
||||
tr_tracker_info tmp = tor->info.trackers[i];
|
||||
tor->info.trackers[i] = tor->info.trackers[pos];
|
||||
tor->info.trackers[pos] = tmp;
|
||||
}
|
||||
|
||||
/* return the new position of the tracker that started out at [pos] */
|
||||
return i;
|
||||
}
|
||||
|
||||
struct RandomTracker
|
||||
{
|
||||
tr_tracker_info tracker;
|
||||
|
|
|
@ -101,6 +101,8 @@ void tr_torrentSetPieceChecked ( tr_torrent *, tr_piece_index_t piece, int i
|
|||
void tr_torrentSetFileChecked ( tr_torrent *, tr_file_index_t file, int isChecked );
|
||||
void tr_torrentUncheck ( tr_torrent * );
|
||||
|
||||
int tr_torrentPromoteTracker ( tr_torrent *, int trackerIndex );
|
||||
|
||||
time_t* tr_torrentGetMTimes ( const tr_torrent *, int * setmeCount );
|
||||
|
||||
typedef enum
|
||||
|
|
|
@ -240,16 +240,9 @@ updateAddresses( tr_tracker * t,
|
|||
}
|
||||
else if( response_code == HTTP_OK )
|
||||
{
|
||||
#if 0
|
||||
/* FIXME */
|
||||
/* multitracker spec: "if a connection with a tracker is
|
||||
successful, it will be moved to the front of the tier." */
|
||||
const int i = t->addressIndex;
|
||||
const int j = t->tierFronts[i];
|
||||
const tr_tracker_info swap = t->addresses[i];
|
||||
t->addresses[i] = t->addresses[j];
|
||||
t->addresses[j] = swap;
|
||||
#endif
|
||||
t->trackerIndex = tr_torrentPromoteTracker( torrent, t->trackerIndex );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue