Changeset 12921
- Timestamp:
- Sep 26, 2011, 10:50:42 PM (11 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/bitfield.c
r12904 r12921 282 282 tr_bitfieldSetHasNone( b ); 283 283 else 284 tr_bitfieldSetRaw( b, src->bits, src->alloc_count );285 } 286 287 void 288 tr_bitfieldSetRaw( tr_bitfield * b, const void * bits, size_t byte_count )284 tr_bitfieldSetRaw( b, src->bits, src->alloc_count, true ); 285 } 286 287 void 288 tr_bitfieldSetRaw( tr_bitfield * b, const void * bits, size_t byte_count, bool bounded ) 289 289 { 290 290 tr_bitfieldFreeArray( b ); 291 291 b->true_count = 0; 292 293 if( bounded ) 294 byte_count = MIN( byte_count, get_bytes_needed( b->bit_count ) ); 295 292 296 b->bits = tr_memdup( bits, byte_count ); 293 297 b->alloc_count = byte_count; 298 299 if( bounded ) { 300 /* ensure the excess bits are set to '0' */ 301 const int excess_bit_count = byte_count*8 - b->bit_count; 302 assert( excess_bit_count >= 0 ); 303 assert( excess_bit_count <= 7 ); 304 if( excess_bit_count ) 305 b->bits[b->alloc_count-1] &= ((0xff) << excess_bit_count); 306 } 307 294 308 tr_bitfieldRebuildTrueCount( b ); 295 309 } -
trunk/libtransmission/bitfield.h
r12902 r12921 75 75 void tr_bitfieldSetFromBitfield( tr_bitfield*, const tr_bitfield* ); 76 76 77 void tr_bitfieldSetRaw( tr_bitfield*, const void * bits, size_t byte_count );77 void tr_bitfieldSetRaw( tr_bitfield*, const void * bits, size_t byte_count, bool bounded ); 78 78 79 79 void* tr_bitfieldGetRaw( const tr_bitfield * b, size_t * byte_count ); -
trunk/libtransmission/peer-msgs.c
r12590 r12921 1415 1415 dbgmsg( msgs, "got a bitfield" ); 1416 1416 tr_peerIoReadBytes( msgs->peer->io, inbuf, tmp, msglen ); 1417 tr_bitfieldSetRaw( &msgs->peer->have, tmp, msglen );1417 tr_bitfieldSetRaw( &msgs->peer->have, tmp, msglen, tr_torrentHasMetadata( msgs->torrent ) ); 1418 1418 fireClientGotBitfield( msgs, &msgs->peer->have ); 1419 1419 updatePeerProgress( msgs ); -
trunk/libtransmission/resume.c
r12291 r12921 592 592 tr_bitfieldSetHasNone( &blocks ); 593 593 else 594 tr_bitfieldSetRaw( &blocks, buf, buflen );594 tr_bitfieldSetRaw( &blocks, buf, buflen, true ); 595 595 } 596 596 else if( tr_bencDictFindStr( prog, KEY_PROGRESS_HAVE, &str ) ) … … 603 603 else if( tr_bencDictFindRaw( prog, KEY_PROGRESS_BITFIELD, &raw, &rawlen ) ) 604 604 { 605 tr_bitfieldSetRaw( &blocks, raw, rawlen );605 tr_bitfieldSetRaw( &blocks, raw, rawlen, true ); 606 606 } 607 607 else err = "Couldn't find 'pieces' or 'have' or 'bitfield'";
Note: See TracChangeset
for help on using the changeset viewer.