Fixed potential EPOLL hang on interface failure

This commit is contained in:
Mark Qvist 2025-07-13 19:16:51 +02:00
parent c0d7f42f17
commit fad1d4972c
2 changed files with 11 additions and 5 deletions

View file

@ -588,9 +588,7 @@ class BackboneClientInterface(Interface):
self.teardown() self.teardown()
break break
try: try: self.connect()
self.connect()
except Exception as e: except Exception as e:
RNS.log("Connection attempt for "+str(self)+" failed: "+str(e), RNS.LOG_DEBUG) RNS.log("Connection attempt for "+str(self)+" failed: "+str(e), RNS.LOG_DEBUG)
@ -648,7 +646,8 @@ class BackboneClientInterface(Interface):
self.online = False self.online = False
if self.initiator and not self.detached: if self.initiator and not self.detached:
RNS.log("The socket for "+str(self)+" was closed, attempting to reconnect...", RNS.LOG_WARNING) RNS.log("The socket for "+str(self)+" was closed, attempting to reconnect...", RNS.LOG_WARNING)
self.reconnect() def job(): self.reconnect()
threading.Thread(target=job, daemon=True).start()
else: else:
RNS.log("The socket for remote client "+str(self)+" was closed.", RNS.LOG_VERBOSE) RNS.log("The socket for remote client "+str(self)+" was closed.", RNS.LOG_VERBOSE)
self.teardown() self.teardown()
@ -659,7 +658,8 @@ class BackboneClientInterface(Interface):
if self.initiator: if self.initiator:
RNS.log("Attempting to reconnect...", RNS.LOG_WARNING) RNS.log("Attempting to reconnect...", RNS.LOG_WARNING)
self.reconnect() def job(): self.reconnect()
threading.Thread(target=job, daemon=True).start()
else: else:
self.teardown() self.teardown()

View file

@ -254,6 +254,9 @@ class LocalClientInterface(Interface):
if self.is_connected_to_shared_instance and not self.detached: if self.is_connected_to_shared_instance and not self.detached:
RNS.log("Socket for "+str(self)+" was closed, attempting to reconnect...", RNS.LOG_WARNING) RNS.log("Socket for "+str(self)+" was closed, attempting to reconnect...", RNS.LOG_WARNING)
RNS.Transport.shared_connection_disappeared() RNS.Transport.shared_connection_disappeared()
# TODO: Potentially run this in a thread, but since if we get here,
# there's no other connectivity left to block anyway, it might be
# unnecessary.
self.reconnect() self.reconnect()
else: else:
self.teardown(nowarning=True) self.teardown(nowarning=True)
@ -276,6 +279,9 @@ class LocalClientInterface(Interface):
if self.is_connected_to_shared_instance and not self.detached: if self.is_connected_to_shared_instance and not self.detached:
RNS.log("Socket for "+str(self)+" was closed, attempting to reconnect...", RNS.LOG_WARNING) RNS.log("Socket for "+str(self)+" was closed, attempting to reconnect...", RNS.LOG_WARNING)
RNS.Transport.shared_connection_disappeared() RNS.Transport.shared_connection_disappeared()
# TODO: Potentially run this in a thread, but since if we get here,
# there's no other connectivity left to block anyway, it might be
# unnecessary.
self.reconnect() self.reconnect()
else: else:
self.teardown(nowarning=True) self.teardown(nowarning=True)