Changeset 1666


Ignore:
Timestamp:
Apr 5, 2007, 4:23:00 PM (16 years ago)
Author:
titer
Message:

Don't assume that peers send us blocks in the same order we sent the requests (another cause of overdownloading)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peerparse.h

    r1665 r1666  
    254254}
    255255
    256 static inline void updateRequests( tr_torrent_t * tor, tr_peer_t * peer,
    257                                    int index, int begin )
     256static inline void updateRequests( tr_peer_t * peer, int index, int begin )
    258257{
    259258    tr_request_t * r;
    260     int i, j;
     259    int i;
    261260
    262261    /* Find this block in the requests list */
     
    270269    }
    271270
    272     /* Usually i should be 0, but some clients don't handle multiple
    273        request well and drop previous requests */
     271    /* Usually 'i' would be 0, but some clients don't handle multiple
     272       requests and drop previous requests, some other clients don't
     273       send blocks in the same order we sent the requests */
    274274    if( i < peer->inRequestCount )
    275275    {
    276         if( i > 0 )
    277         {
    278             peer_dbg( "not expecting this block yet (%d requests dropped)", i );
    279         }
    280         i++;
    281         for( j = 0; j < i; j++ )
    282         {
    283             r = &peer->inRequests[j];
    284             tr_cpDownloaderRem( tor->completion,
    285                                 tr_block( r->index, r->begin ) );
    286         }
    287         peer->inRequestCount -= i;
    288         memmove( &peer->inRequests[0], &peer->inRequests[i],
    289                  peer->inRequestCount * sizeof( tr_request_t ) );
     276        peer->inRequestCount--;
     277        memmove( &peer->inRequests[i], &peer->inRequests[i+1],
     278                 ( peer->inRequestCount - i ) * sizeof( tr_request_t ) );
    290279    }
    291280    else
     
    328317              index, begin, len - 8 );
    329318
    330     updateRequests( tor, peer, index, begin );
     319    updateRequests( peer, index, begin );
    331320    tor->downloadedCur += len - 8;
    332321
Note: See TracChangeset for help on using the changeset viewer.