From 73b546c8173ea460f7a8401be7023dd3695189bb Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 30 Mar 2009 05:30:28 +0000 Subject: [PATCH] (trunk libT) possible fix for #1894: Crash when download finishes and seed ratio is already met --- libtransmission/peer-mgr.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index b309abe92..250719ac4 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -995,6 +995,13 @@ peerSuggestedPiece( Torrent * t UNUSED, #endif } +static int +checkRatioIdle( void * tor ) +{ + tr_torrentCheckSeedRatio( tor ); + return 0; /* one-shot timer */ +} + static void peerCallbackFunc( void * vpeer, void * vevent, void * vt ) { @@ -1043,7 +1050,11 @@ peerCallbackFunc( void * vpeer, void * vevent, void * vt ) a->piece_data_time = now; } - tr_torrentCheckSeedRatio( tor ); + /* we can't check the stop ratio here because the code calling + * this function requires that the torrent not be stopped. + * so instead, add an idle timer to check the ratio as soon + * as the calling code is done. (ticket #1894) */ + tr_timerNew( tor->session, checkRatioIdle, tor, 1 ); break; }