Passing it in as a parameter seems more logical.
---
daemons/ganeti-masterd | 3 ++-
lib/constants.py | 2 --
lib/daemon.py | 9 ++++++---
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/daemons/ganeti-masterd b/daemons/ganeti-masterd
index 3a77be4..392bfac 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 d2ad24d..b4d82f8 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 24f567f..605a4a3 100644
--- a/lib/daemon.py
+++ b/lib/daemon.py
@@ -222,7 +222,7 @@ class Mainloop(object):
def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn,
- default_port=None):
+ multithreaded=False, default_port=None):
"""Shared main function for daemons.
@type daemon_name: string
@@ -238,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
@type default_port: int
@param default_port: Default network port
@@ -270,7 +272,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()
@@ -297,7 +300,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:
--
1.6.4.3