From e9af4a5f6ba5ceafdc779c3ce6d80eb2908fc059 Mon Sep 17 00:00:00 2001 From: HelloZeroNet Date: Mon, 25 Apr 2016 02:24:05 +0200 Subject: [PATCH] Cleanup not useful connections after 5 min --- src/Connection/ConnectionServer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Connection/ConnectionServer.py b/src/Connection/ConnectionServer.py index 29482677..95d67105 100644 --- a/src/Connection/ConnectionServer.py +++ b/src/Connection/ConnectionServer.py @@ -192,11 +192,11 @@ class ConnectionServer: elif idle > 20 * 60 and connection.last_send_time < time.time() - 10: # Idle more than 20 min and we have not sent request in last 10 sec - if not connection.ping(): # send ping request + if not connection.ping(): connection.close() elif idle > 10 and connection.incomplete_buff_recv > 0: - # Incompelte data with more than 10 sec idle + # Incomplete data with more than 10 sec idle connection.log("[Cleanup] Connection buff stalled") connection.close() @@ -215,6 +215,10 @@ class ConnectionServer: connection.log("[Cleanup] Too many bad actions: %s" % connection.bad_actions) connection.close() + elif idle > 5*60 and connection.sites == 0: + connection.log("[Cleanup] No site for connection") + connection.close() + elif run_i % 30 == 0: # Reset bad action counter every 30 min connection.bad_actions = 0