Changeset 5204


Ignore:
Timestamp:
Mar 6, 2008, 1:24:44 PM (14 years ago)
Author:
charles
Message:

#751: more digging to try to figure out where the problem is.

Location:
trunk/libtransmission
Files:
4 edited

Legend:

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

    r5168 r5204  
    811811        const uint32_t length = tr_torBlockCountBytes( tor, (int)block );
    812812
     813        assert( tr_torrentReqIsValid( tor, index, begin, length ) );
    813814        assert( _tr_block( tor, index, begin ) == (int)block );
    814815        assert( begin < (uint32_t)tr_torPieceCountBytes( tor, (int)index ) );
  • trunk/libtransmission/peer-msgs.c

    r5200 r5204  
    6161    TR_LTEP_PEX             = 1,
    6262
    63     /* drop requests who want too much */
    64     MAX_REQUEST_BYTE_COUNT  = (16 * 1024),
    65 
    6663    MIN_CHOKE_PERIOD_SEC    = (10),
    6764
     
    676673            uint32_t              length )
    677674{
    678     const tr_torrent * tor = msgs->torrent;
    679     int err = 0;
    680 
    681     if( index >= (uint32_t) tor->info.pieceCount )
    682         err = 1;
    683     else if ( (int)offset >= tr_torPieceCountBytes( tor, (int)index ) )
    684         err = 2;
    685     else if( length > MAX_REQUEST_BYTE_COUNT )
    686         err = 3;
    687     else if( tr_pieceOffset( tor, index, offset, length ) > tor->info.totalSize )
    688         err = 4;
    689 
    690     if( err )
    691     {
    692         fprintf( stderr, "(ticket #751) err is %d\n", err );
    693         fprintf( stderr, "(ticket #751) req.index is %"PRIu32"\n", index );
    694         fprintf( stderr, "(ticket #751) req.offset is %"PRIu32"\n", offset );
    695         fprintf( stderr, "(ticket #751) req.length is %"PRIu32"\n", length );
    696         fprintf( stderr, "(ticket #751) tor->info.totalSize is %"PRIu64"\n", tor->info.totalSize );
    697         fprintf( stderr, "(ticket #751) tor->info.pieceCount is %d\n", tor->info.pieceCount );
    698         fprintf( stderr, "(ticket #751) tr_torPieceCountBytes is %d\n", tr_torPieceCountBytes( tor, (int)index ) );
    699         fprintf( stderr, "(ticket #751) tr_pieceOffset is %"PRIu64"\n", tr_pieceOffset( tor, index, offset, length ) );
    700     }
    701 
    702     return !err;
     675    return tr_torrentReqIsValid( msgs->torrent, index, offset, length );
    703676}
    704677
  • trunk/libtransmission/torrent.c

    r5193 r5204  
    12821282***/
    12831283
    1284 int _tr_block( const tr_torrent * tor, int index, int begin )
     1284int
     1285_tr_block( const tr_torrent * tor, int index, int begin )
    12851286{
    12861287    const tr_info * inf = &tor->info;
     
    12881289        begin / tor->blockSize;
    12891290}
     1291
     1292int
     1293tr_torrentReqIsValid( const tr_torrent * tor,
     1294                      uint32_t           index,
     1295                      uint32_t           offset,
     1296                      uint32_t           length )
     1297{
     1298    static const uint32_t MAX_REQUEST_BYTE_COUNT  = (16 * 1024);
     1299    int err = 0;
     1300
     1301    if( index >= (uint32_t) tor->info.pieceCount )
     1302        err = 1;
     1303    else if ( (int)offset >= tr_torPieceCountBytes( tor, (int)index ) )
     1304        err = 2;
     1305    else if( length > MAX_REQUEST_BYTE_COUNT )
     1306        err = 3;
     1307    else if( tr_pieceOffset( tor, index, offset, length ) > tor->info.totalSize )
     1308        err = 4;
     1309
     1310    if( err )
     1311    {
     1312        fprintf( stderr, "(ticket #751) err is %d\n", err );
     1313        fprintf( stderr, "(ticket #751) req.index is %"PRIu32"\n", index );
     1314        fprintf( stderr, "(ticket #751) req.offset is %"PRIu32"\n", offset );
     1315        fprintf( stderr, "(ticket #751) req.length is %"PRIu32"\n", length );
     1316        fprintf( stderr, "(ticket #751) tor->info.totalSize is %"PRIu64"\n", tor->info.totalSize );
     1317        fprintf( stderr, "(ticket #751) tor->info.pieceCount is %d\n", tor->info.pieceCount );
     1318        fprintf( stderr, "(ticket #751) tr_torPieceCountBytes is %d\n", tr_torPieceCountBytes( tor, (int)index ) );
     1319        fprintf( stderr, "(ticket #751) tr_pieceOffset is %"PRIu64"\n", tr_pieceOffset( tor, index, offset, length ) );
     1320    }
     1321
     1322    return !err;
     1323}
     1324
    12901325
    12911326uint64_t
  • trunk/libtransmission/torrent.h

    r5126 r5204  
    11/******************************************************************************
    2  * $Id:$
     2 * $Id$
    33 *
    44 * Copyright (c) 2005-2008 Transmission authors and contributors
     
    7575#define tr_block(a,b) _tr_block(tor,a,b)
    7676int _tr_block( const tr_torrent * tor, int index, int begin );
     77
     78int tr_torrentReqIsValid( const tr_torrent * tor,
     79                          uint32_t           index,
     80                          uint32_t           offset,
     81                          uint32_t           length );
    7782
    7883uint64_t tr_pieceOffset( const tr_torrent * tor, int index, int begin, int length );
Note: See TracChangeset for help on using the changeset viewer.