From 9e1d9ba5095bf84d1498516a75b7dac99936216e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 12 Jan 2010 12:18:23 +0100 Subject: [PATCH] TODO: server: collect the panic action outout for logging metze --- server/ctdb_logging.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/server/ctdb_logging.c b/server/ctdb_logging.c index 7e5367ea..ab7cf597 100644 --- a/server/ctdb_logging.c +++ b/server/ctdb_logging.c @@ -173,6 +173,44 @@ struct ctdb_log_state { /* we need this global to keep the DEBUG() syntax */ static struct ctdb_log_state *log_state; +static int log_pid; + +/* + called when log data comes in from a child process + */ +static void ctdb_log_handler(struct event_context *ev, struct fd_event *fde, + uint16_t flags, void *private); + +static void ctdb_post_panic_logging(void) +{ + if (log_pid != getpid()) { + return; + } + + if (log_state == NULL) { + return; + } + + while (true) { + int ret; + int value = 0; + + ret = ioctl(log_state->pfd, FIONREAD, &value); + if (ret == -1) { + break; + } + + if (ret != 0) { + break; + } + + if (value <= 0) { + break; + } + + ctdb_log_handler(NULL, NULL, EVENT_FD_READ, log_state); + } +} /* syslog logging function @@ -332,6 +370,7 @@ int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_sy ctdb->log->ctdb = ctdb; log_state = ctdb->log; + log_pid = getpid(); if (use_syslog) { do_debug_v = ctdb_syslog_log; @@ -543,6 +582,8 @@ int ctdb_set_child_logging(struct ctdb_context *ctdb) DEBUG(DEBUG_DEBUG, (__location__ " Created PIPE FD:%d for logging\n", p[0])); + post_panic_action_hook = ctdb_post_panic_logging; + return 0; } -- 2.34.1