Changeset 5749
- Timestamp:
- May 5, 2008, 8:11:03 PM (14 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/torrent.c
r5748 r5749 299 299 300 300 assert( tor != NULL ); 301 assert( 0 <= pos && pos < tor->info.trackerCount ); 302 301 assert( ( 0 <= pos ) && ( pos < tor->info.trackerCount ) ); 302 303 /* the tier of the tracker we're promoting */ 303 304 tier = tor->info.trackers[pos].tier; 304 305 305 /* find the index of th e first tracker in that tier */306 /* find the index of that tier's first tracker */ 306 307 for( i=0; i<tor->info.trackerCount; ++i ) 307 308 if( tor->info.trackers[i].tier == tier ) … … 310 311 assert( i < tor->info.trackerCount ); 311 312 312 /* swap them if they're not the same*/313 /* promote the tracker at `pos' to the front of the tier */ 313 314 if( i != pos ) { 314 tr_tracker_info tmp = tor->info.trackers[i];315 const tr_tracker_info tmp = tor->info.trackers[i]; 315 316 tor->info.trackers[i] = tor->info.trackers[pos]; 316 317 tor->info.trackers[pos] = tmp; … … 327 328 }; 328 329 330 /* the tiers will be sorted from lowest to highest, 331 * and trackers are randomized within the tiers */ 329 332 static int 330 333 compareRandomTracker( const void * va, const void * vb ) … … 344 347 int i; 345 348 const int n = info->trackerCount; 346 struct RandomTracker * r; 347 r = tr_new0( struct RandomTracker, n ); 349 struct RandomTracker * r = tr_new0( struct RandomTracker, n ); 348 350 for( i=0; i<n; ++i ) { 349 351 r[i].tracker = info->trackers[i]; -
trunk/libtransmission/tracker.c
r5748 r5749 225 225 static void onReqDone( tr_session * session ); 226 226 227 static void 228 updateAddresses( tr_tracker * t, 229 long response_code, 230 int moveToNextAddress, 231 int * tryAgain ) 232 { 227 static int 228 updateAddresses( tr_tracker * t, int success ) 229 { 230 int retry; 231 233 232 tr_torrent * torrent = tr_torrentFindFromHash( t->session, t->hash ); 234 233 235 236 if( !response_code ) /* tracker didn't respond */ 237 { 238 tr_ninf( t->name, _( "Tracker hasn't responded yet. Retrying..." ) ); 239 moveToNextAddress = TRUE; 240 } 241 else if( response_code == HTTP_OK ) 234 if( success ) 242 235 { 243 236 /* multitracker spec: "if a connection with a tracker is 244 237 successful, it will be moved to the front of the tier." */ 245 238 t->trackerIndex = tr_torrentPromoteTracker( torrent, t->trackerIndex ); 246 } 247 else 248 { 249 moveToNextAddress = TRUE; 250 } 251 252 *tryAgain = moveToNextAddress; 253 if( moveToNextAddress ) 254 { 255 if ( ++t->trackerIndex >= torrent->info.trackerCount ) /* we've tried them all */ 256 { 257 *tryAgain = FALSE; 258 t->trackerIndex = 0; 259 } 260 else 261 { 262 const tr_tracker_info * n = getCurrentAddressFromTorrent( t, torrent ); 263 tr_ninf( t->name, _( "Trying tracker \"%s\"" ), n->announce ); 264 } 265 } 239 retry = FALSE; /* we succeeded; no need to retry */ 240 } 241 else if ( ++t->trackerIndex >= torrent->info.trackerCount ) 242 { 243 t->trackerIndex = 0; 244 retry = FALSE; /* we've tried them all */ 245 } 246 else 247 { 248 const tr_tracker_info * n = getCurrentAddressFromTorrent( t, torrent ); 249 tr_ninf( t->name, _( "Trying tracker \"%s\"" ), n->announce ); 250 retry = TRUE; 251 } 252 253 return retry; 266 254 } 267 255 … … 322 310 void * torrent_hash ) 323 311 { 324 int moveToNextAddress = FALSE;325 int tryAgain;312 int retry; 313 int success = FALSE; 326 314 tr_tracker * t; 327 315 … … 348 336 const char * str; 349 337 338 success = TRUE; 339 350 340 if(( tr_bencDictFindStr( &benc, "failure reason", &str ))) { 351 341 // publishErrorMessageAndStop( t, str ); 352 moveToNextAddress = TRUE;353 342 publishMessage( t, str, TR_TRACKER_ERROR ); 343 success = FALSE; 354 344 } 355 345 … … 398 388 } 399 389 400 updateAddresses( t, responseCode, moveToNextAddress, &tryAgain);390 retry = updateAddresses( t, success ); 401 391 402 392 /** … … 404 394 **/ 405 395 406 if( tryAgain)396 if( retry ) 407 397 responseCode = 300; 408 398 … … 459 449 void * torrent_hash ) 460 450 { 461 int moveToNextAddress = FALSE;462 int tryAgain;451 int success = FALSE; 452 int retry; 463 453 tr_tracker * t; 464 454 … … 505 495 t->scrapeIntervalSec = i; 506 496 497 success = TRUE; 498 507 499 tr_ndbg( t->name, "Scrape successful. Rescraping in %d seconds.", 508 500 t->scrapeIntervalSec ); … … 511 503 } 512 504 } 513 else514 moveToNextAddress = TRUE;515 505 516 506 if( bencLoaded ) … … 518 508 } 519 509 520 updateAddresses( t, responseCode, moveToNextAddress, &tryAgain);510 retry = updateAddresses( t, success ); 521 511 522 512 /** … … 524 514 **/ 525 515 526 if( tryAgain)516 if( retry ) 527 517 responseCode = 300; 528 518
Note: See TracChangeset
for help on using the changeset viewer.