1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00

#1126: crash on quit

This commit is contained in:
Charles Kerr 2008-07-31 13:06:59 +00:00
parent 978b60b8ad
commit 81785b5633
3 changed files with 16 additions and 20 deletions

View file

@ -497,7 +497,6 @@ tr_closeAllConnections( void * vh )
tr_torrent ** torrents;
tr_sharedShuttingDown( h->shared );
tr_trackerShuttingDown( h );
tr_rpcClose( &h->rpcServer );
/* close the torrents. get the most active ones first so that
@ -543,6 +542,7 @@ tr_sessionClose( tr_handle * h )
while( !h->isClosed && !deadlineReached( deadline ) )
tr_wait( 100 );
tr_trackerSessionClose( h );
tr_list_free( &h->blocklists, (TrListForeachFunc)_tr_blocklistFree );
tr_webClose( &h->web );

View file

@ -661,7 +661,6 @@ createScrape( tr_session * session, tr_tracker * tracker )
struct tr_tracker_handle
{
unsigned int isShuttingDown : 1;
int runningCount;
tr_timer * pulseTimer;
};
@ -680,29 +679,15 @@ ensureGlobalsExist( tr_session * session )
}
void
tr_trackerShuttingDown( tr_session * session )
tr_trackerSessionClose( tr_session * session )
{
if( session->tracker )
session->tracker->isShuttingDown = 1;
}
static int
maybeFreeGlobals( tr_session * session )
{
int globalsExist = session->tracker != NULL;
if( globalsExist
&& ( session->tracker->runningCount < 1 )
&& ( session->torrentList== NULL ) )
if( session && session->tracker )
{
dbgmsg( NULL, "freeing tracker timer" );
tr_timerFree( &session->tracker->pulseTimer );
tr_free( session->tracker );
session->tracker = NULL;
globalsExist = FALSE;
}
return globalsExist;
}
/***
@ -803,7 +788,18 @@ trackerPulse( void * vsession )
if( th->runningCount )
dbgmsg( NULL, "tracker pulse after upkeep... %d running", th->runningCount );
return maybeFreeGlobals( session );
/* free the tracker manager if no torrents are left */
if( ( session->tracker )
&& ( session->tracker->runningCount < 1 )
&& ( session->torrentList == NULL ) )
{
tr_trackerSessionClose( session );
}
/* if there are still running torrents (as indicated by
* the existence of the tracker manager) then keep the
* trackerPulse() timer alive */
return session->tracker != NULL;
}
static void

View file

@ -27,7 +27,7 @@ tr_tracker * tr_trackerNew( const tr_torrent * );
void tr_trackerFree ( tr_tracker * );
void tr_trackerShuttingDown( tr_handle * );
void tr_trackerSessionClose( tr_handle * );
/**
*** Tracker Publish / Subscribe