From: Martin Schwenke Date: Mon, 27 Aug 2018 04:44:24 +0000 (+1000) Subject: ctdb-daemon: Open eventd pipe earlier X-Git-Tag: tdb-1.3.17~1985 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c446ae5e1382d5e32c33ce92243daf6b4338e15a;p=thirdparty%2Fsamba.git ctdb-daemon: Open eventd pipe earlier The pipe will soon be needed earlier, so initialise it earlier. Ensure the file descriptors are closed on error. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13592 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index 403e10432b2..cf4f7f6860b 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -143,8 +143,15 @@ int ctdb_start_eventd(struct ctdb_context *ctdb) return -1; } + ret = pipe(fd); + if (ret != 0) { + return -1; + } + argv = talloc_array(ectx, const char *, 4); if (argv == NULL) { + close(fd[0]); + close(fd[1]); return -1; } @@ -154,6 +161,8 @@ int ctdb_start_eventd(struct ctdb_context *ctdb) argv[3] = NULL; if (argv[2] == NULL) { + close(fd[0]); + close(fd[1]); talloc_free(argv); return -1; } @@ -161,11 +170,6 @@ int ctdb_start_eventd(struct ctdb_context *ctdb) DEBUG(DEBUG_NOTICE, ("Starting event daemon %s %s %s\n", argv[0], argv[1], argv[2])); - ret = pipe(fd); - if (ret != 0) { - return -1; - } - pid = ctdb_fork(ctdb); if (pid == -1) { close(fd[0]);