Revision 30dabd03

b/daemons/ganeti-masterd
602 602
          (constants.SOCKET_DIR, constants.SOCKET_DIR_MODE),
603 603
         ]
604 604
  daemon.GenericMain(constants.MASTERD, parser, dirs,
605
                     CheckMasterd, ExecMasterd)
605
                     CheckMasterd, ExecMasterd,
606
                     multithreaded=True)
606 607

  
607 608

  
608 609
if __name__ == "__main__":
b/lib/constants.py
118 118
RAPI = "ganeti-rapi"
119 119
MASTERD = "ganeti-masterd"
120 120

  
121
MULTITHREADED_DAEMONS = frozenset([MASTERD])
122

  
123 121
DAEMONS_SSL = {
124 122
  # daemon-name: (default-cert-path, default-key-path)
125 123
  NODED: (SSL_CERT_FILE, SSL_CERT_FILE),
b/lib/daemon.py
221 221
    self._signal_wait.append(owner)
222 222

  
223 223

  
224
def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn):
224
def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn,
225
                multithreaded=False):
225 226
  """Shared main function for daemons.
226 227

  
227 228
  @type daemon_name: string
......
237 238
  @type exec_fn: function which accepts (options, args)
238 239
  @param exec_fn: function that's executed with the daemon's pid file held, and
239 240
                  runs the daemon itself.
241
  @type multithreaded: bool
242
  @param multithreaded: Whether the daemon uses threads
240 243

  
241 244
  """
242 245
  optionparser.add_option("-f", "--foreground", dest="fork",
......
271 274
                            help="SSL certificate",
272 275
                            default=default_cert, type="string")
273 276

  
274
  multithread = utils.no_fork = daemon_name in constants.MULTITHREADED_DAEMONS
277
  # Disable the use of fork(2) if the daemon uses threads
278
  utils.no_fork = multithreaded
275 279

  
276 280
  options, args = optionparser.parse_args()
277 281

  
......
298 302
    utils.SetupLogging(logfile=constants.DAEMONS_LOGFILES[daemon_name],
299 303
                       debug=options.debug,
300 304
                       stderr_logging=not options.fork,
301
                       multithreaded=multithread)
305
                       multithreaded=multithreaded)
302 306
    logging.info("%s daemon startup", daemon_name)
303 307
    exec_fn(options, args)
304 308
  finally:

Also available in: Unified diff