give trackers more time before timing out the requests. make the `stopping' timeout interval smaller than other intervals so that we don't block for too long during shutdown.
This commit is contained in:
parent
e176a25922
commit
7ff8284976
|
@ -45,7 +45,8 @@
|
||||||
#define DEFAULT_ANNOUNCE_INTERVAL_MSEC (MINUTES_TO_MSEC(20))
|
#define DEFAULT_ANNOUNCE_INTERVAL_MSEC (MINUTES_TO_MSEC(20))
|
||||||
|
|
||||||
/* this is how long we'll leave a request hanging before timeout */
|
/* this is how long we'll leave a request hanging before timeout */
|
||||||
#define TIMEOUT_INTERVAL_SEC 5
|
#define TIMEOUT_INTERVAL_SEC 40
|
||||||
|
#define STOPPING_TIMEOUT_INTERVAL_SEC 8
|
||||||
|
|
||||||
/* the value of the 'numwant' argument passed in tracker requests */
|
/* the value of the 'numwant' argument passed in tracker requests */
|
||||||
#define NUMWANT 128
|
#define NUMWANT 128
|
||||||
|
@ -171,7 +172,6 @@ static struct evhttp_connection*
|
||||||
getConnection( Tracker * tracker, const char * address, int port )
|
getConnection( Tracker * tracker, const char * address, int port )
|
||||||
{
|
{
|
||||||
struct evhttp_connection * c = evhttp_connection_new( address, port );
|
struct evhttp_connection * c = evhttp_connection_new( address, port );
|
||||||
evhttp_connection_set_timeout( c, TIMEOUT_INTERVAL_SEC );
|
|
||||||
evhttp_connection_set_closecb( c, connectionClosedCB, tracker->handle );
|
evhttp_connection_set_closecb( c, connectionClosedCB, tracker->handle );
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -708,6 +708,7 @@ onTrackerScrapeNow( void * vt )
|
||||||
tr_inf( "Sending scrape to tracker %s:%d: %s",
|
tr_inf( "Sending scrape to tracker %s:%d: %s",
|
||||||
address->address, address->port, uri );
|
address->address, address->port, uri );
|
||||||
evcon = getConnection( t, address->address, address->port );
|
evcon = getConnection( t, address->address, address->port );
|
||||||
|
evhttp_connection_set_timeout( evcon, TIMEOUT_INTERVAL_SEC );
|
||||||
req = evhttp_request_new( onScrapeResponse, t );
|
req = evhttp_request_new( onScrapeResponse, t );
|
||||||
assert( req );
|
assert( req );
|
||||||
addCommonHeaders( t, req );
|
addCommonHeaders( t, req );
|
||||||
|
@ -994,10 +995,13 @@ sendTrackerRequest( void * vt, const char * eventName )
|
||||||
struct evhttp_request * httpReq;
|
struct evhttp_request * httpReq;
|
||||||
tr_free( t->lastRequest );
|
tr_free( t->lastRequest );
|
||||||
t->lastRequest = tr_strdup( eventName );
|
t->lastRequest = tr_strdup( eventName );
|
||||||
if( eventName && !strcmp( eventName, "stopped" ) )
|
if( !eventName || !strcmp( eventName, "stopped" ) ) {
|
||||||
httpReq = evhttp_request_new( onStoppedResponse, t->tracker->handle );
|
evhttp_connection_set_timeout( evcon, TIMEOUT_INTERVAL_SEC );
|
||||||
else
|
|
||||||
httpReq = evhttp_request_new( onTrackerResponse, onTrackerResponseDataNew(t) );
|
httpReq = evhttp_request_new( onTrackerResponse, onTrackerResponseDataNew(t) );
|
||||||
|
} else {
|
||||||
|
evhttp_connection_set_timeout( evcon, STOPPING_TIMEOUT_INTERVAL_SEC );
|
||||||
|
httpReq = evhttp_request_new( onStoppedResponse, t->tracker->handle );
|
||||||
|
}
|
||||||
addCommonHeaders( t->tracker, httpReq );
|
addCommonHeaders( t->tracker, httpReq );
|
||||||
tr_evhttp_make_request( t->tracker->handle, evcon,
|
tr_evhttp_make_request( t->tracker->handle, evcon,
|
||||||
httpReq, EVHTTP_REQ_GET, uri );
|
httpReq, EVHTTP_REQ_GET, uri );
|
||||||
|
|
Loading…
Reference in New Issue