Improved daemon restart time on systems with many interfaces

This commit is contained in:
Mark Qvist 2025-01-16 17:48:16 +01:00
parent a56d93fc1e
commit ad1e6a41ee
3 changed files with 8 additions and 1 deletions

View File

@ -539,6 +539,7 @@ class TCPServerInterface(Interface):
else: else:
ThreadingTCPServer.allow_reuse_address = True ThreadingTCPServer.allow_reuse_address = True
self.server = ThreadingTCPServer(bind_address, handlerFactory(self.incoming_connection)) self.server = ThreadingTCPServer(bind_address, handlerFactory(self.incoming_connection))
self.server.daemon_threads = True
self.bitrate = TCPServerInterface.BITRATE_GUESS self.bitrate = TCPServerInterface.BITRATE_GUESS
@ -606,13 +607,15 @@ class TCPServerInterface(Interface):
pass pass
def detach(self): def detach(self):
self.detached = True
self.online = False
if self.server != None: if self.server != None:
if hasattr(self.server, "shutdown"): if hasattr(self.server, "shutdown"):
if callable(self.server.shutdown): if callable(self.server.shutdown):
try: try:
RNS.log("Detaching "+str(self), RNS.LOG_DEBUG) RNS.log("Detaching "+str(self), RNS.LOG_DEBUG)
self.server.shutdown() self.server.shutdown()
self.detached = True self.server.server_close()
self.server = None self.server = None
except Exception as e: except Exception as e:

View File

@ -263,6 +263,7 @@ class Reticulum:
RNS.loglevel = self.requested_loglevel RNS.loglevel = self.requested_loglevel
self.is_shared_instance = False self.is_shared_instance = False
self.shared_instance_interface = None
self.require_shared = require_shared_instance self.require_shared = require_shared_instance
self.is_connected_to_shared_instance = False self.is_connected_to_shared_instance = False
self.is_standalone_instance = False self.is_standalone_instance = False
@ -361,6 +362,7 @@ class Reticulum:
else: else:
RNS.Transport.interfaces.append(interface) RNS.Transport.interfaces.append(interface)
self.shared_instance_interface = interface
self.is_shared_instance = True self.is_shared_instance = True
RNS.log("Started shared instance interface: "+str(interface), RNS.LOG_DEBUG) RNS.log("Started shared instance interface: "+str(interface), RNS.LOG_DEBUG)
self.__start_jobs() self.__start_jobs()

View File

@ -42,6 +42,8 @@ def program_setup(configdir, verbosity = 0, quietness = 0, service = False):
if reticulum.is_connected_to_shared_instance: if reticulum.is_connected_to_shared_instance:
RNS.log("Started rnsd version {version} connected to another shared local instance, this is probably NOT what you want!".format(version=__version__), RNS.LOG_WARNING) RNS.log("Started rnsd version {version} connected to another shared local instance, this is probably NOT what you want!".format(version=__version__), RNS.LOG_WARNING)
else: else:
if RNS.Reticulum.get_instance().shared_instance_interface:
RNS.Reticulum.get_instance().shared_instance_interface.server.daemon_threads = True
RNS.log("Started rnsd version {version}".format(version=__version__), RNS.LOG_NOTICE) RNS.log("Started rnsd version {version}".format(version=__version__), RNS.LOG_NOTICE)
while True: while True: