Changeset 8878
- Timestamp:
- Aug 7, 2009, 5:29:37 AM (13 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-mgr.c
r8877 r8878 1026 1026 tr_torrentSetActivityDate( tor, now ); 1027 1027 1028 if( e->wasPieceData ) 1028 if( e->wasPieceData ) { 1029 1029 tor->uploadedCur += e->length; 1030 tr_torrentSetDirty( tor ); 1031 } 1030 1032 1031 1033 /* update the stats */ … … 1065 1067 * to manage the swarms, not the web server and does not fit 1066 1068 * into the jurisdiction of the tracker." */ 1067 if( peer && e->wasPieceData ) 1069 if( peer && e->wasPieceData ) { 1068 1070 tor->downloadedCur += e->length; 1071 tr_torrentSetDirty( tor ); 1072 } 1069 1073 1070 1074 /* update the stats */ … … 1103 1107 1104 1108 tr_cpBlockAdd( &tor->completion, block ); 1109 tr_torrentSetDirty( tor ); 1105 1110 decrementPieceRequests( t, e->pieceIndex ); 1106 1111 -
trunk/libtransmission/resume.c
r8767 r8878 77 77 const tr_torrent * tor ) 78 78 { 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 ); 82 83 if( count > 0 ) 83 84 tr_bencDictAddRaw( dict, KEY_PEERS, pex, sizeof( tr_pex ) * count ); 84 85 85 tr_free( pex ); 86 pex = NULL; 87 86 88 87 count = tr_peerMgrGetPeers( (tr_torrent*) tor, &pex, TR_AF_INET6 ); 89 88 if( count > 0 ) … … 482 481 char * filename; 483 482 484 if( !t or)483 if( !tr_isTorrent( tor ) ) 485 484 return; 485 486 tr_tordbg( tor, "Saving .resume file for \"%s\"", tor->info.name ); 486 487 487 488 tr_bencInitDict( &top, 32 ); /* arbitrary "big enough" number */ -
trunk/libtransmission/torrent.c
r8872 r8878 117 117 118 118 tr_bandwidthSetDesiredSpeed( tor->bandwidth, dir, KiB_sec ); 119 120 tr_torrentSetDirty( tor ); 119 121 } 120 122 … … 135 137 136 138 tr_bandwidthSetLimited( tor->bandwidth, dir, do_use ); 139 140 tr_torrentSetDirty( tor ); 137 141 } 138 142 … … 153 157 tr_bandwidthHonorParentLimits( tor->bandwidth, TR_UP, doUse ); 154 158 tr_bandwidthHonorParentLimits( tor->bandwidth, TR_DOWN, doUse ); 159 160 tr_torrentSetDirty( tor ); 155 161 } 156 162 … … 175 181 tor->ratioLimitMode = mode; 176 182 tor->needsSeedRatioCheck = TRUE; 183 184 tr_torrentSetDirty( tor ); 177 185 } 178 186 … … 193 201 194 202 tor->needsSeedRatioCheck = TRUE; 203 204 tr_torrentSetDirty( tor ); 195 205 } 196 206 … … 742 752 tr_free( tor->downloadDir ); 743 753 tor->downloadDir = tr_strdup( path ); 744 tr_torrentS aveResume( tor );754 tr_torrentSetDirty( tor ); 745 755 } 746 756 } … … 1160 1170 tor->corruptCur = 0; 1161 1171 1172 tr_torrentSetDirty( tor ); 1173 1162 1174 tr_torrentUnlock( tor ); 1163 1175 } … … 1247 1259 tor->error = TR_STAT_OK; 1248 1260 tor->errorString[0] = '\0'; 1261 tor->completeness = tr_cpGetStatus( &tor->completion ); 1262 tor->startDate = tor->anyDate = now; 1249 1263 tr_torrentResetTransferStats( tor ); 1250 tor->completeness = tr_cpGetStatus( &tor->completion );1251 tr_torrentSaveResume( tor );1252 tor->startDate = tor->anyDate = now;1253 1264 tr_trackerStart( tor->tracker ); 1254 1265 tor->dhtAnnounceAt = now + tr_cryptoWeakRandInt( 20 ); … … 1352 1363 1353 1364 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; 1366 1368 if( !tor->isDeleting ) 1367 1369 tr_torrentSaveResume( tor ); 1370 } 1371 } 1372 1373 void 1374 tr_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; 1368 1383 tr_runInEventThread( tor->session, stopTorrent, tor ); 1369 1384 … … 1384 1399 tr_bencDictAddInt( d, "date", time( NULL ) ); 1385 1400 1386 tr_torrentSaveResume( tor );1387 1401 tor->isRunning = 0; 1388 1402 stopTorrent( tor ); … … 1526 1540 } 1527 1541 1528 tr_torrentS aveResume( tor );1542 tr_torrentSetDirty( tor ); 1529 1543 } 1530 1544 … … 1569 1583 tr_torrentInitFilePriority( tor, files[i], priority ); 1570 1584 1571 tr_torrentS aveResume( tor );1585 tr_torrentSetDirty( tor ); 1572 1586 tr_torrentUnlock( tor ); 1573 1587 } … … 1713 1727 tr_torrentLock( tor ); 1714 1728 tr_torrentInitFileDLs( tor, files, fileCount, doDownload ); 1715 tr_torrentS aveResume( tor );1729 tr_torrentSetDirty( tor ); 1716 1730 tr_torrentUnlock( tor ); 1717 1731 } … … 1736 1750 1737 1751 tor->bandwidth->priority = priority; 1752 1753 tr_torrentSetDirty( tor ); 1738 1754 } 1739 1755 … … 2004 2020 tor->activityDate = t; 2005 2021 tor->anyDate = MAX( tor->anyDate, tor->activityDate ); 2022 tr_torrentSetDirty( tor ); 2006 2023 } 2007 2024 -
trunk/libtransmission/torrent.h
r8869 r8878 205 205 tr_bool needsSeedRatioCheck; 206 206 tr_bool startAfterVerify; 207 tr_bool isDirty; 207 208 208 209 uint16_t maxConnectedPeers; … … 326 327 } 327 328 329 /* set a flag indicating that the torrent's .resume file 330 * needs to be saved when the torrent is closed */ 331 static inline void tr_torrentSetDirty( tr_torrent * tor ) 332 { 333 assert( tr_isTorrent( tor ) ); 334 335 tor->isDirty = TRUE; 336 } 337 328 338 #endif -
trunk/libtransmission/tracker.c
r8767 r8878 554 554 t->reannounceAt = now + interval; 555 555 t->manualAnnounceAllowedAt = now + t->announceMinIntervalSec; 556 557 /* #319: save the .resume file after an announce so that, in case558 * of a crash, our stats still match up with the tracker's stats */559 tr_torrentSaveResume( tr_torrentFindFromHash( t->session, t->hash ) );560 556 } 561 557 else if( 300 <= responseCode && responseCode <= 399 ) -
trunk/libtransmission/verify.c
r8864 r8878 24 24 #include "completion.h" 25 25 #include "fdlimit.h" 26 #include "resume.h" /* tr_torrentSaveResume() */27 26 #include "inout.h" 28 27 #include "list.h" … … 220 219 { 221 220 if( changed ) 222 tr_torrentS aveResume( tor );221 tr_torrentSetDirty( tor ); 223 222 fireCheckDone( tor, currentNode.verify_done_cb ); 224 223 }
Note: See TracChangeset
for help on using the changeset viewer.