1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

Fixes a crash and a race condition

This commit is contained in:
Eric Petit 2006-12-18 20:48:46 +00:00
parent 843761f656
commit e0ba0d8f8f

View file

@ -412,10 +412,12 @@ static void torrentReallyStop( tr_torrent_t * tor )
tr_trackerClose( tor->tracker ); tr_trackerClose( tor->tracker );
tor->tracker = NULL; tor->tracker = NULL;
tr_lockLock( &tor->lock );
while( tor->peerCount > 0 ) while( tor->peerCount > 0 )
{ {
tr_peerRem( tor, 0 ); tr_peerRem( tor, 0 );
} }
tr_lockUnlock( &tor->lock );
} }
/*********************************************************************** /***********************************************************************
@ -454,7 +456,7 @@ tr_stat_t * tr_torrentStat( tr_torrent_t * tor )
tr_stat_t * s; tr_stat_t * s;
tr_peer_t * peer; tr_peer_t * peer;
tr_info_t * inf = &tor->info; tr_info_t * inf = &tor->info;
tr_tracker_t * tc = tor->tracker; tr_tracker_t * tc;
int i; int i;
tor->statCur = ( tor->statCur + 1 ) % 2; tor->statCur = ( tor->statCur + 1 ) % 2;
@ -474,6 +476,8 @@ tr_stat_t * tr_torrentStat( tr_torrent_t * tor )
s->error = tor->error; s->error = tor->error;
memcpy( s->trackerError, tor->trackerError, memcpy( s->trackerError, tor->trackerError,
sizeof( s->trackerError ) ); sizeof( s->trackerError ) );
tc = tor->tracker;
s->cannotConnect = tr_trackerCannotConnect( tc ); s->cannotConnect = tr_trackerCannotConnect( tc );
if( tc ) if( tc )