From 4ede763f3b673cad17536f495cc8d80f4f014b97 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 16 Apr 2013 11:11:11 +1000 Subject: [PATCH] util: New functions ctdb_set_child_info() and ctdb_is_child_process() Must be called by all child processes. Signed-off-by: Martin Schwenke Reviewed-by: Michael Adam (This used to be ctdb commit 59b019a97aad9a731f9080ea5be14d0dbdfe03d6) --- ctdb/common/ctdb_fork.c | 22 ++++++++++++++++++++++ ctdb/include/ctdb_private.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/ctdb/common/ctdb_fork.c b/ctdb/common/ctdb_fork.c index 9e3a06d889c..7bad969dd2c 100644 --- a/ctdb/common/ctdb_fork.c +++ b/ctdb/common/ctdb_fork.c @@ -23,6 +23,28 @@ #include "../include/ctdb_private.h" #include "../common/rb_tree.h" +static bool is_child = false; + +void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt, ...) +{ + is_child = true; + if (child_name_fmt != NULL) { + va_list ap; + char *t; + + va_start(ap, child_name_fmt); + t = talloc_vasprintf(mem_ctx, child_name_fmt, ap); + debug_extra = talloc_asprintf(mem_ctx, "%s:", t); + talloc_free(t); + va_end(ap); + } +} + +bool ctdb_is_child_process(void) +{ + return is_child; +} + /* * This function forks a child process and drops the realtime * scheduler for the child process. diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index d0c4234dce4..80a24253d61 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -1080,6 +1080,8 @@ void ctdb_restore_scheduler(struct ctdb_context *ctdb); struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb); pid_t ctdb_fork(struct ctdb_context *ctdb); pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb); +void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt, ...); +bool ctdb_is_child_process(void); int ctdb_kill(struct ctdb_context *ctdb, pid_t pid, int signum); int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,