Changeset 5029
- Timestamp:
- Feb 13, 2008, 5:18:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0x/libtransmission/tracker.c
r4877 r5029 283 283 284 284 static const char* 285 updateAddresses( tr_tracker * t, const struct evhttp_request * req )285 updateAddresses( tr_tracker * t, const struct evhttp_request * req, int * tryAgain ) 286 286 { 287 287 const char * ret = NULL; … … 337 337 } 338 338 339 *tryAgain = moveToNextAddress; 340 339 341 if( moveToNextAddress ) 340 if ( ++t->addressIndex >= t->addressCount ) 342 { 343 if ( ++t->addressIndex >= t->addressCount ) /* we've tried them all */ 344 { 345 *tryAgain = FALSE; 341 346 t->addressIndex = 0; 347 ret = "Tracker hasn't responded yet. Retrying..."; 348 tr_inf( ret ); 349 } 350 } 351 342 352 343 353 return ret; … … 387 397 { 388 398 const char * warning; 399 int tryAgain; 389 400 int responseCode; 390 401 struct torrent_hash * torrent_hash = (struct torrent_hash*) vhash; … … 474 485 } 475 486 476 if (( warning = updateAddresses( t, req ) )) {487 if (( warning = updateAddresses( t, req, &tryAgain ) )) { 477 488 publishWarning( t, warning ); 478 489 tr_err( warning ); … … 483 494 **/ 484 495 485 responseCode = req ? req->response_code : 503; 496 if( tryAgain ) 497 responseCode = 300; 498 else if( req ) 499 responseCode = req->response_code; 500 else 501 responseCode = 503; 486 502 487 503 if( 200<=responseCode && responseCode<=299 ) … … 544 560 { 545 561 const char * warning; 562 int tryAgain; 546 563 time_t nextScrapeSec = 60; 547 564 struct torrent_hash * torrent_hash = (struct torrent_hash*) vhash; … … 607 624 } 608 625 609 if (( warning = updateAddresses( t, req ) )) { 626 if (( warning = updateAddresses( t, req, &tryAgain ) )) 627 { 610 628 tr_err( warning ); 611 629 publishWarning( t, warning ); 612 630 } 613 631 614 t->scrapeAt = time( NULL ) + t->randOffset + nextScrapeSec; 632 if( tryAgain ) 633 t->scrapeAt = time( NULL ); 634 else 635 t->scrapeAt = time( NULL ) + t->randOffset + nextScrapeSec; 615 636 } 616 637 … … 851 872 dbgmsg( t, "sending '%s' to tracker %s:%d, timeout is %d", req->uri, req->address, req->port, (int)req->timeout ); 852 873 evhttp_connection_set_timeout( evcon, req->timeout ); 874 ++handle->tracker->socketCount; 853 875 if( evhttp_make_request( evcon, req->req, EVHTTP_REQ_GET, req->uri )) 854 publishErrorMessageAndStop( t, "Tracker could not be reached." ); 855 else { 856 ++handle->tracker->socketCount; 876 (*req->req->cb)(req->req, req->req->cb_arg); 877 else 857 878 dbgmsg( t, "incremented socket count to %d", handle->tracker->socketCount ); 858 }859 879 } 860 880
Note: See TracChangeset
for help on using the changeset viewer.