Changeset 8878


Ignore:
Timestamp:
Aug 7, 2009, 5:29:37 AM (13 years ago)
Author:
charles
Message:

(trunk libT) #2137: .resume file gets saved too frequently

Location:
trunk/libtransmission
Files:
6 edited

Legend:

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

    r8877 r8878  
    10261026            tr_torrentSetActivityDate( tor, now );
    10271027
    1028             if( e->wasPieceData )
     1028            if( e->wasPieceData ) {
    10291029                tor->uploadedCur += e->length;
     1030                tr_torrentSetDirty( tor );
     1031            }
    10301032
    10311033            /* update the stats */
     
    10651067             * to manage the swarms, not the web server and does not fit
    10661068             * into the jurisdiction of the tracker." */
    1067             if( peer && e->wasPieceData )
     1069            if( peer && e->wasPieceData ) {
    10681070                tor->downloadedCur += e->length;
     1071                tr_torrentSetDirty( tor );
     1072            }
    10691073
    10701074            /* update the stats */
     
    11031107
    11041108            tr_cpBlockAdd( &tor->completion, block );
     1109            tr_torrentSetDirty( tor );
    11051110            decrementPieceRequests( t, e->pieceIndex );
    11061111
  • trunk/libtransmission/resume.c

    r8767 r8878  
    7777           const tr_torrent * tor )
    7878{
    79     tr_pex * pex = NULL;
    80     int count = tr_peerMgrGetPeers( (tr_torrent*) tor, &pex, TR_AF_INET );
    81 
     79    int count;
     80    tr_pex * pex;
     81
     82    count = tr_peerMgrGetPeers( (tr_torrent*) tor, &pex, TR_AF_INET );
    8283    if( count > 0 )
    8384        tr_bencDictAddRaw( dict, KEY_PEERS, pex, sizeof( tr_pex ) * count );
    84 
    8585    tr_free( pex );
    86     pex = NULL;
    87    
     86
    8887    count = tr_peerMgrGetPeers( (tr_torrent*) tor, &pex, TR_AF_INET6 );
    8988    if( count > 0 )
     
    482481    char *  filename;
    483482
    484     if( !tor )
     483    if( !tr_isTorrent( tor ) )
    485484        return;
     485
     486    tr_tordbg( tor, "Saving .resume file for \"%s\"", tor->info.name );
    486487
    487488    tr_bencInitDict( &top, 32 ); /* arbitrary "big enough" number */
  • trunk/libtransmission/torrent.c

    r8872 r8878  
    117117
    118118    tr_bandwidthSetDesiredSpeed( tor->bandwidth, dir, KiB_sec );
     119
     120    tr_torrentSetDirty( tor );
    119121}
    120122
     
    135137
    136138    tr_bandwidthSetLimited( tor->bandwidth, dir, do_use );
     139
     140    tr_torrentSetDirty( tor );
    137141}
    138142
     
    153157    tr_bandwidthHonorParentLimits( tor->bandwidth, TR_UP, doUse );
    154158    tr_bandwidthHonorParentLimits( tor->bandwidth, TR_DOWN, doUse );
     159
     160    tr_torrentSetDirty( tor );
    155161}
    156162
     
    175181    tor->ratioLimitMode = mode;
    176182    tor->needsSeedRatioCheck = TRUE;
     183
     184    tr_torrentSetDirty( tor );
    177185}
    178186
     
    193201
    194202    tor->needsSeedRatioCheck = TRUE;
     203
     204    tr_torrentSetDirty( tor );
    195205}
    196206
     
    742752        tr_free( tor->downloadDir );
    743753        tor->downloadDir = tr_strdup( path );
    744         tr_torrentSaveResume( tor );
     754        tr_torrentSetDirty( tor );
    745755    }
    746756}
     
    11601170    tor->corruptCur      = 0;
    11611171
     1172    tr_torrentSetDirty( tor );
     1173
    11621174    tr_torrentUnlock( tor );
    11631175}
     
    12471259    tor->error = TR_STAT_OK;
    12481260    tor->errorString[0] = '\0';
     1261    tor->completeness = tr_cpGetStatus( &tor->completion );
     1262    tor->startDate = tor->anyDate = now;
    12491263    tr_torrentResetTransferStats( tor );
    1250     tor->completeness = tr_cpGetStatus( &tor->completion );
    1251     tr_torrentSaveResume( tor );
    1252     tor->startDate = tor->anyDate = now;
    12531264    tr_trackerStart( tor->tracker );
    12541265    tor->dhtAnnounceAt = now + tr_cryptoWeakRandInt( 20 );
     
    13521363
    13531364    tr_fdTorrentClose( tor->uniqueId );
    1354 }
    1355 
    1356 void
    1357 tr_torrentStop( tr_torrent * tor )
    1358 {
    1359     assert( tr_isTorrent( tor ) );
    1360 
    1361     if( tr_isTorrent( tor ) )
    1362     {
    1363         tr_globalLock( tor->session );
    1364 
    1365         tor->isRunning = 0;
     1365
     1366    if( tor->isDirty ) {
     1367        tor->isDirty = 0;
    13661368        if( !tor->isDeleting )
    13671369            tr_torrentSaveResume( tor );
     1370    }
     1371}
     1372
     1373void
     1374tr_torrentStop( tr_torrent * tor )
     1375{
     1376    assert( tr_isTorrent( tor ) );
     1377
     1378    if( tr_isTorrent( tor ) )
     1379    {
     1380        tr_globalLock( tor->session );
     1381
     1382        tor->isRunning = 0;
    13681383        tr_runInEventThread( tor->session, stopTorrent, tor );
    13691384
     
    13841399    tr_bencDictAddInt( d, "date", time( NULL ) );
    13851400
    1386     tr_torrentSaveResume( tor );
    13871401    tor->isRunning = 0;
    13881402    stopTorrent( tor );
     
    15261540        }
    15271541
    1528         tr_torrentSaveResume( tor );
     1542        tr_torrentSetDirty( tor );
    15291543    }
    15301544
     
    15691583        tr_torrentInitFilePriority( tor, files[i], priority );
    15701584
    1571     tr_torrentSaveResume( tor );
     1585    tr_torrentSetDirty( tor );
    15721586    tr_torrentUnlock( tor );
    15731587}
     
    17131727    tr_torrentLock( tor );
    17141728    tr_torrentInitFileDLs( tor, files, fileCount, doDownload );
    1715     tr_torrentSaveResume( tor );
     1729    tr_torrentSetDirty( tor );
    17161730    tr_torrentUnlock( tor );
    17171731}
     
    17361750
    17371751    tor->bandwidth->priority = priority;
     1752
     1753    tr_torrentSetDirty( tor );
    17381754}
    17391755
     
    20042020    tor->activityDate = t;
    20052021    tor->anyDate = MAX( tor->anyDate, tor->activityDate );
     2022    tr_torrentSetDirty( tor );
    20062023}
    20072024
  • trunk/libtransmission/torrent.h

    r8869 r8878  
    205205    tr_bool                    needsSeedRatioCheck;
    206206    tr_bool                    startAfterVerify;
     207    tr_bool                    isDirty;
    207208
    208209    uint16_t                   maxConnectedPeers;
     
    326327}
    327328
     329/* set a flag indicating that the torrent's .resume file
     330 * needs to be saved when the torrent is closed */
     331static inline void tr_torrentSetDirty( tr_torrent * tor )
     332{
     333    assert( tr_isTorrent( tor ) );
     334
     335    tor->isDirty = TRUE;
     336}
     337
    328338#endif
  • trunk/libtransmission/tracker.c

    r8767 r8878  
    554554        t->reannounceAt = now + interval;
    555555        t->manualAnnounceAllowedAt = now + t->announceMinIntervalSec;
    556 
    557         /* #319: save the .resume file after an announce so that, in case
    558          * of a crash, our stats still match up with the tracker's stats */
    559         tr_torrentSaveResume( tr_torrentFindFromHash( t->session, t->hash ) );
    560556    }
    561557    else if( 300 <= responseCode && responseCode <= 399 )
  • trunk/libtransmission/verify.c

    r8864 r8878  
    2424#include "completion.h"
    2525#include "fdlimit.h"
    26 #include "resume.h" /* tr_torrentSaveResume() */
    2726#include "inout.h"
    2827#include "list.h"
     
    220219        {
    221220            if( changed )
    222                 tr_torrentSaveResume( tor );
     221                tr_torrentSetDirty( tor );
    223222            fireCheckDone( tor, currentNode.verify_done_cb );
    224223        }
Note: See TracChangeset for help on using the changeset viewer.