Changeset 8186


Ignore:
Timestamp:
Apr 9, 2009, 2:10:31 PM (13 years ago)
Author:
charles
Message:

(trunk libT) another possible fix for #1894: Crash when download finishes and seed ratio is already met

Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r8116 r8186  
    996996}
    997997
    998 static int
    999 checkRatioIdle( void * tor )
    1000 {
    1001     tr_torrentCheckSeedRatio( tor );
    1002     return 0; /* one-shot timer */
    1003 }
    1004 
    1005998static void
    1006999peerCallbackFunc( void * vpeer, void * vevent, void * vt )
     
    10511044            }
    10521045
    1053             /* we can't check the stop ratio here because the code calling
    1054              * this function requires that the torrent not be stopped.
    1055              * so instead, add an idle timer to check the ratio as soon
    1056              * as the calling code is done.  (ticket #1894) */
    1057             tr_timerNew( tor->session, checkRatioIdle, tor, 1 );
     1046            tor->needsSeedRatioCheck = TRUE;
    10581047
    10591048            break;
     
    24322421bandwidthPulse( void * vmgr )
    24332422{
     2423    tr_torrent * tor = NULL;
    24342424    tr_peerMgr * mgr = vmgr;
    24352425    managerLock( mgr );
     
    24422432    tr_bandwidthAllocate( mgr->session->bandwidth, TR_DOWN, BANDWIDTH_PERIOD_MSEC );
    24432433
     2434    /* possibly stop torrents that have seeded enough */
     2435    while(( tor = tr_torrentNext( mgr->session, tor ))) {
     2436        if( tor->needsSeedRatioCheck ) {
     2437            tor->needsSeedRatioCheck = FALSE;
     2438            tr_torrentCheckSeedRatio( tor );
     2439        }
     2440    }
     2441
    24442442    managerUnlock( mgr );
    24452443    return TRUE;
  • trunk/libtransmission/session.c

    r8132 r8186  
    866866
    867867    while(( tor = tr_torrentNext( session, tor )))
    868         tr_torrentCheckSeedRatio( tor );
     868        tor->needsSeedRatioCheck = TRUE;
    869869}
    870870
  • trunk/libtransmission/torrent.c

    r8132 r8186  
    173173
    174174    tor->ratioLimitMode = mode;
    175 
    176     tr_torrentCheckSeedRatio( tor );
     175    tor->needsSeedRatioCheck = TRUE;
    177176}
    178177
     
    186185
    187186void
    188 tr_torrentSetRatioLimit( tr_torrent * tor,
    189                          double       desiredRatio )
     187tr_torrentSetRatioLimit( tr_torrent * tor, double desiredRatio )
    190188{
    191189    assert( tr_isTorrent( tor ) );
     
    193191    tor->desiredRatio = desiredRatio;
    194192
    195     tr_torrentCheckSeedRatio( tor );
     193    tor->needsSeedRatioCheck = TRUE;
    196194}
    197195
     
    11931191    tr_globalLock( tor->session );
    11941192
    1195     tor->isRunning = 1;
     1193    tor->isRunning = TRUE;
     1194    tor->needsSeedRatioCheck = TRUE;
    11961195    *tor->errorString = '\0';
    11971196    tr_torrentResetTransferStats( tor );
     
    12011200    tr_trackerStart( tor->tracker );
    12021201    tr_peerMgrStartTorrent( tor );
    1203     tr_torrentCheckSeedRatio( tor );
    12041202
    12051203    tr_globalUnlock( tor->session );
     
    14711469
    14721470        tor->completeness = completeness;
     1471        tor->needsSeedRatioCheck = TRUE;
    14731472        tr_torrentCloseLocalFiles( tor );
    14741473        fireCompletenessChange( tor, completeness );
     
    14821481
    14831482        tr_torrentSaveResume( tor );
    1484         tr_torrentCheckSeedRatio( tor );
    14851483    }
    14861484
     
    16551653        setFileDND( tor, files[i], doDownload );
    16561654    tr_cpInvalidateDND( &tor->completion );
    1657     tr_torrentCheckSeedRatio( tor );
     1655    tor->needsSeedRatioCheck = TRUE;
    16581656
    16591657    tr_torrentUnlock( tor );
  • trunk/libtransmission/torrent.h

    r8123 r8186  
    200200    tr_bool                    isRunning;
    201201    tr_bool                    isDeleting;
     202    tr_bool                    needsSeedRatioCheck;
    202203
    203204    uint16_t                   maxConnectedPeers;
  • trunk/libtransmission/transmission.h

    r8133 r8186  
    170170#define TR_PREFS_KEY_BLOCKLIST_ENABLED          "blocklist-enabled"
    171171#define TR_PREFS_KEY_DOWNLOAD_DIR               "download-dir"
    172 #define TR_PREFS_KEY_DSPEED                     "download-limit"
    173 #define TR_PREFS_KEY_DSPEED_ENABLED             "download-limit-enabled"
    174172#define TR_PREFS_KEY_ENCRYPTION                 "encryption"
    175173#define TR_PREFS_KEY_LAZY_BITFIELD              "lazy-bitfield-enabled"
     
    202200#define TR_PREFS_KEY_RPC_WHITELIST_ENABLED      "rpc-whitelist-enabled"
    203201#define TR_PREFS_KEY_RPC_WHITELIST              "rpc-whitelist"
    204 #define TR_PREFS_KEY_USPEED_ENABLED             "upload-limit-enabled"
    205 #define TR_PREFS_KEY_USPEED                     "upload-limit"
     202#define TR_PREFS_KEY_DSPEED                     "speed-limit-down"
     203#define TR_PREFS_KEY_DSPEED_ENABLED             "speed-limit-down-enabled"
     204#define TR_PREFS_KEY_USPEED_ENABLED             "speed-limit-up-enabled"
     205#define TR_PREFS_KEY_USPEED                     "speed-limit-up"
    206206#define TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT   "upload-slots-per-torrent"
    207207
Note: See TracChangeset for help on using the changeset viewer.