(trunk libT) a little more work on #1829

This commit is contained in:
Charles Kerr 2009-02-18 21:27:44 +00:00
parent a129c452e5
commit f9e400a22d
3 changed files with 9 additions and 7 deletions

View File

@ -665,11 +665,11 @@ static struct tr_blockIterator*
blockIteratorNew( Torrent * t )
{
struct tr_blockIterator * i = tr_new0( struct tr_blockIterator, 1 );
tordbg( t, "creating new refill queue" );
i->expirationDate = time( NULL ) + PIECE_LIST_SHELF_LIFE_SECS;
i->t = t;
i->pieces = getPreferredPieces( t, &i->pieceCount );
i->blocks = tr_new0( tr_block_index_t, t->tor->blockCountInPiece );
tordbg( t, "creating new refill queue.. it contains %"PRIu32" pieces", i->pieceCount );
return i;
}
@ -871,9 +871,10 @@ refillPulse( void * vtorrent )
tr_free( webseeds );
tr_free( peers );
/* if we're out of blocks to request, free the request queue */
if( !hasNext )
if( !hasNext ) {
tordbg( t, "refill queue has no more blocks to request... freeing (webseed count: %d, peer count: %d)", webseedCount, peerCount );
blockIteratorFree( &t->refillQueue );
}
t->refillTimer = NULL;
torrentUnlock( t );

View File

@ -853,16 +853,16 @@ tr_peerMsgsAddRequest( tr_peermsgs * msgs,
return TR_ADDREQ_CLIENT_CHOKED;
}
/* peer doesn't have this piece */
if( !tr_bitfieldHas( msgs->peer->have, index ) )
return TR_ADDREQ_MISSING;
/* peer's queue is full */
if( requestQueueIsFull( msgs ) ) {
dbgmsg( msgs, "declining request because we're full" );
return TR_ADDREQ_FULL;
}
/* peer doesn't have this piece */
if( !tr_bitfieldHas( msgs->peer->have, index ) )
return TR_ADDREQ_MISSING;
/* have we already asked for this piece? */
req.index = index;
req.offset = offset;

View File

@ -416,6 +416,7 @@ handle_rpc( struct evhttp_request * req,
}
else if( req->type == EVHTTP_REQ_POST )
{
fprintf( stderr, "%s\n", (char*)EVBUFFER_DATA(req->input_buffer) );
tr_rpc_request_exec_json( server->session,
EVBUFFER_DATA( req->input_buffer ),
EVBUFFER_LENGTH( req->input_buffer ),