]> granicus.if.org Git - transmission/commitdiff
fix another crash-on-shutdown in the new web code
authorCharles Kerr <charles@transmissionbt.com>
Mon, 28 Apr 2008 13:29:38 +0000 (13:29 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Mon, 28 Apr 2008 13:29:38 +0000 (13:29 +0000)
libtransmission/session.c
libtransmission/web.c
libtransmission/web.h

index 0b1554406b526355ea63b968b88c9462b7e5a30d..15d4b75ba3b4d50bbd9016db9534c003e35241b9 100644 (file)
@@ -385,18 +385,14 @@ tr_torrentCount( const tr_handle * h )
 }
 
 static void
-tr_closeImpl( void * vh )
+tr_closeAllConnections( void * vh )
 {
     tr_handle * h = vh;
     tr_torrent * t;
 
-    tr_webClose( h->web );
     tr_sharedShuttingDown( h->shared );
     tr_trackerShuttingDown( h );
 
-    _tr_blocklistFree( h->blocklist );
-    h->blocklist = NULL;
-
     for( t=h->torrentList; t!=NULL; ) {
         tr_torrent * tmp = t;
         t = t->next;
@@ -428,10 +424,14 @@ tr_close( tr_handle * h )
 
     tr_statsClose( h );
 
-    tr_runInEventThread( h, tr_closeImpl, h );
+    tr_runInEventThread( h, tr_closeAllConnections, h );
     while( !h->isClosed && !deadlineReached( deadline ) )
         tr_wait( 100 );
 
+    _tr_blocklistFree( h->blocklist );
+    h->blocklist = NULL;
+    tr_webClose( &h->web );
+
     tr_eventClose( h );
     while( h->events && !deadlineReached( deadline ) )
         tr_wait( 100 );
index 1870657465e617f1bcd9b4804cdabf08c01a1e6f..3406a26fd6d3e675ba65084c9ffcf1c7e72394a0 100644 (file)
@@ -319,12 +319,13 @@ tr_webInit( tr_session * session )
 }
 
 void
-tr_webClose( tr_web * web )
+tr_webClose( tr_web ** web )
 {
     dbgmsg( "deleting web->timer" );
-    evtimer_del( &web->timer );
-    curl_multi_cleanup( web->cm );
-    tr_free( web );
+    evtimer_del( &(*web)->timer );
+    curl_multi_cleanup( (*web)->cm );
+    tr_free( *web );
+    *web = NULL;
 }
 
 /***
index ee58b781c5e2b6fd317e864e24dba11392ffd235..28adc821d5411062e270c3ce0db18f471dac926e 100644 (file)
@@ -18,7 +18,7 @@ typedef struct tr_web tr_web;
 
 tr_web* tr_webInit( tr_handle * session );
 
-void tr_webClose( tr_web * );
+void tr_webClose( tr_web ** );
 
 typedef void (tr_web_done_func)( tr_handle    * session,
                                   long          response_code,