mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-06-08 14:11:53 -07:00
Improved link teardown on SIGINT/SIGTERM
This commit is contained in:
+2
-4
@@ -186,13 +186,11 @@ class Reticulum:
|
||||
# out cleanup operations.
|
||||
if not Reticulum.__exit_handler_ran:
|
||||
Reticulum.__exit_handler_ran = True
|
||||
if not Reticulum.__interface_detach_ran:
|
||||
RNS.Transport.detach_interfaces()
|
||||
if not Reticulum.__interface_detach_ran: RNS.Transport.detach_interfaces()
|
||||
RNS.Transport.exit_handler()
|
||||
RNS.Identity.exit_handler()
|
||||
|
||||
if RNS.Profiler.ran():
|
||||
RNS.Profiler.results()
|
||||
if RNS.Profiler.ran(): RNS.Profiler.results()
|
||||
|
||||
RNS.loglevel = -1
|
||||
|
||||
|
||||
+11
-8
@@ -2998,15 +2998,18 @@ class Transport:
|
||||
|
||||
@staticmethod
|
||||
def detach_interfaces():
|
||||
with Transport.active_links_lock:
|
||||
for link in Transport.active_links:
|
||||
try: link.teardown()
|
||||
except Exception as e: RNS.log(f"Could not tear down active link before interface detach: {e}", RNS.LOG_WARNING)
|
||||
closed_links = 0
|
||||
for link in Transport.active_links.copy():
|
||||
try: link.teardown(); closed_links += 1
|
||||
except Exception as e: RNS.log(f"Could not tear down active link before interface detach: {e}", RNS.LOG_WARNING)
|
||||
|
||||
with Transport.pending_links_lock:
|
||||
for link in Transport.pending_links:
|
||||
try: link.teardown()
|
||||
except Exception as e: RNS.log(f"Could not tear down pending link before interface detach: {e}", RNS.LOG_WARNING)
|
||||
for link in Transport.pending_links.copy():
|
||||
try: link.teardown(); closed_links += 1
|
||||
except Exception as e: RNS.log(f"Could not tear down pending link before interface detach: {e}", RNS.LOG_WARNING)
|
||||
|
||||
# Provide a 150ms window to allow link teardown
|
||||
# packets to leave local transport
|
||||
if closed_links: time.sleep(0.15)
|
||||
|
||||
detachable_interfaces = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user