From 79a7cc3fb976c88a57099fdae239ddd217bcc968 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 24 Jun 2019 14:02:53 +1000 Subject: ctdb-daemon: Drop unused function ctdb_vfork_with_logging() Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/server/ctdb_logging.c | 96 ---------------------------------------------- 1 file changed, 96 deletions(-) (limited to 'ctdb/server') diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c index e7ca9b2758d..8af787c189f 100644 --- a/ctdb/server/ctdb_logging.c +++ b/ctdb/server/ctdb_logging.c @@ -132,102 +132,6 @@ static void ctdb_child_log_handler(struct tevent_context *ev, } } -static int log_context_destructor(struct ctdb_log_state *log) -{ - /* Flush buffer in case it wasn't \n-terminated. */ - if (log->buf_used > 0) { - write_to_log(log, log->buf, log->buf_used); - } - return 0; -} - -/* - * vfork + exec, redirecting child output to logging and specified callback. - */ -struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx, - struct ctdb_context *ctdb, - const char *log_prefix, - const char *helper, - int helper_argc, - const char **helper_argv, - void (*logfn)(const char *, uint16_t, void *), - void *logfn_private, pid_t *pid) -{ - int p[2]; - struct ctdb_log_state *log; - struct tevent_fd *fde; - char **argv; - int i; - struct timeval before; - double delta_t; - - log = talloc_zero(mem_ctx, struct ctdb_log_state); - CTDB_NO_MEMORY_NULL(ctdb, log); - - log->prefix = log_prefix; - log->logfn = logfn; - log->logfn_private = logfn_private; - - if (pipe(p) != 0) { - DEBUG(DEBUG_ERR, (__location__ " Failed to setup pipe for child logging:" - " %s\n", strerror(errno))); - goto free_log; - } - - argv = talloc_array(mem_ctx, char *, helper_argc + 2); - if (argv == NULL) { - DEBUG(DEBUG_ERR, (__location__ "Failed to allocate memory for helper\n")); - goto free_log; - } - argv[0] = discard_const(helper); - argv[1] = talloc_asprintf(argv, "%d", p[1]); - if (argv[1] == NULL) { - DEBUG(DEBUG_ERR, (__location__ "Failed to allocate memory for helper\n")); - talloc_free(argv); - goto free_log; - } - - for (i=0; i 3.0) { - DEBUG(DEBUG_WARNING, ("vfork() took %lf seconds\n", delta_t)); - } - - ctdb_track_child(ctdb, *pid); - - log->pfd = p[0]; - set_close_on_exec(log->pfd); - talloc_set_destructor(log, log_context_destructor); - fde = tevent_add_fd(ctdb->ev, log, log->pfd, TEVENT_FD_READ, - ctdb_child_log_handler, log); - tevent_fd_set_auto_close(fde); - - return log; - -free_log: - talloc_free(log); - return NULL; -} - - /* setup for logging of child process stdout */ -- cgit v1.2.1