Changeset 7578 for trunk/libtransmission/torrent.c
- Timestamp:
- Jan 2, 2009, 5:01:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 );
Note: See TracChangeset
for help on using the changeset viewer.