make download speed limits work?

This commit is contained in:
Charles Kerr 2007-09-22 05:16:32 +00:00
parent e106876393
commit c6aa57f306
2 changed files with 17 additions and 12 deletions

View File

@ -740,7 +740,6 @@ maybeConnect( tr_peerMgr * manager, Torrent * t, tr_peer * peer )
assert( t != NULL );
assert( peer != NULL );
#if 0
if( peer->io != NULL ) { /* already connected */
fprintf( stderr, "not connecting because we already have an IO for that address\n" );
return;
@ -759,7 +758,6 @@ maybeConnect( tr_peerMgr * manager, Torrent * t, tr_peer * peer )
peer->port,
t->hash );
initiateHandshake( manager, io );
#endif
}
void
@ -1167,6 +1165,8 @@ rechokePulse( void * vtorrent )
static int
reconnectPulse( void * vt UNUSED )
{
static int n = 0;
fprintf( stderr, "This console message has annoyed John_Clay %d times.\n", ++n );
#if 0
Torrent * t = vt;
/* FIXME */

View File

@ -787,7 +787,7 @@ peerGotBytes( tr_peermsgs * msgs, uint32_t byteCount )
}
static int
canDownload( const tr_peermsgs * msgs UNUSED )
canDownload( const tr_peermsgs * msgs )
{
tr_torrent * tor = msgs->torrent;
@ -960,19 +960,26 @@ readBtPiece( tr_peermsgs * msgs, struct evbuffer * inbuf )
}
static ReadState
canRead( struct bufferevent * evin, void * vpeer )
canRead( struct bufferevent * evin, void * vmsgs )
{
ReadState ret;
tr_peermsgs * peer = (tr_peermsgs *) vpeer;
tr_peermsgs * msgs = (tr_peermsgs *) vmsgs;
struct evbuffer * inbuf = EVBUFFER_INPUT ( evin );
switch( peer->state )
if( !canDownload( msgs ) )
{
case AWAITING_BT_LENGTH: ret = readBtLength ( peer, inbuf ); break;
case AWAITING_BT_MESSAGE: ret = readBtMessage ( peer, inbuf ); break;
case READING_BT_PIECE: ret = readBtPiece ( peer, inbuf ); break;
msgs->notListening = 1;
tr_peerIoSetIOMode ( msgs->io, 0, EV_READ );
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 );
}
return ret;
}
@ -1015,14 +1022,12 @@ pulse( void * vmsgs )
/* if we froze out a downloaded block because of speed limits,
start listening to the peer again */
#if 0
if( msgs->notListening )
if( msgs->notListening && canDownload( msgs ) )
{
fprintf( stderr, "msgs %p thawing out...\n", msgs );
msgs->notListening = 0;
tr_peerIoSetIOMode ( msgs->io, EV_READ, 0 );
}
#endif
if( !canWrite( msgs ) )
{