(trunk libT) #2722 "crash when removing/modifying trackers" -- fixed

This commit is contained in:
Charles Kerr 2010-01-04 09:11:27 +00:00
parent 6f68e30f37
commit 59c10a3dc8
2 changed files with 10 additions and 4 deletions

View File

@ -1697,6 +1697,7 @@ static void
onUpkeepTimer( int foo UNUSED, short bar UNUSED, void * vannouncer )
{
tr_announcer * announcer = vannouncer;
tr_sessionLock( announcer->session );
/* maybe send out some "stopped" messages for closed torrents */
flushCloseMessages( announcer );
@ -1706,6 +1707,8 @@ onUpkeepTimer( int foo UNUSED, short bar UNUSED, void * vannouncer )
/* set up the next timer */
tr_timerAdd( announcer->upkeepTimer, UPKEEP_INTERVAL_SECS, 0 );
tr_sessionUnlock( announcer->session );
}
/***

View File

@ -2089,16 +2089,18 @@ tr_torrentSetAnnounceList( tr_torrent * tor,
{
int i;
tr_benc metainfo;
tr_bool ok = TRUE;
tr_torrentLock( tor );
assert( tr_isTorrent( tor ) );
/* look for bad URLs */
for( i=0; i<trackerCount; ++i )
for( i=0; ok && i<trackerCount; ++i )
if( !tr_httpIsValidURL( trackers[i].announce ) )
return TR_ANNOUNCE_LIST_HAS_BAD;
ok = FALSE;
/* save to the .torrent file */
if( !tr_bencLoadFile( &metainfo, TR_FMT_BENC, tor->info.torrent ) )
if( ok && !tr_bencLoadFile( &metainfo, TR_FMT_BENC, tor->info.torrent ) )
{
tr_info tmpInfo;
@ -2155,7 +2157,8 @@ tr_torrentSetAnnounceList( tr_torrent * tor,
tr_announcerResetTorrent( tor->session->announcer, tor );
}
return TR_ANNOUNCE_LIST_OK;
tr_torrentUnlock( tor );
return ok ? TR_ANNOUNCE_LIST_OK : TR_ANNOUNCE_LIST_HAS_BAD;
}
/**