mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-04-27 14:20:35 +00:00
Improved link teardown on SIGINT/SIGTERM
This commit is contained in:
parent
015692d51e
commit
695d4d8684
2 changed files with 14 additions and 13 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue