Changeset 2221


Ignore:
Timestamp:
Jun 28, 2007, 5:43:53 PM (16 years ago)
Author:
charles
Message:
  • (libT) stopped torrents shouldn't use CPU cycles.
  • (gtk) if a torrent is stopped when you exit, keep it stopped when restarting.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr_torrent.c

    r2206 r2221  
    238238}
    239239
     240static tr_stat_t*
     241refreshStat( TrTorrent * tor )
     242{
     243    tor->lastStatTime= time( NULL );
     244    tor->stat = *tr_torrentStat( tor->handle );
     245    return &tor->stat;
     246}
     247
    240248const tr_stat_t *
    241249tr_torrent_stat(TrTorrent *tor)
    242250{
    243     const time_t now = time( NULL );
    244 
    245251    g_assert( TR_IS_TORRENT(tor) );
    246252
    247     if( tor->severed )
    248         return NULL;
    249 
    250     if( tor->lastStatTime != now ) {
    251         tor->lastStatTime = now;
    252         tor->stat = *tr_torrentStat( tor->handle );
    253     }
     253    if( !tor->severed && tor->lastStatTime!=time(NULL) )
     254        refreshStat( tor );
    254255
    255256    return &tor->stat;
     
    401402
    402403  torrent = hash = dir = NULL;
    403   paused = FALSE;
    404404
    405405  for(ii = 0; ii + 1 < state->val.l.count; ii += 2) {
     
    428428
    429429  flags = 0;
    430   if( forcedpause )
     430  if( paused || forcedpause )
    431431      flags |= TR_FLAG_PAUSED;
    432432
     
    494494    tr_bencInitStr( tr_bencDictAdd( state, "dir" ),
    495495                    tr_torrentGetFolder( tor->handle ), -1, 1 );
    496 #if 0
     496
    497497    tr_bencInitInt( tr_bencDictAdd( state, "paused" ),
    498                     tr_torrent_paused( tor ) ? 1 : 0 );
    499 #endif
    500 
     498                    (refreshStat(tor)->status & TR_STATUS_INACTIVE) ? 1 : 0);
    501499    tr_bencInitInt( tr_bencDictAdd( state, "ul-cap-speed" ),
    502500                    tor->ul_cap );
  • trunk/libtransmission/torrent.c

    r2216 r2221  
    2525#include "transmission.h"
    2626#include "shared.h"
    27 #define INTERVAL_MSEC 100
    2827
    2928/***
     
    824823    tr_peer_t * otherPeer;
    825824
     825    assert( tor != NULL );
     826    assert( peer != NULL );
     827
    826828    if( tor->peerCount >= TR_MAX_PEER_COUNT )
    827829    {
     
    952954
    953955        /* sleep a little while */
    954         tr_wait( INTERVAL_MSEC );
     956        tr_wait( tor->runStatus == TR_RUN_STOPPED ? 1000 : 100 );
    955957
    956958        /* if we're stopping... */
Note: See TracChangeset for help on using the changeset viewer.