Send the correct bitfield in the bitfield message.

This commit is contained in:
Josh Elsasser 2007-03-09 01:43:10 +00:00
parent 3ea3455a4a
commit 18c171d0ae
1 changed files with 5 additions and 4 deletions

View File

@ -250,12 +250,13 @@ static void sendHave( tr_peer_t * peer, int piece )
**********************************************************************/
static void sendBitfield( tr_torrent_t * tor, tr_peer_t * peer )
{
uint8_t * p;
int bitfieldSize = ( tor->info.pieceCount + 7 ) / 8;
uint8_t * p;
tr_bitfield_t * bitfield;
p = getMessagePointer( peer, bitfieldSize, PEER_MSG_BITFIELD );
bitfield = tr_cpPieceBitfield( tor->completion );
p = getMessagePointer( peer, bitfield->len, PEER_MSG_BITFIELD );
memcpy( p, tr_cpPieceBitfield( tor->completion ), bitfieldSize );
memcpy( p, bitfield->bits, bitfield->len );
peer_dbg( "SEND bitfield" );
}