1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

don't cache the connection; these are one-shot requests

This commit is contained in:
Charles Kerr 2007-08-17 05:00:59 +00:00
parent d5cfbf9426
commit 8713d3468c

View file

@ -126,7 +126,6 @@ typedef struct tr_tracker_s
tr_timer_tag scrapeTag; tr_timer_tag scrapeTag;
tr_timer_tag reannounceTag; tr_timer_tag reannounceTag;
struct evhttp_connection * httpConn;
struct evhttp_request * httpReq; struct evhttp_request * httpReq;
tr_torrent_t * torrent; tr_torrent_t * torrent;
@ -862,7 +861,6 @@ onTrackerResponse( struct evhttp_request * req, void * vtor )
publishErrorMessage( tor, buf ); publishErrorMessage( tor, buf );
} }
tor->httpConn = NULL;
tor->httpReq = NULL; tor->httpReq = NULL;
if( isStopped ) if( isStopped )
@ -883,6 +881,7 @@ sendTrackerRequest( void * vtor, const char * eventName )
Torrent * tor = (Torrent *) vtor; Torrent * tor = (Torrent *) vtor;
const tr_tracker_info_t * address = getCurrentAddress( tor->tracker ); const tr_tracker_info_t * address = getCurrentAddress( tor->tracker );
char * uri = buildTrackerRequestURI( tor, eventName ); char * uri = buildTrackerRequestURI( tor, eventName );
struct evhttp_connection * evcon = NULL;
tr_inf( "tracker request to %s:%d: %s", address->address, tr_inf( "tracker request to %s:%d: %s", address->address,
address->port, uri ); address->port, uri );
@ -890,19 +889,16 @@ sendTrackerRequest( void * vtor, const char * eventName )
/* kill any pending requests */ /* kill any pending requests */
tr_timerFree( &tor->reannounceTag ); tr_timerFree( &tor->reannounceTag );
/* make a connection if we don't have one */ evcon = evhttp_connection_new( address->address, address->port );
if( tor->httpConn == NULL ) if ( !evcon )
tor->httpConn = evhttp_connection_new( address->address,
address->port );
if ( tor->httpConn == NULL )
tr_err( "Can't make a connection to %s:%d", address->address, address->port ); tr_err( "Can't make a connection to %s:%d", address->address, address->port );
else { else {
tr_free( tor->lastRequest ); tr_free( tor->lastRequest );
tor->lastRequest = tr_strdup( eventName ); tor->lastRequest = tr_strdup( eventName );
evhttp_connection_set_timeout( tor->httpConn, REQ_TIMEOUT_INTERVAL_SEC ); evhttp_connection_set_timeout( evcon, REQ_TIMEOUT_INTERVAL_SEC );
tor->httpReq = evhttp_request_new( onTrackerResponse, tor ); tor->httpReq = evhttp_request_new( onTrackerResponse, tor );
addCommonHeaders( tor->tracker, tor->httpReq ); addCommonHeaders( tor->tracker, tor->httpReq );
evhttp_make_request( tor->httpConn, tor->httpReq, EVHTTP_REQ_GET, uri ); evhttp_make_request( evcon, tor->httpReq, EVHTTP_REQ_GET, uri );
} }
tr_free( uri ); tr_free( uri );