make download speed limits work?
This commit is contained in:
parent
e106876393
commit
c6aa57f306
|
@ -740,7 +740,6 @@ maybeConnect( tr_peerMgr * manager, Torrent * t, tr_peer * peer )
|
||||||
assert( t != NULL );
|
assert( t != NULL );
|
||||||
assert( peer != NULL );
|
assert( peer != NULL );
|
||||||
|
|
||||||
#if 0
|
|
||||||
if( peer->io != NULL ) { /* already connected */
|
if( peer->io != NULL ) { /* already connected */
|
||||||
fprintf( stderr, "not connecting because we already have an IO for that address\n" );
|
fprintf( stderr, "not connecting because we already have an IO for that address\n" );
|
||||||
return;
|
return;
|
||||||
|
@ -759,7 +758,6 @@ maybeConnect( tr_peerMgr * manager, Torrent * t, tr_peer * peer )
|
||||||
peer->port,
|
peer->port,
|
||||||
t->hash );
|
t->hash );
|
||||||
initiateHandshake( manager, io );
|
initiateHandshake( manager, io );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1167,6 +1165,8 @@ rechokePulse( void * vtorrent )
|
||||||
static int
|
static int
|
||||||
reconnectPulse( void * vt UNUSED )
|
reconnectPulse( void * vt UNUSED )
|
||||||
{
|
{
|
||||||
|
static int n = 0;
|
||||||
|
fprintf( stderr, "This console message has annoyed John_Clay %d times.\n", ++n );
|
||||||
#if 0
|
#if 0
|
||||||
Torrent * t = vt;
|
Torrent * t = vt;
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
|
|
|
@ -787,7 +787,7 @@ peerGotBytes( tr_peermsgs * msgs, uint32_t byteCount )
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
canDownload( const tr_peermsgs * msgs UNUSED )
|
canDownload( const tr_peermsgs * msgs )
|
||||||
{
|
{
|
||||||
tr_torrent * tor = msgs->torrent;
|
tr_torrent * tor = msgs->torrent;
|
||||||
|
|
||||||
|
@ -960,19 +960,26 @@ readBtPiece( tr_peermsgs * msgs, struct evbuffer * inbuf )
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReadState
|
static ReadState
|
||||||
canRead( struct bufferevent * evin, void * vpeer )
|
canRead( struct bufferevent * evin, void * vmsgs )
|
||||||
{
|
{
|
||||||
ReadState ret;
|
ReadState ret;
|
||||||
tr_peermsgs * peer = (tr_peermsgs *) vpeer;
|
tr_peermsgs * msgs = (tr_peermsgs *) vmsgs;
|
||||||
struct evbuffer * inbuf = EVBUFFER_INPUT ( evin );
|
struct evbuffer * inbuf = EVBUFFER_INPUT ( evin );
|
||||||
|
|
||||||
switch( peer->state )
|
if( !canDownload( msgs ) )
|
||||||
{
|
{
|
||||||
case AWAITING_BT_LENGTH: ret = readBtLength ( peer, inbuf ); break;
|
msgs->notListening = 1;
|
||||||
case AWAITING_BT_MESSAGE: ret = readBtMessage ( peer, inbuf ); break;
|
tr_peerIoSetIOMode ( msgs->io, 0, EV_READ );
|
||||||
case READING_BT_PIECE: ret = readBtPiece ( peer, inbuf ); break;
|
ret = READ_DONE;
|
||||||
|
}
|
||||||
|
else switch( msgs->state )
|
||||||
|
{
|
||||||
|
case AWAITING_BT_LENGTH: ret = readBtLength ( msgs, inbuf ); break;
|
||||||
|
case AWAITING_BT_MESSAGE: ret = readBtMessage ( msgs, inbuf ); break;
|
||||||
|
case READING_BT_PIECE: ret = readBtPiece ( msgs, inbuf ); break;
|
||||||
default: assert( 0 );
|
default: assert( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,14 +1022,12 @@ pulse( void * vmsgs )
|
||||||
|
|
||||||
/* if we froze out a downloaded block because of speed limits,
|
/* if we froze out a downloaded block because of speed limits,
|
||||||
start listening to the peer again */
|
start listening to the peer again */
|
||||||
#if 0
|
if( msgs->notListening && canDownload( msgs ) )
|
||||||
if( msgs->notListening )
|
|
||||||
{
|
{
|
||||||
fprintf( stderr, "msgs %p thawing out...\n", msgs );
|
fprintf( stderr, "msgs %p thawing out...\n", msgs );
|
||||||
msgs->notListening = 0;
|
msgs->notListening = 0;
|
||||||
tr_peerIoSetIOMode ( msgs->io, EV_READ, 0 );
|
tr_peerIoSetIOMode ( msgs->io, EV_READ, 0 );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if( !canWrite( msgs ) )
|
if( !canWrite( msgs ) )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue