From 1bc2d4015e500fb32c165e33cdab65aacb5e256e Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Fri, 24 Sep 2021 14:14:34 +0200 Subject: [PATCH] Fixed bug in reverse table culling --- RNS/Transport.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/RNS/Transport.py b/RNS/Transport.py index f5ef83c..12a1c27 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -226,7 +226,7 @@ class Transport: - RNS.log("Transport instance "+str(Transport.identity)+" started") + RNS.log("Transport instance "+str(Transport.identity)+" started", RNS.LOG_VERBOSE) # Synthesize tunnels for any interfaces wanting it for interface in Transport.interfaces: @@ -322,10 +322,11 @@ class Transport: if time.time() > Transport.tables_last_culled + Transport.tables_cull_interval: # Cull the reverse table according to timeout + stale_reverse_entries = [] for truncated_packet_hash in Transport.reverse_table: reverse_entry = Transport.reverse_table[truncated_packet_hash] if time.time() > reverse_entry[2] + Transport.REVERSE_TIMEOUT: - Transport.reverse_table.pop(truncated_packet_hash) + stale_reverse_entries.append(truncated_packet_hash) # Cull the link table according to timeout stale_links = [] @@ -378,6 +379,21 @@ class Transport: else: RNS.log("Removed "+str(ti)+" tunnel paths", RNS.LOG_DEBUG) + + + i = 0 + for truncated_packet_hash in stale_reverse_entries: + Transport.reverse_table.pop(truncated_packet_hash) + i += 1 + + if i > 0: + if i == 1: + RNS.log("Dropped "+str(i)+" reverse table entry", RNS.LOG_DEBUG) + else: + RNS.log("Dropped "+str(i)+" reverse table entries", RNS.LOG_DEBUG) + + + i = 0 for link_id in stale_links: Transport.link_table.pop(link_id)