From 18c171d0ae62b31dd0c1ff614fccca15518646f8 Mon Sep 17 00:00:00 2001 From: Josh Elsasser Date: Fri, 9 Mar 2007 01:43:10 +0000 Subject: [PATCH] Send the correct bitfield in the bitfield message. --- libtransmission/peermessages.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libtransmission/peermessages.h b/libtransmission/peermessages.h index 12325c21c..6fefad3dd 100644 --- a/libtransmission/peermessages.h +++ b/libtransmission/peermessages.h @@ -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" ); }