1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-27 01:57:52 +00:00

(trunk libT) possible fix for the `few peers' errors reported on OS X. denis_, merlyn3d, give this a spin...

This commit is contained in:
Charles Kerr 2009-01-19 13:55:41 +00:00
parent b484b77b90
commit 69f59b423a
2 changed files with 17 additions and 4 deletions

View file

@ -190,6 +190,8 @@ event_read_cb( int fd, short event UNUSED, void * vio )
assert( tr_isPeerIo( io ) ); assert( tr_isPeerIo( io ) );
io->hasFinishedConnecting = TRUE;
curlen = EVBUFFER_LENGTH( io->inbuf ); curlen = EVBUFFER_LENGTH( io->inbuf );
howmuch = curlen >= max ? 0 : max - curlen; howmuch = curlen >= max ? 0 : max - curlen;
howmuch = tr_bandwidthClamp( &io->bandwidth, TR_DOWN, howmuch ); howmuch = tr_bandwidthClamp( &io->bandwidth, TR_DOWN, howmuch );
@ -270,6 +272,8 @@ event_write_cb( int fd, short event UNUSED, void * vio )
assert( tr_isPeerIo( io ) ); assert( tr_isPeerIo( io ) );
io->hasFinishedConnecting = TRUE;
dbgmsg( io, "libevent says this peer is ready to write" ); dbgmsg( io, "libevent says this peer is ready to write" );
/* Write as much as possible, since the socket is non-blocking, write() will /* Write as much as possible, since the socket is non-blocking, write() will
@ -352,6 +356,7 @@ tr_peerIoNew( tr_session * session,
io->port = port; io->port = port;
io->socket = socket; io->socket = socket;
io->isIncoming = isIncoming != 0; io->isIncoming = isIncoming != 0;
io->hasFinishedConnecting = FALSE;
io->timeCreated = time( NULL ); io->timeCreated = time( NULL );
io->inbuf = evbuffer_new( ); io->inbuf = evbuffer_new( );
io->outbuf = evbuffer_new( ); io->outbuf = evbuffer_new( );
@ -821,10 +826,13 @@ tr_peerIoFlush( tr_peerIo * io, tr_direction dir, size_t limit )
assert( tr_isPeerIo( io ) ); assert( tr_isPeerIo( io ) );
assert( tr_isDirection( dir ) ); assert( tr_isDirection( dir ) );
if( io->hasFinishedConnecting )
{
if( dir == TR_DOWN ) if( dir == TR_DOWN )
bytesUsed = tr_peerIoTryRead( io, limit ); bytesUsed = tr_peerIoTryRead( io, limit );
else else
bytesUsed = tr_peerIoTryWrite( io, limit ); bytesUsed = tr_peerIoTryWrite( io, limit );
}
dbgmsg( io, "flushing peer-io, direction %d, limit %zu, bytesUsed %zd", (int)dir, limit, bytesUsed ); dbgmsg( io, "flushing peer-io, direction %d, limit %zu, bytesUsed %zd", (int)dir, limit, bytesUsed );
return bytesUsed; return bytesUsed;

View file

@ -64,6 +64,11 @@ typedef struct tr_peerIo
tr_bool extendedProtocolSupported; tr_bool extendedProtocolSupported;
tr_bool fastExtensionSupported; tr_bool fastExtensionSupported;
/* we create the socket in a nonblocking way, so this flag is initially
* false and then set to true when libevent says that the socket is ready
* for reading or writing */
tr_bool hasFinishedConnecting;
int magicNumber; int magicNumber;
uint8_t encryptionMode; uint8_t encryptionMode;