Changeset 10747
- Timestamp:
- Jun 13, 2010, 11:06:50 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-mgr.c
r10746 r10747 3272 3272 struct peer_candidate 3273 3273 { 3274 int from; 3274 3275 int salt; 3276 int priority; 3277 int seedProbability; 3278 int wasRecentlyStarted; 3279 time_t lastConnectionAt; 3280 time_t lastConnectionAttemptAt; 3275 3281 tr_torrent * tor; 3276 3282 struct peer_atom * atom; 3277 tr_priority_t priority; 3278 tr_bool wasRecentlyStarted; 3283 3279 3284 }; 3280 3285 … … 3310 3315 3311 3316 /* prefer peers we've connected to, or never tried, over peers we failed to connect to. */ 3312 af = a-> atom->lastConnectionAt < a->atom->lastConnectionAttemptAt;3313 bf = b-> atom->lastConnectionAt < b->atom->lastConnectionAttemptAt;3317 af = a->lastConnectionAt < a->lastConnectionAttemptAt; 3318 bf = b->lastConnectionAt < b->lastConnectionAttemptAt; 3314 3319 if( af != bf ) 3315 3320 return af ? 1 : -1; 3316 3321 3317 3322 /* prefer the one we attempted least recently (to cycle through all peers) */ 3318 if( a-> atom->lastConnectionAttemptAt != b->atom->lastConnectionAttemptAt )3319 return a-> atom->lastConnectionAttemptAt < b->atom->lastConnectionAttemptAt ? -1 : 1;3323 if( a->lastConnectionAttemptAt != b->lastConnectionAttemptAt ) 3324 return a->lastConnectionAttemptAt < b->lastConnectionAttemptAt ? -1 : 1; 3320 3325 3321 3326 /* prefer peers belonging to a torrent of a higher priority */ … … 3328 3333 3329 3334 /* prefer peers that we might have a chance of uploading to */ 3330 if(( i = compareSeedProbabilities( a-> atom->seedProbability, b->atom->seedProbability )))3335 if(( i = compareSeedProbabilities( a->seedProbability, b->seedProbability ))) 3331 3336 return i; 3332 3337 3333 3338 /* prefer peers that we got from more trusted sources */ 3334 if( a-> atom->from != b->atom->from )3335 return a-> atom->from < b->atom->from ? -1 : 1;3339 if( a->from != b->from ) 3340 return a->from < b->from ? -1 : 1; 3336 3341 3337 3342 /* salt */ … … 3396 3401 walk->tor = tor; 3397 3402 walk->atom = atom; 3403 walk->from = atom->from; 3398 3404 walk->salt = tr_cryptoWeakRandInt( 4096 ); 3399 3405 walk->priority = tr_torrentGetPriority( tor ); 3406 walk->seedProbability = atom->seedProbability; 3400 3407 walk->wasRecentlyStarted = torrentWasRecentlyStarted( tor ); 3408 walk->lastConnectionAt = atom->lastConnectionAt; 3409 walk->lastConnectionAttemptAt = atom->lastConnectionAttemptAt; 3401 3410 ++walk; 3402 3411 }
Note: See TracChangeset
for help on using the changeset viewer.