util: New functions ctdb_set_child_info() and ctdb_is_child_process()
authorMartin Schwenke <martin@meltin.net>
Fri, 19 Apr 2013 04:42:44 +0000 (14:42 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 19 Apr 2013 06:27:09 +0000 (16:27 +1000)
Must be called by all child processes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(backported from commit 59b019a97aad9a731f9080ea5be14d0dbdfe03d6)

common/ctdb_util.c
include/ctdb_private.h

index 724233a4cdae9f86fdc5c388a7087f67bed1f329..79439f679d02e59eb706959623bc60351406d04b 100644 (file)
@@ -357,6 +357,28 @@ void ctdb_restore_scheduler(struct ctdb_context *ctdb)
 #endif
 }
 
+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.
index 62c3e0c9334157a044820162c72f828bdcec2578..8ebd718d03c65aa471f3554ce59087b095a5f9b5 100644 (file)
@@ -1035,6 +1035,7 @@ void ctdb_set_scheduler(struct ctdb_context *ctdb);
 void ctdb_restore_scheduler(struct ctdb_context *ctdb);
 pid_t ctdb_fork(struct ctdb_context *ctdb);
 pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb);
+bool ctdb_is_child_process(void);
 int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb, 
                                 struct ctdb_req_control *c,
                                 TDB_DATA indata,