From 99bb470658f82653b7ba0989d1d052b18797452e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 7 Aug 2010 02:17:29 +0000 Subject: [PATCH] (trunk libT) when shutting down, use a shorter timeout interval for tracker announces --- libtransmission/web.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libtransmission/web.c b/libtransmission/web.c index 2888c9a72..8935e8b49 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -133,11 +133,18 @@ getCurlProxyType( tr_proxy_type t ) } static long -getTimeoutFromURL( const char * url ) +getTimeoutFromURL( const struct tr_web_task * task ) { - if( strstr( url, "scrape" ) != NULL ) return 30L; - if( strstr( url, "announce" ) != NULL ) return 90L; - return 240L; + long timeout; + const tr_session * session = task->session; + + if( !session || session->isClosed ) timeout = 20L; + else if( strstr( task->url, "scrape" ) != NULL ) timeout = 30L; + else if( strstr( task->url, "announce" ) != NULL ) timeout = 90L; + else timeout = 240L; + + fprintf( stderr, "timeout for [%s] is %ld\n", task->url, timeout ); + return timeout; } static CURL * @@ -174,7 +181,7 @@ createEasy( tr_session * s, struct tr_web_task * task ) #endif curl_easy_setopt( e, CURLOPT_SSL_VERIFYHOST, 0L ); curl_easy_setopt( e, CURLOPT_SSL_VERIFYPEER, 0L ); - curl_easy_setopt( e, CURLOPT_TIMEOUT, getTimeoutFromURL( task->url ) ); + curl_easy_setopt( e, CURLOPT_TIMEOUT, getTimeoutFromURL( task ) ); curl_easy_setopt( e, CURLOPT_URL, task->url ); curl_easy_setopt( e, CURLOPT_USERAGENT, TR_NAME "/" SHORT_VERSION_STRING ); curl_easy_setopt( e, CURLOPT_VERBOSE, verbose ); @@ -310,6 +317,7 @@ tr_webThreadFunc( void * vsession ) tr_lockLock( web->taskLock ); while(( task = tr_list_pop_front( &web->tasks ))) { + dbgmsg( "adding task to curl: [%s]\n", task->url ); curl_multi_add_handle( multi, createEasy( session, task )); /*fprintf( stderr, "adding a task.. taskCount is now %d\n", taskCount );*/ ++taskCount; -- 2.40.0