Changeset 7692
- Timestamp:
- Jan 12, 2009, 9:59:53 PM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/completion.c
r7647 r7692 316 316 return cp->completeBlocks[piece] == tr_torPieceCountBlocks( cp->tor, piece ); 317 317 } 318 319 tr_bool 320 tr_cpFileIsComplete( const tr_completion * cp, tr_file_index_t fileIndex ) 321 { 322 tr_block_index_t block; 323 324 const tr_torrent * tor = cp->tor; 325 const tr_file * file = &tor->info.files[fileIndex]; 326 const tr_block_index_t firstBlock = file->offset / tor->blockSize; 327 const tr_block_index_t lastBlock = ( file->offset + file->length - 1 ) / tor->blockSize; 328 329 assert( tr_torBlockPiece( tor, firstBlock ) == file->firstPiece ); 330 assert( tr_torBlockPiece( tor, lastBlock ) == file->lastPiece ); 331 332 for( block=firstBlock; block<=lastBlock; ++block ) 333 if( !tr_cpBlockIsComplete( cp, block ) ) 334 return FALSE; 335 336 return TRUE; 337 } -
trunk/libtransmission/completion.h
r7663 r7692 129 129 tr_piece_index_t piece ); 130 130 131 tr_bool tr_cpFileIsComplete( const tr_completion * cp, tr_file_index_t ); 132 131 133 /** 132 134 *** Blocks 133 135 **/ 134 136 135 static TR_INLINE inttr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t block ) {137 static TR_INLINE tr_bool tr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t block ) { 136 138 return tr_bitfieldHas( &cp->blockBitfield, block ); 137 139 } -
trunk/libtransmission/peer-mgr.c
r7663 r7692 27 27 #include "completion.h" 28 28 #include "crypto.h" 29 #include "fdlimit.h" 29 30 #include "handshake.h" 30 31 #include "inout.h" /* tr_ioTestPiece */ … … 1063 1064 case TR_PEER_CLIENT_GOT_BLOCK: 1064 1065 { 1065 tr_torrent * 1066 tr_torrent * tor = t->tor; 1066 1067 1067 1068 tr_block_index_t block = _tr_block( tor, e->pieceIndex, e->offset ); … … 1088 1089 1089 1090 if( !ok ) 1091 { 1090 1092 gotBadPiece( t, p ); 1093 } 1091 1094 else 1092 1095 { 1093 1096 int i; 1094 int peerCount = tr_ptrArraySize( &t->peers ); 1095 tr_peer ** peers = (tr_peer**) tr_ptrArrayBase( &t->peers ); 1097 int peerCount; 1098 tr_peer ** peers; 1099 tr_file_index_t fileIndex; 1100 1101 peerCount = tr_ptrArraySize( &t->peers ); 1102 peers = (tr_peer**) tr_ptrArrayBase( &t->peers ); 1096 1103 for( i=0; i<peerCount; ++i ) 1097 1104 tr_peerMsgsHave( peers[i]->msgs, p ); 1105 1106 for( fileIndex=0; fileIndex<tor->info.fileCount; ++fileIndex ) 1107 { 1108 const tr_file * file = &tor->info.files[fileIndex]; 1109 if( ( file->firstPiece <= p ) && ( p <= file->lastPiece ) && tr_cpFileIsComplete( &tor->completion, fileIndex ) ) 1110 { 1111 char * path = tr_buildPath( tor->downloadDir, file->name, NULL ); 1112 tordbg( t, "closing recently-completed file \"%s\"", path ); 1113 tr_fdFileClose( path ); 1114 tr_free( path ); 1115 } 1116 } 1098 1117 } 1099 1118
Note: See TracChangeset
for help on using the changeset viewer.