mirror of
https://github.com/transmission/transmission
synced 2025-03-20 02:35:43 +00:00
improve upload speeds when the speed limits are uncapped.
This commit is contained in:
parent
e843d4869c
commit
abef433926
4 changed files with 27 additions and 5 deletions
|
@ -968,7 +968,7 @@ void
|
||||||
tr_handshakeDone( tr_handshake * handshake, int isOK )
|
tr_handshakeDone( tr_handshake * handshake, int isOK )
|
||||||
{
|
{
|
||||||
dbgmsg( handshake, "handshakeDone: %s", isOK ? "connected" : "aborting" );
|
dbgmsg( handshake, "handshakeDone: %s", isOK ? "connected" : "aborting" );
|
||||||
tr_peerIoSetIOFuncs( handshake->io, NULL, NULL, NULL );
|
tr_peerIoSetIOFuncs( handshake->io, NULL, NULL, NULL, NULL );
|
||||||
|
|
||||||
fireDoneFunc( handshake, isOK );
|
fireDoneFunc( handshake, isOK );
|
||||||
|
|
||||||
|
@ -1030,7 +1030,7 @@ tr_handshakeNew( tr_peerIo * io,
|
||||||
handshake->doneUserData = doneUserData;
|
handshake->doneUserData = doneUserData;
|
||||||
handshake->handle = tr_peerIoGetHandle( io );
|
handshake->handle = tr_peerIoGetHandle( io );
|
||||||
|
|
||||||
tr_peerIoSetIOFuncs( handshake->io, canRead, gotError, handshake );
|
tr_peerIoSetIOFuncs( handshake->io, canRead, NULL, gotError, handshake );
|
||||||
|
|
||||||
if( tr_peerIoIsIncoming( handshake->io ) )
|
if( tr_peerIoIsIncoming( handshake->io ) )
|
||||||
setReadState( handshake, AWAITING_HANDSHAKE );
|
setReadState( handshake, AWAITING_HANDSHAKE );
|
||||||
|
|
|
@ -61,6 +61,7 @@ struct tr_peerIo
|
||||||
unsigned int peerIdIsSet : 1;
|
unsigned int peerIdIsSet : 1;
|
||||||
|
|
||||||
tr_can_read_cb canRead;
|
tr_can_read_cb canRead;
|
||||||
|
tr_did_write_cb didWrite;
|
||||||
tr_net_error_cb gotError;
|
tr_net_error_cb gotError;
|
||||||
void * userData;
|
void * userData;
|
||||||
|
|
||||||
|
@ -71,6 +72,14 @@ struct tr_peerIo
|
||||||
***
|
***
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
static void
|
||||||
|
didWriteWrapper( struct bufferevent * e, void * userData )
|
||||||
|
{
|
||||||
|
tr_peerIo * c = (tr_peerIo *) userData;
|
||||||
|
if( c->didWrite != NULL )
|
||||||
|
(*c->didWrite)( e, c->userData );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
canReadWrapper( struct bufferevent * e, void * userData )
|
canReadWrapper( struct bufferevent * e, void * userData )
|
||||||
{
|
{
|
||||||
|
@ -134,7 +143,7 @@ tr_peerIoNew( struct tr_handle * handle,
|
||||||
c->timeout = IO_TIMEOUT_SECS;
|
c->timeout = IO_TIMEOUT_SECS;
|
||||||
c->bufev = bufferevent_new( c->socket,
|
c->bufev = bufferevent_new( c->socket,
|
||||||
canReadWrapper,
|
canReadWrapper,
|
||||||
NULL,
|
didWriteWrapper,
|
||||||
gotErrorWrapper,
|
gotErrorWrapper,
|
||||||
c );
|
c );
|
||||||
bufferevent_settimeout( c->bufev, c->timeout, c->timeout );
|
bufferevent_settimeout( c->bufev, c->timeout, c->timeout );
|
||||||
|
@ -192,6 +201,7 @@ tr_peerIoFree( tr_peerIo * io )
|
||||||
if( io != NULL )
|
if( io != NULL )
|
||||||
{
|
{
|
||||||
io->canRead = NULL;
|
io->canRead = NULL;
|
||||||
|
io->didWrite = NULL;
|
||||||
io->gotError = NULL;
|
io->gotError = NULL;
|
||||||
tr_runInEventThread( io->handle, io_dtor, io );
|
tr_runInEventThread( io->handle, io_dtor, io );
|
||||||
}
|
}
|
||||||
|
@ -241,10 +251,12 @@ tr_peerIoTryRead( tr_peerIo * io )
|
||||||
void
|
void
|
||||||
tr_peerIoSetIOFuncs( tr_peerIo * io,
|
tr_peerIoSetIOFuncs( tr_peerIo * io,
|
||||||
tr_can_read_cb readcb,
|
tr_can_read_cb readcb,
|
||||||
|
tr_did_write_cb writecb,
|
||||||
tr_net_error_cb errcb,
|
tr_net_error_cb errcb,
|
||||||
void * userData )
|
void * userData )
|
||||||
{
|
{
|
||||||
io->canRead = readcb;
|
io->canRead = readcb;
|
||||||
|
io->didWrite = writecb;
|
||||||
io->gotError = errcb;
|
io->gotError = errcb;
|
||||||
io->userData = userData;
|
io->userData = userData;
|
||||||
|
|
||||||
|
@ -272,7 +284,9 @@ tr_peerIoReconnect( tr_peerIo * io )
|
||||||
bufferevent_free( io->bufev );
|
bufferevent_free( io->bufev );
|
||||||
|
|
||||||
io->bufev = bufferevent_new( io->socket,
|
io->bufev = bufferevent_new( io->socket,
|
||||||
canReadWrapper, NULL, gotErrorWrapper,
|
canReadWrapper,
|
||||||
|
didWriteWrapper,
|
||||||
|
gotErrorWrapper,
|
||||||
io );
|
io );
|
||||||
bufferevent_settimeout( io->bufev, io->timeout, io->timeout );
|
bufferevent_settimeout( io->bufev, io->timeout, io->timeout );
|
||||||
bufferevent_enable( io->bufev, EV_READ|EV_WRITE );
|
bufferevent_enable( io->bufev, EV_READ|EV_WRITE );
|
||||||
|
|
|
@ -99,10 +99,12 @@ const uint8_t*
|
||||||
|
|
||||||
typedef enum { READ_MORE, READ_AGAIN, READ_DONE } ReadState;
|
typedef enum { READ_MORE, READ_AGAIN, READ_DONE } ReadState;
|
||||||
typedef ReadState (*tr_can_read_cb)(struct bufferevent*, void* user_data);
|
typedef ReadState (*tr_can_read_cb)(struct bufferevent*, void* user_data);
|
||||||
|
typedef void (*tr_did_write_cb)(struct bufferevent *, void *);
|
||||||
typedef void (*tr_net_error_cb)(struct bufferevent *, short what, void *);
|
typedef void (*tr_net_error_cb)(struct bufferevent *, short what, void *);
|
||||||
|
|
||||||
void tr_peerIoSetIOFuncs( tr_peerIo * io,
|
void tr_peerIoSetIOFuncs( tr_peerIo * io,
|
||||||
tr_can_read_cb readcb,
|
tr_can_read_cb readcb,
|
||||||
|
tr_did_write_cb writecb,
|
||||||
tr_net_error_cb errcb,
|
tr_net_error_cb errcb,
|
||||||
void * user_data );
|
void * user_data );
|
||||||
|
|
||||||
|
|
|
@ -1410,6 +1410,12 @@ clientGotBlock( tr_peermsgs * msgs,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
didWrite( struct bufferevent * evin UNUSED, void * vmsgs )
|
||||||
|
{
|
||||||
|
pulse( vmsgs );
|
||||||
|
}
|
||||||
|
|
||||||
static ReadState
|
static ReadState
|
||||||
canRead( struct bufferevent * evin, void * vmsgs )
|
canRead( struct bufferevent * evin, void * vmsgs )
|
||||||
{
|
{
|
||||||
|
@ -1843,7 +1849,7 @@ tr_peerMsgsNew( struct tr_torrent * torrent,
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_peerIoSetTimeoutSecs( m->io, 150 ); /* timeout after N seconds of inactivity */
|
tr_peerIoSetTimeoutSecs( m->io, 150 ); /* timeout after N seconds of inactivity */
|
||||||
tr_peerIoSetIOFuncs( m->io, canRead, gotError, m );
|
tr_peerIoSetIOFuncs( m->io, canRead, didWrite, gotError, m );
|
||||||
ratePulse( m );
|
ratePulse( m );
|
||||||
|
|
||||||
if ( tr_peerIoSupportsLTEP( m->io ) )
|
if ( tr_peerIoSupportsLTEP( m->io ) )
|
||||||
|
|
Loading…
Add table
Reference in a new issue