1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00

(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 ) blockIteratorNew( Torrent * t )
{ {
struct tr_blockIterator * i = tr_new0( struct tr_blockIterator, 1 ); 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->expirationDate = time( NULL ) + PIECE_LIST_SHELF_LIFE_SECS;
i->t = t; i->t = t;
i->pieces = getPreferredPieces( t, &i->pieceCount ); i->pieces = getPreferredPieces( t, &i->pieceCount );
i->blocks = tr_new0( tr_block_index_t, t->tor->blockCountInPiece ); 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; return i;
} }
@ -871,9 +871,10 @@ refillPulse( void * vtorrent )
tr_free( webseeds ); tr_free( webseeds );
tr_free( peers ); 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 ); blockIteratorFree( &t->refillQueue );
}
t->refillTimer = NULL; t->refillTimer = NULL;
torrentUnlock( t ); torrentUnlock( t );

View file

@ -853,16 +853,16 @@ tr_peerMsgsAddRequest( tr_peermsgs * msgs,
return TR_ADDREQ_CLIENT_CHOKED; 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 */ /* peer's queue is full */
if( requestQueueIsFull( msgs ) ) { if( requestQueueIsFull( msgs ) ) {
dbgmsg( msgs, "declining request because we're full" ); dbgmsg( msgs, "declining request because we're full" );
return TR_ADDREQ_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? */ /* have we already asked for this piece? */
req.index = index; req.index = index;
req.offset = offset; req.offset = offset;

View file

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