Changeset 3169
- Timestamp:
- Sep 25, 2007, 10:30:41 PM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/Makefile.am
r3105 r3169 45 45 noinst_HEADERS = \ 46 46 bencode.h \ 47 bsdqueue.h \48 47 bsdtree.h \ 49 48 clients.h \ -
trunk/libtransmission/peer-mgr.c
r3163 r3169 1237 1237 } 1238 1238 } 1239 1239 1240 #if 0 1240 1241 /* maybe connect to some new peers */ 1241 1242 if( t->isRunning && (liveCount<MAX_CONNECTED_PEERS_PER_TORRENT) ) … … 1282 1283 tr_free( pool ); 1283 1284 } 1285 #endif 1284 1286 1285 1287 return TRUE; -
trunk/libtransmission/peer-msgs.c
r3165 r3169 381 381 pulse( void * vmsgs ); 382 382 383 static int 384 reqIsValid( const tr_peermsgs * msgs, uint32_t index, uint32_t offset, uint32_t length ) 385 { 386 const tr_torrent * tor = msgs->torrent; 387 388 if( index >= (uint32_t) tor->info.pieceCount ) 389 return FALSE; 390 if ( (int)offset >= tr_torPieceCountBytes( tor, (int)index ) ) 391 return FALSE; 392 if( length > MAX_REQUEST_BYTE_COUNT ) 393 return FALSE; 394 if( tr_pieceOffset( tor, index, offset, length ) > tor->info.totalSize ) 395 return FALSE; 396 397 return TRUE; 398 } 399 400 static int 401 requestIsValid( const tr_peermsgs * msgs, struct peer_request * req ) 402 { 403 return reqIsValid( msgs, req->index, req->offset, req->length ); 404 } 405 383 406 int 384 407 tr_peerMsgsAddRequest( tr_peermsgs * msgs, … … 394 417 assert( msgs != NULL ); 395 418 assert( msgs->torrent != NULL ); 396 assert( index < ((uint32_t)msgs->torrent->info.pieceCount) ); 397 assert( offset < (uint32_t)tr_torPieceCountBytes( msgs->torrent, (int)index ) ); 398 assert( (offset + length) <= (uint32_t)tr_torPieceCountBytes( msgs->torrent, (int)index ) ); 419 assert( reqIsValid( msgs, index, offset, length ) ); 399 420 400 421 if( msgs->info->clientIsChoked ) … … 608 629 msgs->state = AWAITING_BT_MESSAGE; 609 630 } return READ_AGAIN; 610 }611 612 static int613 requestIsValid( const tr_peermsgs * msgs, struct peer_request * req )614 {615 const tr_torrent * tor = msgs->torrent;616 assert( req != NULL );617 618 if( req->index >= (uint32_t) tor->info.pieceCount )619 return FALSE;620 if ( (int)req->offset >= tr_torPieceCountBytes( tor, (int)req->index ) )621 return FALSE;622 if( req->length > MAX_REQUEST_BYTE_COUNT )623 return FALSE;624 if( tr_pieceOffset( tor, req->index, req->offset, req->length ) > tor->info.totalSize )625 return FALSE;626 627 return TRUE;628 631 } 629 632 … … 727 730 dbgmsg( msgs, "peer sent us a BT_PIECE" ); 728 731 assert( msgs->blockToUs.length == 0 ); 729 msgs->state = READING_BT_PIECE;730 732 tr_peerIoReadUint32( msgs->io, inbuf, &msgs->blockToUs.index ); 731 733 tr_peerIoReadUint32( msgs->io, inbuf, &msgs->blockToUs.offset ); 732 734 msgs->blockToUs.length = msglen - 8; 733 assert( msgs->blockToUs.length > 0 );734 735 assert( EVBUFFER_LENGTH(msgs->inBlock) == 0 ); 735 736 //evbuffer_drain( msgs->inBlock, ~0 ); 737 msgs->state = msgs->blockToUs.length ? READING_BT_PIECE : AWAITING_BT_LENGTH; 736 738 return READ_AGAIN; 737 739 break; … … 1011 1013 { 1012 1014 /* don't let our outbuffer get too large */ 1013 if( tr_peerIoWriteBytesWaiting( msgs->io ) > 1024)1015 if( tr_peerIoWriteBytesWaiting( msgs->io ) > 2048 ) 1014 1016 return FALSE; 1015 1017 … … 1056 1058 while ( len && canUpload( msgs ) ) 1057 1059 { 1058 const size_t outlen = MIN( len, 1024);1060 const size_t outlen = MIN( len, 2048 ); 1059 1061 tr_peerIoWrite( msgs->io, EVBUFFER_DATA(msgs->outBlock), outlen ); 1060 1062 evbuffer_drain( msgs->outBlock, outlen );
Note: See TracChangeset
for help on using the changeset viewer.