Changeset 7578
- Timestamp:
- Jan 2, 2009, 5:01:55 PM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/completion.c
r7576 r7578 31 31 #include "utils.h" 32 32 33 struct tr_completion34 {35 tr_bool sizeWhenDoneIsDirty;36 tr_bool haveValidIsDirty;37 38 tr_torrent * tor;39 40 /* do we have this block? */41 tr_bitfield blockBitfield;42 43 /* do we have this piece? */44 tr_bitfield pieceBitfield;45 46 /* a block is complete if and only if we have it */47 uint16_t * completeBlocks;48 49 /* number of bytes we'll have when done downloading. [0..info.totalSize]50 DON'T access this directly; it's a lazy field.51 use tr_cpSizeWhenDone() instead! */52 uint64_t sizeWhenDoneLazy;53 54 /* number of bytes we'll have when done downloading. [0..info.totalSize]55 DON'T access this directly; it's a lazy field.56 use tr_cpHaveValid() instead! */57 uint64_t haveValidLazy;58 59 /* number of bytes we want or have now. [0..sizeWhenDone] */60 uint64_t sizeNow;61 };62 63 33 static void 64 34 tr_cpReset( tr_completion * cp ) … … 74 44 75 45 tr_completion * 76 tr_cpInit( tr_torrent * tor ) 77 { 78 tr_completion * cp = tr_new( tr_completion, 1 ); 79 80 cp->tor = tor; 46 tr_cpConstruct( tr_completion * cp, tr_torrent * tor ) 47 { 48 cp->tor = tor; 81 49 cp->completeBlocks = tr_new( uint16_t, tor->info.pieceCount ); 82 50 tr_bitfieldConstruct( &cp->blockBitfield, tor->blockCount ); … … 86 54 } 87 55 88 void 89 tr_cp Close( tr_completion * cp )56 tr_completion* 57 tr_cpDestruct( tr_completion * cp ) 90 58 { 91 59 tr_free( cp->completeBlocks ); 92 60 tr_bitfieldDestruct( &cp->pieceBitfield ); 93 61 tr_bitfieldDestruct( &cp->blockBitfield ); 94 tr_free ( cp );62 return cp; 95 63 } 96 64 … … 146 114 } 147 115 148 int149 tr_cpPieceIsComplete( const tr_completion * cp,150 tr_piece_index_t piece )151 {152 return cp->completeBlocks[piece] == tr_torPieceCountBlocks( cp->tor, piece );153 }154 155 const tr_bitfield *156 tr_cpPieceBitfield( const tr_completion * cp )157 {158 return &cp->pieceBitfield;159 }160 161 116 void 162 117 tr_cpPieceAdd( tr_completion * cp, … … 198 153 } 199 154 200 int201 tr_cpBlockIsComplete( const tr_completion * cp,202 tr_block_index_t block )203 {204 return tr_bitfieldHas( &cp->blockBitfield, block );205 }206 207 155 void 208 156 tr_cpBlockAdd( tr_completion * cp, … … 229 177 cp->sizeWhenDoneIsDirty = 1; 230 178 } 231 }232 233 const tr_bitfield *234 tr_cpBlockBitfield( const tr_completion * cp )235 {236 assert( cp );237 assert( cp->blockBitfield.bits );238 assert( cp->blockBitfield.bitCount );239 240 return &cp->blockBitfield;241 179 } 242 180 … … 263 201 } 264 202 265 int266 tr_cpMissingBlocksInPiece( const tr_completion * cp,267 tr_piece_index_t piece )268 {269 return tr_torPieceCountBlocks( cp->tor, piece ) - cp->completeBlocks[piece];270 }271 272 203 /*** 273 204 **** 274 205 ***/ 275 276 float277 tr_cpPercentDone( const tr_completion * cp )278 {279 return tr_getRatio( cp->sizeNow, tr_cpSizeWhenDone( cp ) );280 }281 282 float283 tr_cpPercentComplete( const tr_completion * cp )284 {285 return tr_getRatio( cp->sizeNow, cp->tor->info.totalSize );286 }287 288 uint64_t289 tr_cpLeftUntilDone( const tr_completion * cp )290 {291 return tr_cpSizeWhenDone( cp ) - cp->sizeNow;292 }293 294 uint64_t295 tr_cpLeftUntilComplete( const tr_completion * cp )296 {297 return cp->tor->info.totalSize - cp->sizeNow;298 }299 206 300 207 tr_completeness … … 339 246 } 340 247 341 uint64_t342 tr_cpHaveTotal( const tr_completion * cp )343 {344 return cp->sizeNow;345 }346 347 248 void 348 249 tr_cpGetAmountDone( const tr_completion * cp, … … 353 254 const tr_torrent * tor = cp->tor; 354 255 const float interval = tor->info.pieceCount / (float)tabCount; 355 const int isSeed = tr_cpGetStatus ( tor->completion) == TR_SEED;256 const int isSeed = tr_cpGetStatus( cp ) == TR_SEED; 356 257 357 258 for( i = 0; i < tabCount; ++i ) … … 368 269 } 369 270 } 271 272 int 273 tr_cpMissingBlocksInPiece( const tr_completion * cp, tr_piece_index_t piece ) 274 { 275 return tr_torPieceCountBlocks( cp->tor, piece ) - cp->completeBlocks[piece]; 276 } 277 278 279 int 280 tr_cpPieceIsComplete( const tr_completion * cp, tr_piece_index_t piece ) 281 { 282 return cp->completeBlocks[piece] == tr_torPieceCountBlocks( cp->tor, piece ); 283 } -
trunk/libtransmission/completion.h
r7576 r7578 30 30 #endif 31 31 32 #include <assert.h> 33 32 34 #include "transmission.h" 35 #include "utils.h" /* tr_bitfield */ 33 36 34 struct tr_bitfield; 35 typedef struct tr_completion tr_completion; 37 typedef struct tr_completion 38 { 39 tr_bool sizeWhenDoneIsDirty; 40 tr_bool haveValidIsDirty; 36 41 37 tr_completion * tr_cpInit( tr_torrent * );42 tr_torrent * tor; 38 43 39 void tr_cpClose( tr_completion * ); 44 /* do we have this block? */ 45 tr_bitfield blockBitfield; 40 46 41 /* General */ 47 /* do we have this piece? */ 48 tr_bitfield pieceBitfield; 49 50 /* a block is complete if and only if we have it */ 51 uint16_t * completeBlocks; 52 53 /* number of bytes we'll have when done downloading. [0..info.totalSize] 54 DON'T access this directly; it's a lazy field. 55 use tr_cpSizeWhenDone() instead! */ 56 uint64_t sizeWhenDoneLazy; 57 58 /* number of bytes we'll have when done downloading. [0..info.totalSize] 59 DON'T access this directly; it's a lazy field. 60 use tr_cpHaveValid() instead! */ 61 uint64_t haveValidLazy; 62 63 /* number of bytes we want or have now. [0..sizeWhenDone] */ 64 uint64_t sizeNow; 65 } 66 tr_completion; 67 68 /** 69 *** Life Cycle 70 **/ 71 72 tr_completion * tr_cpConstruct( tr_completion *, tr_torrent * ); 73 74 tr_completion * tr_cpDestruct( tr_completion * ); 75 76 static inline tr_completion* tr_cpNew( tr_torrent * tor ) 77 { 78 return tr_cpConstruct( tr_new0( tr_completion, 1 ), tor ); 79 } 80 81 static inline void tr_cpFree( tr_completion * cp ) 82 { 83 tr_free( tr_cpDestruct( cp ) ); 84 } 85 86 /** 87 *** General 88 **/ 42 89 43 90 tr_completeness tr_cpGetStatus( const tr_completion * ); 44 91 45 extern inline uint64_t tr_cpHaveTotal( const tr_completion * );46 47 92 uint64_t tr_cpHaveValid( const tr_completion * ); 48 93 49 extern inline uint64_t tr_cpLeftUntilComplete( const tr_completion * );50 51 extern inline uint64_t tr_cpLeftUntilDone( const tr_completion * );52 53 94 uint64_t tr_cpSizeWhenDone( const tr_completion * ); 54 55 extern inline float tr_cpPercentComplete( const tr_completion * );56 57 extern inline float tr_cpPercentDone( const tr_completion * );58 95 59 96 void tr_cpInvalidateDND( tr_completion * ); … … 63 100 int tabCount ); 64 101 65 /* Pieces */ 66 extern inline int tr_cpPieceIsComplete( const tr_completion * completion, 67 tr_piece_index_t piece ); 102 static inline uint64_t tr_cpHaveTotal( const tr_completion * cp ) 103 { 104 return cp->sizeNow; 105 } 68 106 69 void tr_cpPieceAdd( tr_completion * completion, 70 tr_piece_index_t piece ); 107 static inline uint64_t tr_cpLeftUntilComplete( const tr_completion * cp ) 108 { 109 return tr_torrentInfo(cp->tor)->totalSize - cp->sizeNow; 110 } 71 111 72 void tr_cpPieceRem( tr_completion * completion, 73 tr_piece_index_t piece ); 112 static inline uint64_t tr_cpLeftUntilDone( const tr_completion * cp ) 113 { 114 return tr_cpSizeWhenDone( cp ) - cp->sizeNow; 115 } 74 116 75 /* Blocks */ 76 extern inline int tr_cpBlockIsComplete( const tr_completion * completion, 77 tr_block_index_t block ); 117 static inline float tr_cpPercentComplete( const tr_completion * cp ) 118 { 119 return tr_getRatio( cp->sizeNow, tr_torrentInfo(cp->tor)->totalSize ); 120 } 121 122 static inline float tr_cpPercentDone( const tr_completion * cp ) 123 { 124 return tr_getRatio( cp->sizeNow, tr_cpSizeWhenDone( cp ) ); 125 } 126 127 /** 128 *** Pieces 129 **/ 130 131 int tr_cpMissingBlocksInPiece( const tr_completion * cp, 132 tr_piece_index_t piece ); 133 134 int tr_cpPieceIsComplete( const tr_completion * cp, 135 tr_piece_index_t piece ); 136 137 void tr_cpPieceAdd( tr_completion * completion, 138 tr_piece_index_t piece ); 139 140 void tr_cpPieceRem( tr_completion * completion, 141 tr_piece_index_t piece ); 142 143 /** 144 *** Blocks 145 **/ 146 147 static inline int tr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t block ) { 148 return tr_bitfieldHas( &cp->blockBitfield, block ); 149 } 78 150 79 151 void tr_cpBlockAdd( tr_completion * completion, … … 83 155 struct tr_bitfield * blocks ); 84 156 85 extern inline int tr_cpMissingBlocksInPiece( const tr_completion * completion, 86 tr_piece_index_t piece ); 157 /*** 158 **** 159 ***/ 87 160 161 static inline const struct tr_bitfield * tr_cpPieceBitfield( const tr_completion * cp ) { 162 return &cp->pieceBitfield; 163 } 88 164 89 extern inline const struct tr_bitfield * 90 tr_cpPieceBitfield( const tr_completion* ); 91 92 extern inline const struct tr_bitfield * 93 tr_cpBlockBitfield( const tr_completion * ); 165 static inline const struct tr_bitfield * tr_cpBlockBitfield( const tr_completion * cp ) { 166 assert( cp ); 167 assert( cp->blockBitfield.bits ); 168 assert( cp->blockBitfield.bitCount ); 169 return &cp->blockBitfield; 170 } 94 171 95 172 #endif -
trunk/libtransmission/fastresume.c
r7567 r7578 283 283 bitfield.bitCount = bitfield.byteCount * 8; 284 284 bitfield.bits = (uint8_t*) walk; 285 if( tr_cpBlockBitfieldSet( tor->completion, &bitfield ) )285 if( tr_cpBlockBitfieldSet( &tor->completion, &bitfield ) ) 286 286 ret = TR_FR_PROGRESS; 287 287 else { … … 297 297 for( i = 0; i < tor->info.pieceCount; ++i ) 298 298 if( !tr_torrentIsPieceChecked( tor, i ) ) 299 tr_cpPieceRem( tor->completion, i );299 tr_cpPieceRem( &tor->completion, i ); 300 300 } 301 301 -
trunk/libtransmission/peer-mgr.c
r7566 r7578 629 629 for( i = 0; i < inf->pieceCount; ++i ) 630 630 if( !tor->info.pieces[i].dnd 631 && !tr_cpPieceIsComplete( tor->completion, i ) )631 && !tr_cpPieceIsComplete( &tor->completion, i ) ) 632 632 pool[poolSize++] = i; 633 633 … … 650 650 setme->pendingRequestCount = getPieceRequests( t, piece ); 651 651 setme->missingBlockCount 652 = tr_cpMissingBlocksInPiece( tor->completion, piece );652 = tr_cpMissingBlocksInPiece( &tor->completion, piece ); 653 653 654 654 for( k = 0; k < peerCount; ++k ) … … 712 712 i->blockIndex = 0; 713 713 for( block=b; block!=e; ++block ) 714 if( !tr_cpBlockIsComplete( tor->completion, block ) )714 if( !tr_cpBlockIsComplete( &tor->completion, block ) ) 715 715 i->blocks[i->blockCount++] = block; 716 716 } … … 1082 1082 tr_block_index_t block = _tr_block( tor, e->pieceIndex, e->offset ); 1083 1083 1084 tr_cpBlockAdd( tor->completion, block );1084 tr_cpBlockAdd( &tor->completion, block ); 1085 1085 decrementPieceRequests( t, e->pieceIndex ); 1086 1086 1087 1087 broadcastGotBlock( t, e->pieceIndex, e->offset, e->length ); 1088 1088 1089 if( tr_cpPieceIsComplete( tor->completion, e->pieceIndex ) )1089 if( tr_cpPieceIsComplete( &tor->completion, e->pieceIndex ) ) 1090 1090 { 1091 1091 const tr_piece_index_t p = e->pieceIndex; … … 1664 1664 tor = t->tor; 1665 1665 interval = tor->info.pieceCount / (float)tabCount; 1666 isSeed = tor && ( tr_cpGetStatus ( tor->completion ) == TR_SEED );1666 isSeed = tor && ( tr_cpGetStatus ( &tor->completion ) == TR_SEED ); 1667 1667 peers = (const tr_peer **) TR_PTR_ARRAY_DATA( &t->peers ); 1668 1668 peerCount = TR_PTR_ARRAY_LENGTH( &t->peers ); … … 1674 1674 const int piece = i * interval; 1675 1675 1676 if( isSeed || tr_cpPieceIsComplete( tor->completion, piece ) )1676 if( isSeed || tr_cpPieceIsComplete( &tor->completion, piece ) ) 1677 1677 tab[i] = -1; 1678 1678 else if( peerCount ) { … … 2075 2075 if( atom->flags & ADDED_F_SEED_FLAG ) 2076 2076 peerHasEverything = TRUE; 2077 else if( peer->progress < tr_cpPercentDone( tor->completion ) )2077 else if( peer->progress < tr_cpPercentDone( &tor->completion ) ) 2078 2078 peerHasEverything = FALSE; 2079 2079 else { 2080 tr_bitfield * tmp = tr_bitfieldDup( tr_cpPieceBitfield( tor->completion ) );2080 tr_bitfield * tmp = tr_bitfieldDup( tr_cpPieceBitfield( &tor->completion ) ); 2081 2081 tr_bitfieldDifference( tmp, peer->have ); 2082 2082 peerHasEverything = tr_bitfieldCountTrueBits( tmp ) == 0; -
trunk/libtransmission/peer-msgs.c
r7576 r7578 718 718 719 719 return ( !torrent->info.pieces[piece].dnd ) /* we want it */ 720 && ( !tr_cpPieceIsComplete( torrent->completion, piece ) ) /* !have */720 && ( !tr_cpPieceIsComplete( &torrent->completion, piece ) ) /* !have */ 721 721 && ( tr_bitfieldHas( msgs->peer->have, piece ) ); /* peer has it */ 722 722 } … … 738 738 739 739 torrent = msgs->torrent; 740 bitfield = tr_cpPieceBitfield( torrent->completion );740 bitfield = tr_cpPieceBitfield( &torrent->completion ); 741 741 742 742 if( !msgs->peer->have ) … … 927 927 /* don't ask for it if we've already got it... this block may have 928 928 * come in from a different peer after we cancelled a request for it */ 929 if( !tr_cpBlockIsComplete( msgs->torrent->completion, block ) )929 if( !tr_cpBlockIsComplete( &msgs->torrent->completion, block ) ) 930 930 { 931 931 protocolSendRequest( msgs, &req ); … … 1292 1292 const tr_bool fext = tr_peerIoSupportsFEXT( msgs->peer->io ); 1293 1293 const int reqIsValid = requestIsValid( msgs, req ); 1294 const int clientHasPiece = reqIsValid && tr_cpPieceIsComplete( msgs->torrent->completion, req->index );1294 const int clientHasPiece = reqIsValid && tr_cpPieceIsComplete( &msgs->torrent->completion, req->index ); 1295 1295 const int peerIsChoked = msgs->peer->peerIsChoked; 1296 1296 … … 1641 1641 **/ 1642 1642 1643 if( tr_cpBlockIsComplete( tor->completion, block ) ) {1643 if( tr_cpBlockIsComplete( &tor->completion, block ) ) { 1644 1644 dbgmsg( msgs, "we have this block already..." ); 1645 1645 clientGotUnwantedBlock( msgs, req ); … … 1753 1753 { 1754 1754 if( requestIsValid( msgs, &req ) 1755 && tr_cpPieceIsComplete( msgs->torrent->completion, req.index ) )1755 && tr_cpPieceIsComplete( &msgs->torrent->completion, req.index ) ) 1756 1756 { 1757 1757 int err; … … 1850 1850 size_t lazyCount = 0; 1851 1851 1852 field = tr_bitfieldDup( tr_cpPieceBitfield( msgs->torrent->completion ) );1852 field = tr_bitfieldDup( tr_cpPieceBitfield( &msgs->torrent->completion ) ); 1853 1853 1854 1854 if( tr_sessionIsLazyBitfieldEnabled( msgs->session ) ) … … 1899 1899 const tr_bool fext = tr_peerIoSupportsFEXT( msgs->peer->io ); 1900 1900 1901 if( fext && ( tr_cpGetStatus( msgs->torrent->completion ) == TR_SEED ) )1901 if( fext && ( tr_cpGetStatus( &msgs->torrent->completion ) == TR_SEED ) ) 1902 1902 { 1903 1903 protocolSendHaveAll( msgs ); 1904 1904 } 1905 else if( fext && ( tr_cpHaveValid( msgs->torrent->completion ) == 0 ) )1905 else if( fext && ( tr_cpHaveValid( &msgs->torrent->completion ) == 0 ) ) 1906 1906 { 1907 1907 protocolSendHaveNone( msgs ); -
trunk/libtransmission/resume.c
r7476 r7578 309 309 310 310 /* add the bitfield */ 311 bitfield = tr_cpBlockBitfield( tor->completion );311 bitfield = tr_cpBlockBitfield( &tor->completion ); 312 312 tr_bencDictAddRaw( p, KEY_PROGRESS_BITFIELD, 313 313 bitfield->bits, bitfield->byteCount ); … … 377 377 tmp.bitCount = tmp.byteCount * 8; 378 378 tmp.bits = (uint8_t*) raw; 379 if( !tr_cpBlockBitfieldSet( tor->completion, &tmp ) )379 if( !tr_cpBlockBitfieldSet( &tor->completion, &tmp ) ) 380 380 { 381 381 tr_torrentUncheck( tor ); -
trunk/libtransmission/torrent.c
r7576 r7578 88 88 } 89 89 90 tr_bool91 tr_torrentExists( const tr_session * session, const uint8_t * torrentHash )92 {93 return tr_torrentFindFromHash( (tr_session*)session, torrentHash ) != NULL;94 }95 96 90 tr_torrent* 97 91 tr_torrentFindFromHash( tr_session * session, const uint8_t * torrentHash ) … … 119 113 120 114 return NULL; 121 }122 123 /***124 **** LOCKS125 ***/126 127 void128 tr_torrentLock( const tr_torrent * tor )129 {130 tr_globalLock( tor->session );131 }132 133 void134 tr_torrentUnlock( const tr_torrent * tor )135 {136 tr_globalUnlock( tor->session );137 115 } 138 116 … … 520 498 assert( t == (uint64_t)tor->blockCount ); 521 499 522 t or->completion = tr_cpInit(tor );500 tr_cpConstruct( &tor->completion, tor ); 523 501 524 502 tr_torrentInitFilePieces( tor ); … … 557 535 } 558 536 559 tor->completeness = tr_cpGetStatus( tor->completion );537 tor->completeness = tr_cpGetStatus( &tor->completion ); 560 538 561 539 tor->tracker = tr_trackerNew( tor ); … … 803 781 usableSeeds += tor->info.webseedCount; 804 782 805 s->percentComplete = tr_cpPercentComplete ( tor->completion );806 807 s->percentDone = tr_cpPercentDone(tor->completion );808 s->leftUntilDone = tr_cpLeftUntilDone( tor->completion );809 s->sizeWhenDone = tr_cpSizeWhenDone(tor->completion );783 s->percentComplete = tr_cpPercentComplete ( &tor->completion ); 784 785 s->percentDone = tr_cpPercentDone ( &tor->completion ); 786 s->leftUntilDone = tr_cpLeftUntilDone( &tor->completion ); 787 s->sizeWhenDone = tr_cpSizeWhenDone ( &tor->completion ); 810 788 811 789 s->recheckProgress = s->activity == TR_STATUS_CHECK … … 825 803 s->downloadedEver = tor->downloadedCur + tor->downloadedPrev; 826 804 s->uploadedEver = tor->uploadedCur + tor->uploadedPrev; 827 s->haveValid = tr_cpHaveValid( tor->completion );828 s->haveUnchecked = tr_cpHaveTotal( tor->completion ) - s->haveValid;805 s->haveValid = tr_cpHaveValid( &tor->completion ); 806 s->haveUnchecked = tr_cpHaveTotal( &tor->completion ) - s->haveValid; 829 807 830 808 … … 847 825 for( i = 0; i < tor->info.pieceCount; ++i ) 848 826 if( !tor->info.pieces[i].dnd && tr_bitfieldHas( peerPieces, i ) ) 849 s->desiredAvailable += tr_cpMissingBlocksInPiece( 850 tor->completion, i ); 827 s->desiredAvailable += tr_cpMissingBlocksInPiece( &tor->completion, i ); 851 828 s->desiredAvailable *= tor->blockSize; 852 829 tr_bitfieldFree( peerPieces ); … … 904 881 if( firstBlock == lastBlock ) 905 882 { 906 if( tr_cpBlockIsComplete( tor->completion, firstBlock ) )883 if( tr_cpBlockIsComplete( &tor->completion, firstBlock ) ) 907 884 haveBytes += lastBlockOffset + 1 - firstBlockOffset; 908 885 } … … 911 888 tr_block_index_t i; 912 889 913 if( tr_cpBlockIsComplete( tor->completion, firstBlock ) )890 if( tr_cpBlockIsComplete( &tor->completion, firstBlock ) ) 914 891 haveBytes += tor->blockSize - firstBlockOffset; 915 892 916 893 for( i = firstBlock + 1; i < lastBlock; ++i ) 917 if( tr_cpBlockIsComplete( tor->completion, i ) )894 if( tr_cpBlockIsComplete( &tor->completion, i ) ) 918 895 haveBytes += tor->blockSize; 919 896 920 if( tr_cpBlockIsComplete( tor->completion, lastBlock ) )897 if( tr_cpBlockIsComplete( &tor->completion, lastBlock ) ) 921 898 haveBytes += lastBlockOffset + 1; 922 899 } … … 1001 978 { 1002 979 tr_torrentLock( tor ); 1003 tr_cpGetAmountDone( tor->completion, tab, size );980 tr_cpGetAmountDone( &tor->completion, tab, size ); 1004 981 tr_torrentUnlock( tor ); 1005 982 } … … 1031 1008 1032 1009 if( has ) 1033 tr_cpPieceAdd( tor->completion, pieceIndex );1010 tr_cpPieceAdd( &tor->completion, pieceIndex ); 1034 1011 else 1035 tr_cpPieceRem( tor->completion, pieceIndex );1012 tr_cpPieceRem( &tor->completion, pieceIndex ); 1036 1013 1037 1014 tr_torrentUnlock( tor ); … … 1056 1033 tr_peerMgrRemoveTorrent( session->peerMgr, tor->info.hash ); 1057 1034 1058 tr_cp Close(tor->completion );1035 tr_cpDestruct( &tor->completion ); 1059 1036 1060 1037 tr_rcClose( tor->swarmSpeed ); … … 1103 1080 *tor->errorString = '\0'; 1104 1081 tr_torrentResetTransferStats( tor ); 1105 tor->completeness = tr_cpGetStatus( tor->completion );1082 tor->completeness = tr_cpGetStatus( &tor->completion ); 1106 1083 tr_torrentSaveResume( tor ); 1107 1084 tor->startDate = time( NULL ); … … 1307 1284 tr_torrentLock( tor ); 1308 1285 1309 completeness = tr_cpGetStatus( tor->completion );1286 completeness = tr_cpGetStatus( &tor->completion ); 1310 1287 1311 1288 if( completeness != tor->completeness ) … … 1500 1477 for( i = 0; i < fileCount; ++i ) 1501 1478 setFileDND( tor, files[i], doDownload ); 1502 tr_cpInvalidateDND ( tor->completion );1479 tr_cpInvalidateDND ( &tor->completion ); 1503 1480 1504 1481 tr_torrentUnlock( tor ); -
trunk/libtransmission/torrent.h
r7576 r7578 27 27 #endif 28 28 29 #include "utils.h" /* tr_bitfield */30 31 29 #ifndef TR_TORRENT_H 32 30 #define TR_TORRENT_H 1 31 32 #include "completion.h" /* tr_completion */ 33 #include "session.h" /* tr_globalLock(), tr_globalUnlock() */ 34 #include "utils.h" /* tr_bitfield */ 33 35 34 36 struct tr_bandwidth; … … 64 66 tr_bool has ); 65 67 66 extern inline void67 tr_torrentLock( const tr_torrent * session );68 69 extern inline void70 tr_torrentUnlock( const tr_torrent * session );71 72 68 tr_bool tr_torrentIsSeed( const tr_torrent * session ); 73 69 74 70 void tr_torrentChangeMyPort( tr_torrent * session ); 75 76 extern inline tr_bool77 tr_torrentExists( const tr_session * session,78 const uint8_t * hash );79 71 80 72 tr_torrent* tr_torrentFindFromId( tr_session * session, … … 184 176 uint32_t blockCountInLastPiece; 185 177 186 struct tr_completion *completion;178 struct tr_completion completion; 187 179 188 180 struct tr_bitfield checkedPieces; … … 262 254 } 263 255 256 static inline void 257 tr_torrentLock( const tr_torrent * tor ) 258 { 259 tr_globalLock( tor->session ); 260 } 261 262 static inline void 263 tr_torrentUnlock( const tr_torrent * tor ) 264 { 265 tr_globalUnlock( tor->session ); 266 } 267 268 static inline tr_bool 269 tr_torrentExists( const tr_session * session, const uint8_t * torrentHash ) 270 { 271 return tr_torrentFindFromHash( (tr_session*)session, torrentHash ) != NULL; 272 } 273 274 264 275 #endif -
trunk/libtransmission/tracker.c
r7541 r7578 768 768 torrent->downloadedCur, 769 769 torrent->corruptCur, 770 tr_cpLeftUntilComplete( torrent->completion ),770 tr_cpLeftUntilComplete( &torrent->completion ), 771 771 numwant, 772 772 t->key_param ); … … 794 794 /* BEP 21: In order to tell the tracker that a peer is a partial seed, it MUST send 795 795 * an event=paused parameter in every announce while it is a partial seed. */ 796 if( tr_cpGetStatus( torrent->completion ) == TR_PARTIAL_SEED )796 if( tr_cpGetStatus( &torrent->completion ) == TR_PARTIAL_SEED ) 797 797 reqtype = TR_REQ_PAUSED; 798 798 -
trunk/libtransmission/transmission.h
r7576 r7578 827 827 * tr_info.hashString. 828 828 */ 829 extern inlineint tr_torrentId( const tr_torrent * torrent );829 int tr_torrentId( const tr_torrent * torrent ); 830 830 831 831 /**** -
trunk/libtransmission/verify.c
r7559 r7578 87 87 else if( !tr_torrentIsPieceChecked( tor, i ) ) 88 88 { 89 const int wasComplete = tr_cpPieceIsComplete( tor->completion, i );89 const int wasComplete = tr_cpPieceIsComplete( &tor->completion, i ); 90 90 91 91 if( tr_ioTestPiece( tor, i, buffer, buflen ) ) /* yay */
Note: See TracChangeset
for help on using the changeset viewer.