Changeset 12640


Ignore:
Timestamp:
Aug 7, 2011, 7:24:33 PM (10 years ago)
Author:
jordan
Message:

Add a mechanism for enabling/disabling the stalled minutes feature. This is a pre-existing feature in the Mac client.

Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpcimpl.c

    r12611 r12640  
    15601560    if( tr_bencDictFindStr( args_in, TR_PREFS_KEY_DOWNLOAD_DIR, &str ) )
    15611561        tr_sessionSetDownloadDir( session, str );
     1562    if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_QUEUE_STALLED_MINUTES, &i ) )
     1563        tr_sessionSetQueueStalledMinutes( session, i );
     1564    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_QUEUE_STALLED_ENABLED, &boolVal ) )
     1565        tr_sessionSetQueueStalledEnabled( session, boolVal );
     1566    if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_DOWNLOAD_QUEUE_SIZE, &i ) )
     1567        tr_sessionSetQueueSize( session, TR_DOWN, i );
    15621568    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_DOWNLOAD_QUEUE_ENABLED, &boolVal ) )
    15631569        tr_sessionSetQueueEnabled ( session, TR_DOWN, boolVal );
    1564     if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_DOWNLOAD_QUEUE_SIZE, &i ) )
    1565         tr_sessionSetQueueSize( session, TR_DOWN, i );
    15661570    if( tr_bencDictFindStr( args_in, TR_PREFS_KEY_INCOMPLETE_DIR, &str ) )
    15671571        tr_sessionSetIncompleteDir( session, str );
     
    17311735    tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, tr_sessionGetTorrentDoneScript( s ) );
    17321736    tr_bencDictAddBool( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, tr_sessionIsTorrentDoneScriptEnabled( s ) );
     1737    tr_bencDictAddInt ( d, TR_PREFS_KEY_QUEUE_STALLED_MINUTES, tr_sessionGetQueueStalledMinutes( s ) );
     1738    tr_bencDictAddBool( d, TR_PREFS_KEY_QUEUE_STALLED_ENABLED, tr_sessionGetQueueStalledEnabled( s ) );
    17331739    tr_formatter_get_units( tr_bencDictAddDict( d, "units", 0 ) );
    17341740    tr_bencDictAddStr ( d, "version", LONG_VERSION_STRING );
  • trunk/libtransmission/session.c

    r12611 r12640  
    333333    tr_bencDictAddInt ( d, TR_PREFS_KEY_PREALLOCATION,                   TR_PREALLOCATE_SPARSE );
    334334    tr_bencDictAddBool( d, TR_PREFS_KEY_PREFETCH_ENABLED,                DEFAULT_PREFETCH_ENABLED );
     335    tr_bencDictAddBool( d, TR_PREFS_KEY_QUEUE_STALLED_ENABLED,           true );
    335336    tr_bencDictAddInt ( d, TR_PREFS_KEY_QUEUE_STALLED_MINUTES,           30 );
    336337    tr_bencDictAddReal( d, TR_PREFS_KEY_RATIO,                           2.0 );
     
    403404    tr_bencDictAddInt ( d, TR_PREFS_KEY_PREALLOCATION,                    s->preallocationMode );
    404405    tr_bencDictAddInt ( d, TR_PREFS_KEY_PREFETCH_ENABLED,                 s->isPrefetchEnabled );
     406    tr_bencDictAddBool( d, TR_PREFS_KEY_QUEUE_STALLED_ENABLED,            tr_sessionGetQueueStalledEnabled( s ) );
    405407    tr_bencDictAddInt ( d, TR_PREFS_KEY_QUEUE_STALLED_MINUTES,            tr_sessionGetQueueStalledMinutes( s ) );
    406408    tr_bencDictAddReal( d, TR_PREFS_KEY_RATIO,                            s->desiredRatio );
     
    793795    if( tr_bencDictFindInt( settings, TR_PREFS_KEY_QUEUE_STALLED_MINUTES, &i ) )
    794796        tr_sessionSetQueueStalledMinutes( session, i );
     797    if( tr_bencDictFindBool( settings, TR_PREFS_KEY_QUEUE_STALLED_ENABLED, &boolVal ) )
     798        tr_sessionSetQueueStalledEnabled( session, boolVal );
    795799    if( tr_bencDictFindInt( settings, TR_PREFS_KEY_DOWNLOAD_QUEUE_SIZE, &i ) )
    796800        tr_sessionSetQueueSize( session, TR_DOWN, i );
     
    26752679}
    26762680
     2681void
     2682tr_sessionSetQueueStalledEnabled( tr_session * session, bool is_enabled )
     2683{
     2684    assert( tr_isSession( session ) );
     2685    assert( tr_isBool( is_enabled ) );
     2686
     2687    session->stalledEnabled = is_enabled;
     2688}
     2689 
     2690bool
     2691tr_sessionGetQueueStalledEnabled( const tr_session * session )
     2692{
     2693    assert( tr_isSession( session ) );
     2694
     2695    return session->stalledEnabled;
     2696}
     2697
    26772698int
    26782699tr_sessionGetQueueStalledMinutes( const tr_session * session )
  • trunk/libtransmission/session.h

    r12607 r12640  
    112112    tr_benc                      removedTorrents;
    113113
     114    bool                         stalledEnabled;
    114115    bool                         queueEnabled[2];
    115116    int                          queueSize[2];
  • trunk/libtransmission/torrent.c

    r12627 r12640  
    11421142tr_torrentIsStalled( const tr_torrent * tor )
    11431143{
    1144     return torrentGetIdleSecs( tor ) > ( tr_sessionGetQueueStalledMinutes( tor->session ) * 60 );
     1144    return tr_sessionGetQueueStalledEnabled( tor->session )
     1145        && ( torrentGetIdleSecs( tor ) > ( tr_sessionGetQueueStalledMinutes( tor->session ) * 60 ) );
    11451146}
    11461147
  • trunk/libtransmission/transmission.h

    r12617 r12640  
    210210#define TR_PREFS_KEY_SEED_QUEUE_ENABLED                 "seed-queue-enabled"
    211211#define TR_PREFS_KEY_RPC_WHITELIST                      "rpc-whitelist"
     212#define TR_PREFS_KEY_QUEUE_STALLED_ENABLED              "queue-stalled-enabled"
    212213#define TR_PREFS_KEY_QUEUE_STALLED_MINUTES              "queue-stalled-minutes"
    213214#define TR_PREFS_KEY_DSPEED_KBps                        "speed-limit-down"
     
    802803bool tr_sessionGetQueueEnabled  ( const tr_session *, tr_direction );
    803804
     805/**
     806**/
     807
    804808/** @brief Consider torrent as 'stalled' when it's been inactive for N minutes.
    805809    Stalled torrents are left running but are not counted by tr_sessionGetQueueSize(). */
     
    808812/** @return the number of minutes a torrent can be idle before being considered as stalled */
    809813int  tr_sessionGetQueueStalledMinutes( const tr_session * );
     814
     815/** @brief Set whether or not to count torrents idle for over N minutes as 'stalled' */
     816void tr_sessionSetQueueStalledEnabled( tr_session *, bool );
     817
     818/** @return true if we're torrents idle for over N minutes will be flagged as 'stalled' */
     819bool tr_sessionGetQueueStalledEnabled( const tr_session * );
     820
     821/**
     822**/
    810823
    811824/** @brief Set a callback that is invoked when the queue starts a torrent */
Note: See TracChangeset for help on using the changeset viewer.