From a9849660f61a49642eb8fc04484e1efcae88c5d6 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 10 Oct 2007 02:59:30 +0000 Subject: [PATCH] * fix bug that incorrectly marked some incoming connections for termination * strip unnecessary linefeeds out of some debug messages --- libtransmission/handshake.c | 8 ++++---- libtransmission/peer-mgr.c | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libtransmission/handshake.c b/libtransmission/handshake.c index 0c90820ee..ae12b580d 100644 --- a/libtransmission/handshake.c +++ b/libtransmission/handshake.c @@ -277,7 +277,7 @@ parseHandshake( tr_handshake * handshake, uint8_t reserved[HANDSHAKE_FLAGS_LEN]; uint8_t hash[SHA_DIGEST_LENGTH]; - dbgmsg( handshake, "payload: need %d, got %d\n", (int)HANDSHAKE_SIZE, (int)EVBUFFER_LENGTH(inbuf) ); + dbgmsg( handshake, "payload: need %d, got %d", (int)HANDSHAKE_SIZE, (int)EVBUFFER_LENGTH(inbuf) ); if( EVBUFFER_LENGTH(inbuf) < HANDSHAKE_SIZE ) return READ_MORE; @@ -877,11 +877,11 @@ readIA( tr_handshake * handshake, struct evbuffer * inbuf ) struct evbuffer * outbuf = evbuffer_new( ); uint32_t crypto_select; -dbgmsg( handshake, "zbz reading IA... have %d, need %d", (int)EVBUFFER_LENGTH(inbuf), (int)needlen ); +dbgmsg( handshake, "reading IA... have %d, need %d", (int)EVBUFFER_LENGTH(inbuf), (int)needlen ); if( EVBUFFER_LENGTH(inbuf) < needlen ) return READ_MORE; -dbgmsg( handshake, "zbz reading IA..." ); +dbgmsg( handshake, "reading IA..." ); /* parse the handshake ... */ i = parseHandshake( handshake, inbuf ); dbgmsg( handshake, "parseHandshake returned %d", i ); @@ -907,7 +907,7 @@ dbgmsg( handshake, "sending vc" ); dbgmsg( handshake, "sending crypto_select" ); /* send crypto_select */ { -dbgmsg( handshake, "handshake->crypto_provide is %d\n", (int)handshake->crypto_provide ); +dbgmsg( handshake, "handshake->crypto_provide is %d", (int)handshake->crypto_provide ); if( handshake->crypto_provide & CRYPTO_PROVIDE_CRYPTO ) crypto_select = CRYPTO_PROVIDE_CRYPTO; else if( handshake->allowUnencryptedPeers ) diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 992a290fc..5870ce79b 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -936,6 +936,7 @@ myHandshakeDoneCB( tr_handshake * handshake, peer->port = port; peer->io = io; peer->msgs = tr_peerMsgsNew( t->tor, peer, msgsCallbackFunc, t, &peer->msgsTag ); + atom->time = time( NULL ); } } @@ -1516,7 +1517,7 @@ getWeakConnections( Torrent * t, int * setmeSize ) isWeak = FALSE; else if( peerIsSeed && clientIsSeed ) isWeak = t->tor->pexDisabled || (now-atom->time>=30); - else if( ( now - atom->time ) < LAISSEZ_FAIRE_PERIOD_SECS ) + else if( !atom->time || ( ( now - atom->time ) < LAISSEZ_FAIRE_PERIOD_SECS ) ) isWeak = FALSE; else isWeak = ( now - peer->pieceDataActivityDate ) > 180;