From: Charles Kerr Date: Mon, 28 Apr 2008 13:29:38 +0000 (+0000) Subject: fix another crash-on-shutdown in the new web code X-Git-Tag: 1.20~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1dfc98fc77195ff8d7732875bce7a45fbe43e2ef;p=transmission fix another crash-on-shutdown in the new web code --- diff --git a/libtransmission/session.c b/libtransmission/session.c index 0b1554406..15d4b75ba 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -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 ); diff --git a/libtransmission/web.c b/libtransmission/web.c index 187065746..3406a26fd 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -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; } /*** diff --git a/libtransmission/web.h b/libtransmission/web.h index ee58b781c..28adc821d 100644 --- a/libtransmission/web.h +++ b/libtransmission/web.h @@ -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,