Changeset 224
- Timestamp:
- Apr 8, 2006, 6:33:56 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simple_http_parsing/libtransmission/tracker.c
r223 r224 47 47 char status; 48 48 49 #define TC_ATTEMPT_NOREACH 1 50 #define TC_ATTEMPT_ERROR 2 51 #define TC_ATTEMPT_OK 4 52 char lastAttempt; 53 49 54 tr_resolve_t * resolve; 50 55 int socket; … … 73 78 tc->started = 1; 74 79 80 tc->interval = 300; 75 81 tc->seeders = -1; 76 82 tc->leechers = -1; 77 83 78 84 tc->status = TC_STATUS_IDLE; 85 tc->lastAttempt = TC_ATTEMPT_NOREACH; 79 86 tc->size = 1024; 80 87 tc->buf = malloc( tc->size ); … … 93 100 uint64_t now = tr_date(); 94 101 95 /* In any case, always wait 5 seconds between two requests */ 96 if( now < tc->dateTry + 5000 ) 102 /* Unreachable tracker, try 10 seconds before trying again */ 103 if( tc->lastAttempt == TC_ATTEMPT_NOREACH && 104 now < tc->dateTry + 10000 ) 105 { 106 return 0; 107 } 108 109 /* The tracker rejected us (like 4XX code, unauthorized IP...), 110 don't hammer it - we'll probably get the same answer next time 111 anyway */ 112 if( tc->lastAttempt == TC_ATTEMPT_ERROR && 113 now < tc->dateTry + 1000 * tc->interval ) 97 114 { 98 115 return 0; … … 391 408 /* We don't have a complete HTTP status line */ 392 409 tr_inf( "Tracker: incomplete HTTP status line" ); 410 tc->lastAttempt = TC_ATTEMPT_NOREACH; 393 411 return; 394 412 } … … 399 417 tr_err( "Tracker: invalid HTTP status code: %c%c%c", 400 418 tc->buf[9], tc->buf[10], tc->buf[11] ); 419 tc->lastAttempt = TC_ATTEMPT_ERROR; 401 420 return; 402 421 } … … 417 436 { 418 437 tr_err( "Tracker: could not find end of HTTP headers" ); 438 tc->lastAttempt = TC_ATTEMPT_ERROR; 419 439 return; 420 440 } … … 435 455 if( tc->stopped || 0 < tc->newPort ) 436 456 { 457 tc->lastAttempt = TC_ATTEMPT_OK; 437 458 goto nodict; 438 459 } 439 460 tr_err( "Tracker: no dictionary in answer" ); 440 // printf( "%s\n", body );461 tc->lastAttempt = TC_ATTEMPT_ERROR; 441 462 return; 442 463 } … … 445 466 { 446 467 tr_err( "Tracker: error parsing bencoded data" ); 468 tc->lastAttempt = TC_ATTEMPT_ERROR; 447 469 return; 448 470 } … … 456 478 snprintf( tor->trackerError, sizeof( tor->trackerError ), 457 479 "%s", bePeers->val.s.s ); 480 tc->lastAttempt = TC_ATTEMPT_ERROR; 458 481 goto cleanup; 459 482 } 483 460 484 tor->error &= ~TR_ETRACKER; 485 tc->lastAttempt = TC_ATTEMPT_OK; 461 486 462 487 if( !tc->interval )
Note: See TracChangeset
for help on using the changeset viewer.