fix a handshake bug and reduce the idle cpu load a little.

This commit is contained in:
Charles Kerr 2007-09-26 02:29:49 +00:00
parent ee6a0b8945
commit b63a505c6d
2 changed files with 4 additions and 3 deletions

View File

@ -749,6 +749,7 @@ readYa( tr_handshake * handshake, struct evbuffer * inbuf )
const uint8_t *myKey, *secret;
int len;
dbgmsg( handshake, "in readYa... need %d, have %d", (int)KEY_LEN, (int)EVBUFFER_LENGTH( inbuf ) );
if( EVBUFFER_LENGTH( inbuf ) < KEY_LEN )
return READ_MORE;
@ -758,6 +759,7 @@ readYa( tr_handshake * handshake, struct evbuffer * inbuf )
memcpy( handshake->mySecret, secret, KEY_LEN );
tr_sha1( handshake->myReq1, "req1", 4, secret, KEY_LEN, NULL );
dbgmsg( handshake, "sending out our pad a" );
/* send our public key to the peer */
walk = outbuf;
myKey = tr_cryptoGetMyPublicKey( handshake->crypto, &len );
@ -768,8 +770,7 @@ readYa( tr_handshake * handshake, struct evbuffer * inbuf )
setReadState( handshake, AWAITING_PAD_A );
tr_peerIoWrite( handshake->io, outbuf, walk-outbuf );
return READ_DONE;
return READ_AGAIN;
}
static int

View File

@ -229,7 +229,7 @@ tr_eventInit( tr_handle * handle )
eh = tr_new0( tr_event_handle, 1 );
eh->lock = tr_lockNew( );
eh->h = handle;
eh->pulseInterval = timevalMsec( 20 );
eh->pulseInterval = timevalMsec( 50 );
eh->thread = tr_threadNew( libeventThreadFunc, eh, "libeventThreadFunc" );
}