From 489e1a5b8339403288a4a88b91ae01cb0092ddca Mon Sep 17 00:00:00 2001
From: Adam Ierymenko <adam.ierymenko@gmail.com>
Date: Tue, 13 Oct 2015 13:51:54 -0700
Subject: [PATCH] Don't keep connections up longer than the alive timeout
 (unless they are relays or roots)

---
 node/Node.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/node/Node.cpp b/node/Node.cpp
index be37b7c7c..d72bc73fd 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -206,8 +206,10 @@ public:
 			}
 		}
 
-		if ((!p->doPingAndKeepalive(RR,_now))&&(stableEndpoint))
-			p->attemptToContactAt(RR,InetAddress(),stableEndpoint,_now);
+		if ((p->alive(_now))||(upstream)) {
+			if ((!p->doPingAndKeepalive(RR,_now))&&(stableEndpoint))
+				p->attemptToContactAt(RR,InetAddress(),stableEndpoint,_now);
+		}
 
 		if (upstream)
 			lastReceiveFromUpstream = std::max(p->lastReceive(),lastReceiveFromUpstream);