From f9e400a22dfb77ea51757c8454383490a8fc334a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 18 Feb 2009 21:27:44 +0000 Subject: [PATCH] (trunk libT) a little more work on #1829 --- libtransmission/peer-mgr.c | 7 ++++--- libtransmission/peer-msgs.c | 8 ++++---- libtransmission/rpc-server.c | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 384aa094f..f0b142ad7 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -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 ); diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index ebe27e2bf..3e4ee8709 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -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; diff --git a/libtransmission/rpc-server.c b/libtransmission/rpc-server.c index 6cfff9e4b..faabde273 100644 --- a/libtransmission/rpc-server.c +++ b/libtransmission/rpc-server.c @@ -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 ),