Improved shared interface reconnection on service restart

This commit is contained in:
Mark Qvist 2023-10-18 23:18:59 +02:00
parent fddf36a920
commit 67c7395ea7
1 changed files with 5 additions and 2 deletions

View File

@ -50,7 +50,7 @@ class ThreadingTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
self.server_address = self.socket.getsockname() self.server_address = self.socket.getsockname()
class LocalClientInterface(Interface): class LocalClientInterface(Interface):
RECONNECT_WAIT = 3 RECONNECT_WAIT = 8
def __init__(self, owner, name, target_port = None, connected_socket=None): def __init__(self, owner, name, target_port = None, connected_socket=None):
super().__init__() super().__init__()
@ -139,7 +139,10 @@ class LocalClientInterface(Interface):
thread = threading.Thread(target=self.read_loop) thread = threading.Thread(target=self.read_loop)
thread.daemon = True thread.daemon = True
thread.start() thread.start()
RNS.Transport.shared_connection_reappeared() def job():
time.sleep(LocalClientInterface.RECONNECT_WAIT+2)
RNS.Transport.shared_connection_reappeared()
threading.Thread(target=job, daemon=True).start()
else: else:
RNS.log("Attempt to reconnect on a non-initiator shared local interface. This should not happen.", RNS.LOG_ERROR) RNS.log("Attempt to reconnect on a non-initiator shared local interface. This should not happen.", RNS.LOG_ERROR)