}
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;
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 );
}
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;
}
/***
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,