(libT) add NULL pointer checks to tr_torrentStart(), tr_torrentStop()

This commit is contained in:
Charles Kerr 2008-06-10 19:25:18 +00:00
parent 92a178d75f
commit 13424ed977
2 changed files with 15 additions and 12 deletions

View File

@ -115,13 +115,12 @@ rpcPulse( int socket UNUSED, short action UNUSED, void * vserver )
shttpd_poll( server->ctx, 1 );
/* set a timer for the next pulse */
if( EVBUFFER_LENGTH( server->in ) || EVBUFFER_LENGTH( server->out ) ) {
if( EVBUFFER_LENGTH( server->in ) || EVBUFFER_LENGTH( server->out ) )
interval = BUSY_INTERVAL_MSEC;
} else if( now - server->lastRequestTime < 300 ) {
else if( now - server->lastRequestTime < 300 )
interval = IDLE_INTERVAL_MSEC;
} else {
else
interval = UNUSED_INTERVAL_MSEC;
}
tv = tr_timevalMsec( interval );
evtimer_add( &server->timer, &tv );
}

View File

@ -1037,7 +1037,8 @@ torrentStart( tr_torrent * tor, int reloadProgress )
void
tr_torrentStart( tr_torrent * tor )
{
torrentStart( tor, TRUE );
if( tor )
torrentStart( tor, TRUE );
}
static void
@ -1086,14 +1087,17 @@ stopTorrent( void * vtor )
void
tr_torrentStop( tr_torrent * tor )
{
tr_globalLock( tor->handle );
if( tor )
{
tr_globalLock( tor->handle );
tor->isRunning = 0;
if( !tor->isDeleting )
tr_torrentSaveResume( tor );
tr_runInEventThread( tor->handle, stopTorrent, tor );
tor->isRunning = 0;
if( !tor->isDeleting )
tr_torrentSaveResume( tor );
tr_runInEventThread( tor->handle, stopTorrent, tor );
tr_globalUnlock( tor->handle );
tr_globalUnlock( tor->handle );
}
}
static void
@ -1113,7 +1117,7 @@ closeTorrent( void * vtor )
void
tr_torrentFree( tr_torrent * tor )
{
if( tor != NULL )
if( tor )
{
tr_handle * handle = tor->handle;
tr_globalLock( handle );