Tear down active and pending links before interface detach

This commit is contained in:
Mark Qvist 2026-04-26 11:30:22 +02:00
commit 015692d51e
2 changed files with 16 additions and 10 deletions

View file

@ -1319,11 +1319,11 @@ class Link:
def cancel_outgoing_resource(self, resource):
if resource in self.outgoing_resources: self.outgoing_resources.remove(resource)
else: RNS.log("Attempt to cancel a non-existing outgoing resource", RNS.LOG_ERROR)
else: RNS.log("Attempt to cancel a non-existing outgoing resource", RNS.LOG_WARNING)
def cancel_incoming_resource(self, resource):
if resource in self.incoming_resources: self.incoming_resources.remove(resource)
else: RNS.log("Attempt to cancel a non-existing incoming resource", RNS.LOG_ERROR)
else: RNS.log("Attempt to cancel a non-existing incoming resource", RNS.LOG_WARNING)
def ready_for_new_resource(self):
if len(self.outgoing_resources) > 0: return False

View file

@ -2998,25 +2998,31 @@ 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)
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)
detachable_interfaces = []
for interface in Transport.interfaces:
# Currently no rules are being applied
# here, and all interfaces will be sent
# the detach call on RNS teardown.
if not interface.detached:
detachable_interfaces.append(interface)
else:
pass
if not interface.detached: detachable_interfaces.append(interface)
else: pass
for interface in Transport.local_client_interfaces:
# Currently no rules are being applied
# here, and all interfaces will be sent
# the detach call on RNS teardown.
if not interface.detached:
detachable_interfaces.append(interface)
else:
pass
if not interface.detached: detachable_interfaces.append(interface)
else: pass
shared_instance_master = None
local_interfaces = []