(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.
This commit is contained in:
Jordan Lee 2011-02-21 01:13:28 +00:00
parent 779f52069a
commit 1ccdb1a797
1 changed files with 9 additions and 2 deletions

View File

@ -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 );