Changeset 12065


Ignore:
Timestamp:
Mar 2, 2011, 3:00:12 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) #4078 "Better calculation of the bitfield length while still a magnet link" -- fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-msgs.c

    r12022 r12065  
    179179    uint16_t        pexCount6;
    180180
     181    size_t          metadata_size_hint;
    181182#if 0
    182183    size_t                 fastsetSize;
     
    926927
    927928    /* look for metainfo size (BEP 9) */
    928     if( tr_bencDictFindInt( &val, "metadata_size", &i ) )
     929    if( tr_bencDictFindInt( &val, "metadata_size", &i ) ) {
    929930        tr_torrentSetMetadataSizeHint( msgs->torrent, i );
     931        msgs->metadata_size_hint = (size_t) i;
     932    }
    930933
    931934    /* look for upload_only (BEP 21) */
     
    12751278
    12761279        case BT_BITFIELD:
    1277             return len == ( msg->torrent->info.pieceCount + 7u ) / 8u + 1u;
     1280            if( tr_torrentHasMetadata( msg->torrent ) )
     1281                return len == ( msg->torrent->info.pieceCount + 7u ) / 8u + 1u;
     1282            /* we don't know the piece count yet,
     1283               so we can only guess whether to send TRUE or FALSE */
     1284            if( msg->metadata_size_hint > 0 )
     1285                return len <= msg->metadata_size_hint;
     1286            return TRUE;
    12781287
    12791288        case BT_REQUEST:
Note: See TracChangeset for help on using the changeset viewer.