From eba49d3d2a27e7199d7e907c63097edcb7b1b310 Mon Sep 17 00:00:00 2001 From: Eric Petit Date: Fri, 3 Mar 2006 12:53:55 +0000 Subject: [PATCH] Quick fix for the 'getting unconnectable' problem (adds a timeout on incoming connections) --- libtransmission/peer.c | 5 +++++ libtransmission/peer.h | 1 + libtransmission/transmission.c | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/libtransmission/peer.c b/libtransmission/peer.c index 3281e1c27..32aba5219 100644 --- a/libtransmission/peer.c +++ b/libtransmission/peer.c @@ -264,6 +264,11 @@ int tr_peerRead( tr_torrent_t * tor, tr_peer_t * peer ) return 0; } +uint64_t tr_peerDate( tr_peer_t * peer ) +{ + return peer->date; +} + /*********************************************************************** * tr_peerHash *********************************************************************** diff --git a/libtransmission/peer.h b/libtransmission/peer.h index e768027d0..d37e755f1 100644 --- a/libtransmission/peer.h +++ b/libtransmission/peer.h @@ -32,6 +32,7 @@ void tr_peerAttach ( tr_torrent_t *, tr_peer_t * ); void tr_peerDestroy ( tr_fd_t *, tr_peer_t * ); void tr_peerRem ( tr_torrent_t *, int ); int tr_peerRead ( tr_torrent_t *, tr_peer_t * ); +uint64_t tr_peerDate ( tr_peer_t * ); uint8_t * tr_peerHash ( tr_peer_t * ); void tr_peerPulse ( tr_torrent_t * ); int tr_peerIsConnected ( tr_peer_t * ); diff --git a/libtransmission/transmission.c b/libtransmission/transmission.c index 51dc15698..6142ed25a 100644 --- a/libtransmission/transmission.c +++ b/libtransmission/transmission.c @@ -655,6 +655,12 @@ static void acceptLoop( void * _h ) tr_peerDestroy( h->fdlimit, h->acceptPeers[ii] ); goto removePeer; } + if( date1 > tr_peerDate( h->acceptPeers[ii] ) + 10000 ) + { + /* Give them 10 seconds to send the handshake */ + tr_peerDestroy( h->fdlimit, h->acceptPeers[ii] ); + goto removePeer; + } ii++; continue; removePeer: