(trunk libT) avoid an unnecessary malloc() + free() call when we finish downloading a block.

Pre-libevent2, this free() was useful in helping keep the peer's incoming piece data buffer from growing too large because that could be a significant amount of wasted space given enough peers. However now that we're using the libevent2 code, that piece data buffer gets handed off to the block cache, so most of the time we're freeing an evbuffer that doesn't have any inernal chains allocated anyway.
This commit is contained in:
Jordan Lee 2011-04-04 05:15:54 +00:00
parent 525d854016
commit 40b2ad63d9
1 changed files with 2 additions and 3 deletions

View File

@ -1319,12 +1319,11 @@ readBtPiece( tr_peermsgs * msgs,
if( evbuffer_get_length( msgs->incoming.block ) < req->length )
return READ_LATER;
/* we've got the whole block ... process it */
/* pass the block along... */
err = clientGotBlock( msgs, msgs->incoming.block, req );
evbuffer_drain( msgs->incoming.block, evbuffer_get_length( msgs->incoming.block ) );
/* cleanup */
evbuffer_free( msgs->incoming.block );
msgs->incoming.block = evbuffer_new( );
req->length = 0;
msgs->state = AWAITING_BT_LENGTH;
return err ? READ_ERR : READ_NOW;