From: Jordan Lee Date: Mon, 21 Feb 2011 01:13:28 +0000 (+0000) Subject: (trunk libT) web.c: free the unprocessed tasks before exiting the libcurl thread. X-Git-Tag: 2.30b1~253 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ccdb1a797f5bd9f6294cac86fb2320d4a7c504b;p=transmission (trunk libT) web.c: free the unprocessed tasks before exiting the libcurl thread. This is rare but can happen during shutdown if there are unresponsive trackers. Cleaning up the tasks improves the S/N ratio in valgrind a bit. --- diff --git a/libtransmission/web.c b/libtransmission/web.c index 2515c02a3..14e9ac3cb 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -292,10 +292,10 @@ tr_select( int nfds, static void tr_webThreadFunc( void * vsession ) { - int unused; CURLM * multi; struct tr_web * web; int taskCount = 0; + struct tr_web_task * task; tr_session * session = vsession; /* try to enable ssl for https support; but if that fails, @@ -313,9 +313,9 @@ tr_webThreadFunc( void * vsession ) for( ;; ) { long msec; + int unused; CURLMsg * msg; CURLMcode mcode; - struct tr_web_task * task; if( web->close_mode == TR_WEB_CLOSE_NOW ) break; @@ -390,6 +390,13 @@ tr_webThreadFunc( void * vsession ) } } + /* Discard any remaining tasks. + * This is rare, but can happen on shutdown with unresponsive trackers. */ + while(( task = tr_list_pop_front( &web->tasks ))) { + dbgmsg( "Discarding task \"%s\"", task->url ); + task_free( task ); + } + /* cleanup */ curl_multi_cleanup( multi ); tr_lockFree( web->taskLock );