(trunk) #3320: "If the seed ratio is already met when download completes, the Mac callback options do not occur" -- possible fix. needs confirmation from OP or BMW

This commit is contained in:
Charles Kerr 2010-06-25 06:57:34 +00:00
parent 5baab746c6
commit 7e239e932e
5 changed files with 23 additions and 9 deletions

View File

@ -3166,10 +3166,11 @@ bandwidthPulse( int foo UNUSED, short bar UNUSED, void * vmgr )
}
}
/* possibly stop torrents that have an error */
/* stop torrents that are ready to stop, but couldn't be stopped earlier
* during the peer-io callback call chain */
tor = NULL;
while(( tor = tr_torrentNext( mgr->session, tor )))
if( tor->isRunning && ( tor->error == TR_STAT_LOCAL_ERROR ))
if( tor->isStopping )
tr_torrentStop( tor );
reconnectPulse( 0, 0, mgr );

View File

@ -221,9 +221,10 @@ torrentStop( tr_session * session,
for( i = 0; i < torrentCount; ++i )
{
tr_torrent * tor = torrents[i];
if( tor->isRunning )
{
tr_torrentStop( tor );
tor->isStopping = TRUE;
notify( session, TR_RPC_TORRENT_STOPPED, tor );
}
}

View File

@ -322,7 +322,7 @@ tr_torrentCheckSeedRatio( tr_torrent * tor )
{
tr_torinf( tor, "Seed ratio reached; pausing torrent" );
tr_torrentStop( tor );
tor->isStopping = TRUE;
/* maybe notify the client */
if( tor->ratio_limit_hit_func != NULL )
@ -347,6 +347,9 @@ tr_torrentSetLocalError( tr_torrent * tor, const char * fmt, ... )
tor->errorTracker[0] = '\0';
evutil_vsnprintf( tor->errorString, sizeof( tor->errorString ), fmt, ap );
va_end( ap );
if( tor->isRunning )
tor->isStopping = TRUE;
}
static void
@ -1354,7 +1357,6 @@ checkAndStartImpl( void * vtor )
if( tor->preVerifyTotal && !tr_cpHaveTotal( &tor->completion ) )
{
tr_torrentSetLocalError( tor, _( "No data found! Reconnect any disconnected drives, use \"Set Location\", or restart the torrent to re-download." ) );
tr_torrentStop( tor );
}
else
{
@ -1437,7 +1439,6 @@ torrentRecheckDoneImpl( void * vtor )
if( tor->preVerifyTotal && !tr_cpHaveTotal( &tor->completion ) )
{
tr_torrentSetLocalError( tor, _( "Can't find local data. Try \"Set Location\" to find it, or restart the torrent to re-download." ) );
tr_torrentStop( tor );
}
else if( tor->startAfterVerify )
{
@ -1528,6 +1529,7 @@ tr_torrentStop( tr_torrent * tor )
tr_sessionLock( tor->session );
tor->isRunning = 0;
tor->isStopping = 0;
tr_torrentSetDirty( tor );
tr_runInEventThread( tor->session, stopTorrent, tor );
@ -1613,7 +1615,8 @@ getCompletionString( int type )
static void
fireCompletenessChange( tr_torrent * tor,
tr_completeness status )
tr_completeness status,
tr_bool wasPaused )
{
assert( tr_isTorrent( tor ) );
assert( ( status == TR_LEECH )
@ -1621,7 +1624,8 @@ fireCompletenessChange( tr_torrent * tor,
|| ( status == TR_PARTIAL_SEED ) );
if( tor->completeness_func )
tor->completeness_func( tor, status, tor->completeness_func_user_data );
tor->completeness_func( tor, status, wasPaused,
tor->completeness_func_user_data );
}
void
@ -1700,6 +1704,7 @@ torrentCallScript( tr_torrent * tor, const char * script )
void
tr_torrentRecheckCompleteness( tr_torrent * tor )
{
tr_bool wasPaused;
tr_completeness completeness;
assert( tr_isTorrent( tor ) );
@ -1707,6 +1712,7 @@ tr_torrentRecheckCompleteness( tr_torrent * tor )
tr_torrentLock( tor );
completeness = tr_cpGetStatus( &tor->completion );
wasPaused = tor->isRunning;
if( completeness != tor->completeness )
{
@ -1739,7 +1745,7 @@ tr_torrentRecheckCompleteness( tr_torrent * tor )
torrentCallScript( tor, tr_sessionGetTorrentDoneScript( tor->session ) );
}
fireCompletenessChange( tor, completeness );
fireCompletenessChange( tor, wasPaused, completeness );
tr_torrentSetDirty( tor );
}

View File

@ -230,6 +230,7 @@ struct tr_torrent
void * ratio_limit_hit_func_user_data;
tr_bool isRunning;
tr_bool isStopping;
tr_bool isDeleting;
tr_bool startAfterVerify;
tr_bool isDirty;

View File

@ -1274,8 +1274,13 @@ typedef enum
}
tr_completeness;
/**
* @param wasPaused whether or not the torrent was in a paused state when
* it changed its completeness state
*/
typedef void ( tr_torrent_completeness_func )( tr_torrent * torrent,
tr_completeness completeness,
tr_bool wasPaused,
void * user_data );
typedef void ( tr_torrent_ratio_limit_hit_func )( tr_torrent * torrent,