]> granicus.if.org Git - transmission/commitdiff
(trunk libT) web.c: free the unprocessed tasks before exiting the libcurl thread.
authorJordan Lee <jordan@transmissionbt.com>
Mon, 21 Feb 2011 01:13:28 +0000 (01:13 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Mon, 21 Feb 2011 01:13:28 +0000 (01:13 +0000)
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.

libtransmission/web.c

index 2515c02a3df6d2521a70d8a9a12d55f8d44f5818..14e9ac3cb39acb34f5de7ceabb9a19a4c3e7c901 100644 (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 );