Changeset 2184
- Timestamp:
- Jun 22, 2007, 4:30:39 AM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/makemeta.c
r2165 r2184 143 143 ++ret->fileCount; 144 144 145 ret->files = tr_calloc( ret->fileCount, sizeof(tr_metainfo_builder_file_t));145 ret->files = tr_calloc(ret->fileCount, sizeof(tr_metainfo_builder_file_t)); 146 146 147 147 for( i=0, walk=files; walk!=NULL; ++i ) … … 207 207 { 208 208 uint8_t *bufptr = buf; 209 const uint64_t thisPieceSize = MIN( (uint32_t)b->pieceSize, totalRemain ); 209 const uint64_t thisPieceSize = 210 MIN( (uint32_t)b->pieceSize, totalRemain ); 210 211 uint64_t pieceRemain = thisPieceSize; 211 212 … … 214 215 while( pieceRemain ) 215 216 { 216 const uint64_t n_this_pass = MIN( (b->files[fileIndex].size - off), pieceRemain ); 217 const uint64_t n_this_pass = 218 MIN( (b->files[fileIndex].size - off), pieceRemain ); 217 219 fread( bufptr, 1, n_this_pass, fp ); 218 220 bufptr += n_this_pass; -
trunk/libtransmission/makemeta.h
r2160 r2184 22 22 { 23 23 /** 24 *** These are set by tr_makeMetaInfo ()24 *** These are set by tr_makeMetaInfoBuilderCreate() 25 25 *** and cleaned up by tr_metaInfoBuilderFree() 26 26 **/ -
trunk/libtransmission/peer.c
r2177 r2184 57 57 /** 58 58 * We expend a fraction of our torrent's total upload speed 59 * on onlargesse by uniformly distributing free credit to59 * on largesse by uniformly distributing free credit to 60 60 * all of our peers. This too helps prevent gridlock. 61 61 */ … … 603 603 604 604 /* TODO: add some asserts to see if this bitfield is really necessary */ 605 tr_bitfield_t * blocksAlreadyRequested= tr_bitfieldNew( tor->blockCount );605 tr_bitfield_t * requestedBlocks = tr_bitfieldNew( tor->blockCount ); 606 606 for( i=0; i<peer->inRequestCount; ++i) { 607 607 const tr_request_t * r = &peer->inRequests[i]; 608 608 const int block = tr_block( r->index, r->begin ); 609 tr_bitfieldAdd( blocksAlreadyRequested, block );609 tr_bitfieldAdd( requestedBlocks, block ); 610 610 } 611 611 … … 618 618 : tr_cpMissingBlockInPiece ( tor->completion, piece ); 619 619 620 if( block>=0 && (endgame || !tr_bitfieldHas( blocksAlreadyRequested, block ) ) )620 if( block>=0 && (endgame || !tr_bitfieldHas( requestedBlocks, block ) ) ) 621 621 { 622 tr_bitfieldAdd( blocksAlreadyRequested, block );622 tr_bitfieldAdd( requestedBlocks, block ); 623 623 sendRequest( tor, peer, block ); 624 624 } … … 626 626 } 627 627 628 tr_bitfieldFree( blocksAlreadyRequested);628 tr_bitfieldFree( requestedBlocks ); 629 629 free( pool ); 630 630 } … … 660 660 } 661 661 662 /***********************************************************************663 * tr_peerProgress664 ***********************************************************************665 *666 **********************************************************************/667 662 float tr_peerProgress( const tr_peer_t * peer ) 668 663 { … … 670 665 } 671 666 672 /***********************************************************************673 * tr_peerPort674 ***********************************************************************675 * Returns peer's listening port in host byte order676 **********************************************************************/677 667 int tr_peerPort( const tr_peer_t * peer ) 678 668 { … … 881 871 { 882 872 static time_t lastPulseTime = 0; 883 const time_t now = time (NULL); 884 tr_torrent_t * tor;885 886 if( lastPulseTime + SWIFT_REFRESH_INTERVAL_SEC > now )887 return;888 lastPulseTime = now;889 890 for( tor=h->torrentList; tor; tor=tor->next )891 tr_torrentSwiftPulse( tor );892 } 873 874 if( lastPulseTime + SWIFT_REFRESH_INTERVAL_SEC <= time( NULL ) ) 875 { 876 tr_torrent_t * tor; 877 for( tor=h->torrentList; tor; tor=tor->next ) 878 tr_torrentSwiftPulse( tor ); 879 880 lastPulseTime = time( NULL ); 881 } 882 } -
trunk/libtransmission/platform.c
r2155 r2184 265 265 } 266 266 267 void tr_lockLock( tr_lock_t * l ) 268 { 269 #ifdef SYS_BEOS 270 acquire_sem( *l ); 271 #else 272 pthread_mutex_lock( l ); 273 #endif 274 } 275 276 void tr_lockUnlock( tr_lock_t * l ) 277 { 278 #ifdef SYS_BEOS 279 release_sem( *l ); 280 #else 281 pthread_mutex_unlock( l ); 282 #endif 283 } 284 267 285 268 286 void tr_condInit( tr_cond_t * c ) -
trunk/libtransmission/platform.h
r2154 r2184 45 45 tr_thread_t; 46 46 47 /* only for debugging purposes */48 47 const char * tr_getHomeDirectory( void ); 49 50 48 const char * tr_getCacheDirectory( void ); 51 49 const char * tr_getTorrentsDirectory( void ); … … 62 60 void tr_lockInit ( tr_lock_t * ); 63 61 void tr_lockClose ( tr_lock_t * ); 62 void tr_lockLock ( tr_lock_t * ); 63 void tr_lockUnlock ( tr_lock_t * ); 64 64 65 static inline void tr_lockLock( tr_lock_t * l ) 66 { 67 #ifdef SYS_BEOS 68 acquire_sem( *l ); 69 #else 70 pthread_mutex_lock( l ); 71 #endif 72 } 73 74 static inline void tr_lockUnlock( tr_lock_t * l ) 75 { 76 #ifdef SYS_BEOS 77 release_sem( *l ); 78 #else 79 pthread_mutex_unlock( l ); 80 #endif 81 } 82 83 void tr_condInit( tr_cond_t * ); 84 void tr_condWait( tr_cond_t *, tr_lock_t * ); 85 void tr_condSignal( tr_cond_t * ); 86 void tr_condClose( tr_cond_t * ); 65 void tr_condInit ( tr_cond_t * ); 66 void tr_condWait ( tr_cond_t *, tr_lock_t * ); 67 void tr_condSignal ( tr_cond_t * ); 68 void tr_condClose ( tr_cond_t * ); 87 69 88 70 struct in_addr; /* forward declaration to calm gcc down */
Note: See TracChangeset
for help on using the changeset viewer.