From: Anbang Wen Date: Mon, 18 Jun 2018 22:48:22 +0000 (-0700) Subject: Enable fork mode under systemd X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=906b8b82c3935743afa942aa31d9f87403f350bf;p=thirdparty%2Fknot-resolver.git Enable fork mode under systemd Although the sockets are still shared, multiple process mode has the ability to use more CPUs. It should be splitted later. --- diff --git a/daemon/main.c b/daemon/main.c index 5568e3476..cc3d7dfe9 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -416,7 +416,9 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, fd_array_t *ipc_se /* Notify supervisor. */ #ifdef HAS_SYSTEMD - sd_notify(0, "READY=1"); + if (leader) { + sd_notify(0, "READY=1"); + } #endif /* Run event loop */ uv_run(loop, UV_RUN_DEFAULT); @@ -610,14 +612,13 @@ int main(int argc, char **argv) int fd = SD_LISTEN_FDS_START + i; /* when run under systemd supervision, do not use interactive mode */ args.interactive = false; - if (args.forks != 1) { - kr_log_error("[system] when run under systemd-style supervision, " - "use single-process only (bad: --forks=%d).\n", args.forks); - free_sd_socket_names(socket_names, sd_nsocks); - return EXIT_FAILURE; - } + if (!strcasecmp("control",socket_names[i])) { - args.control_fd = fd; + /* only use activated control socket on single + * process mode for now. */ + if (args.forks == 1) { + args.control_fd = fd; + } } else if (!strcasecmp("tls",socket_names[i])) { array_push(args.tls_fd_set, fd); } else {