diff --git a/daemons/ganeti-masterd b/daemons/ganeti-masterd index 3a77be41c38159d7a3d88c14ded349e03d11c711..392bfac874ee79b5d8caaadcf4baf89242f338c0 100755 --- a/daemons/ganeti-masterd +++ b/daemons/ganeti-masterd @@ -602,7 +602,8 @@ def main(): (constants.SOCKET_DIR, constants.SOCKET_DIR_MODE), ] daemon.GenericMain(constants.MASTERD, parser, dirs, - CheckMasterd, ExecMasterd) + CheckMasterd, ExecMasterd, + multithreaded=True) if __name__ == "__main__": diff --git a/lib/constants.py b/lib/constants.py index d2ad24d7c6f432fb0a33dc1fbe97c61e4c294bf3..b4d82f8633d2d25ba5822661ad5538f969d37561 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -118,8 +118,6 @@ CONFD = "ganeti-confd" RAPI = "ganeti-rapi" MASTERD = "ganeti-masterd" -MULTITHREADED_DAEMONS = frozenset([MASTERD]) - DAEMONS_SSL = { # daemon-name: (default-cert-path, default-key-path) NODED: (SSL_CERT_FILE, SSL_CERT_FILE), diff --git a/lib/daemon.py b/lib/daemon.py index 6818d7d389362ec4470790e71f00c62637925978..569b84d74405faa87c2a87e91685e6fb89ce87b5 100644 --- a/lib/daemon.py +++ b/lib/daemon.py @@ -221,7 +221,8 @@ class Mainloop(object): self._signal_wait.append(owner) -def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn): +def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn, + multithreaded=False): """Shared main function for daemons. @type daemon_name: string @@ -237,6 +238,8 @@ def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn): @type exec_fn: function which accepts (options, args) @param exec_fn: function that's executed with the daemon's pid file held, and runs the daemon itself. + @type multithreaded: bool + @param multithreaded: Whether the daemon uses threads """ optionparser.add_option("-f", "--foreground", dest="fork", @@ -271,7 +274,8 @@ def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn): help="SSL certificate", default=default_cert, type="string") - multithread = utils.no_fork = daemon_name in constants.MULTITHREADED_DAEMONS + # Disable the use of fork(2) if the daemon uses threads + utils.no_fork = multithreaded options, args = optionparser.parse_args() @@ -298,7 +302,7 @@ def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn): utils.SetupLogging(logfile=constants.DAEMONS_LOGFILES[daemon_name], debug=options.debug, stderr_logging=not options.fork, - multithreaded=multithread) + multithreaded=multithreaded) logging.info("%s daemon startup", daemon_name) exec_fn(options, args) finally: