diff options
| author | Martin Schwenke <martin@meltin.net> | 2013-04-16 11:11:11 +1000 |
|---|---|---|
| committer | Amitay Isaacs <amitay@gmail.com> | 2013-04-18 13:18:29 +1000 |
| commit | 4ede763f3b673cad17536f495cc8d80f4f014b97 (patch) | |
| tree | dbda6d513fc30394665103c4d4996d9eebe0545d | |
| parent | f07d47a56d68e42bc89ea0ff2879fc7aab3ffdec (diff) | |
util: New functions ctdb_set_child_info() and ctdb_is_child_process()
Must be called by all child processes.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(This used to be ctdb commit 59b019a97aad9a731f9080ea5be14d0dbdfe03d6)
| -rw-r--r-- | ctdb/common/ctdb_fork.c | 22 | ||||
| -rw-r--r-- | ctdb/include/ctdb_private.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/ctdb/common/ctdb_fork.c b/ctdb/common/ctdb_fork.c index 9e3a06d889..7bad969dd2 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 d0c4234dce..80a24253d6 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, |
