Ticket #1447: tracker.patch
File tracker.patch, 4.5 KB (added by charles, 12 years ago) |
---|
-
libtransmission/fdlimit.c
38 38 39 39 #include <sys/types.h> 40 40 #include <sys/stat.h> 41 #ifdef HAVE_GETRLIMIT42 #include <sys/time.h> /* getrlimit */43 #include <sys/resource.h> /* getrlimit */44 #endif45 41 #include <unistd.h> 46 42 #include <fcntl.h> /* O_LARGEFILE */ 47 43 … … tr_fdInit( int globalPeerLimit ) 504 500 assert( gFd == NULL ); 505 501 gFd = tr_new0( struct tr_fd_s, 1 ); 506 502 gFd->lock = tr_lockNew( ); 507 508 #ifdef HAVE_GETRLIMIT509 {510 struct rlimit rlim;511 getrlimit( RLIMIT_NOFILE, &rlim );512 rlim.rlim_cur = MIN( rlim.rlim_max,513 (rlim_t)( globalPeerLimit + NOFILE_BUFFER ) );514 setrlimit( RLIMIT_NOFILE, &rlim );515 gFd->socketMax = rlim.rlim_cur - NOFILE_BUFFER;516 tr_dbg( "setrlimit( RLIMIT_NOFILE, %d )", (int)rlim.rlim_cur );517 }518 #else519 503 gFd->socketMax = globalPeerLimit; 520 #endif521 504 tr_dbg( "%d usable file descriptors", globalPeerLimit ); 522 505 523 506 for( i = 0; i < TR_MAX_OPEN_FILES; ++i ) -
libtransmission/tracker.c
updateAddresses( tr_tracker * t, 257 257 { 258 258 /* multitracker spec: "if a connection with a tracker is 259 259 successful, it will be moved to the front of the tier." */ 260 t->trackerIndex = tr_torrentPromoteTracker( torrent, 261 t->trackerIndex ); 260 t->trackerIndex = tr_torrentPromoteTracker( torrent, t->trackerIndex ); 262 261 retry = FALSE; /* we succeeded; no need to retry */ 263 262 } 264 263 else if( ++t->trackerIndex >= torrent->info.trackerCount ) … … updateAddresses( tr_tracker * t, 268 267 } 269 268 else 270 269 { 271 const tr_tracker_info * n = getCurrentAddressFromTorrent( t, 272 torrent ); 270 const tr_tracker_info * n = getCurrentAddressFromTorrent( t, torrent ); 273 271 tr_ninf( t->name, _( "Trying tracker \"%s\"" ), n->announce ); 274 272 retry = TRUE; 275 273 } … … onTrackerResponse( tr_session * session, 444 442 if( bencLoaded ) 445 443 tr_bencFree( &benc ); 446 444 } 447 else 445 else if( responseCode ) 448 446 { 449 447 /* %1$ld - http status code, such as 404 450 448 * %2$s - human-readable explanation of the http status code */ … … onTrackerResponse( tr_session * session, 457 455 458 456 retry = updateAddresses( t, success ); 459 457 460 /** 461 *** 462 **/ 463 464 if( retry ) 458 if( responseCode && retry ) 465 459 responseCode = 300; 466 460 467 if( 200 <= responseCode && responseCode <= 299 ) 461 if( responseCode == 0 ) 462 { 463 dbgmsg( t->name, "No response from tracker... retrying in two minutes." ); 464 t->manualAnnounceAllowedAt = ~(time_t)0; 465 t->reannounceAt = time( NULL ) + t->randOffset + 120; 466 } 467 else if( 200 <= responseCode && responseCode <= 299 ) 468 468 { 469 469 const int interval = t->announceIntervalSec + t->randOffset; 470 470 const time_t now = time ( NULL ); 471 dbgmsg( t->name, "request succeeded. reannouncing in %d seconds", 472 interval ); 471 dbgmsg( t->name, "request succeeded. reannouncing in %d seconds", interval ); 473 472 474 473 /* if the announce response was a superset of the scrape response, 475 474 treat this as both a successful announce AND scrape. */ … … onTrackerResponse( tr_session * session, 499 498 const int interval = 5; 500 499 dbgmsg( t->name, "got a redirect. retrying in %d seconds", interval ); 501 500 t->reannounceAt = time( NULL ) + interval; 502 t->manualAnnounceAllowedAt = time( NULL ) + 503 t->announceMinIntervalSec; 501 t->manualAnnounceAllowedAt = time( NULL ) + t->announceMinIntervalSec; 504 502 } 505 503 else if( 400 <= responseCode && responseCode <= 499 ) 506 504 { … … onTrackerResponse( tr_session * session, 524 522 else 525 523 { 526 524 /* WTF did we get?? */ 527 dbgmsg( 528 t->name, 529 "Invalid response from tracker... retrying in two minutes." ); 525 dbgmsg( t->name, "Invalid response from tracker... retrying in two minutes." ); 530 526 t->manualAnnounceAllowedAt = ~(time_t)0; 531 527 t->reannounceAt = time( NULL ) + t->randOffset + 120; 532 528 }