From 30dabd03436be299b1daa02f35685d440a69c7ab Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Fri, 27 Nov 2009 17:13:06 +0100 Subject: [PATCH] daemon.GenericMain: Don't use list of multithreaded daemons Passing it in as a parameter seems more logical. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- daemons/ganeti-masterd | 3 ++- lib/constants.py | 2 -- lib/daemon.py | 10 +++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/daemons/ganeti-masterd b/daemons/ganeti-masterd index 3a77be41c..392bfac87 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 d2ad24d7c..b4d82f863 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 6818d7d38..569b84d74 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: -- GitLab