Cleanup not useful connections after 5 min

This commit is contained in:
HelloZeroNet 2016-04-25 02:24:05 +02:00
parent dbdde65f52
commit e9af4a5f6b

View file

@ -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