ctdb-daemon: Drop unused function ctdb_vfork_with_logging()
authorMartin Schwenke <martin@meltin.net>
Mon, 24 Jun 2019 04:02:53 +0000 (14:02 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 5 Jul 2019 05:03:24 +0000 (05:03 +0000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/include/ctdb_private.h
ctdb/server/ctdb_logging.c

index 7ea7691a36b97aabb4546e95a48549d62491fd38..2bcc7c9415691e752de0ab4afbf93c4521329a24 100644 (file)
@@ -675,16 +675,6 @@ struct lock_request *ctdb_lock_db(TALLOC_CTX *mem_ctx,
 bool ctdb_logging_init(TALLOC_CTX *mem_ctx, const char *logging,
                       const char *debug_level);
 
-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 ctdb_set_child_logging(struct ctdb_context *ctdb);
 
 /* from ctdb_logging_file.c */
index e7ca9b2758d4037050d29438a09f90f857edd124..8af787c189fa47d63cd501bb8ef0fb8cc44931e0 100644 (file)
@@ -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<helper_argc; i++) {
-               argv[i+2] = discard_const(helper_argv[i]);
-       }
-
-       before = timeval_current();
-
-       *pid = vfork();
-       if (*pid == 0) {
-               execv(helper, argv);
-               _exit(1);
-       }
-       close(p[1]);
-
-       if (*pid < 0) {
-               DEBUG(DEBUG_ERR, (__location__ "vfork failed for helper process\n"));
-               close(p[0]);
-               goto free_log;
-       }
-
-       delta_t = timeval_elapsed(&before);
-       if (delta_t > 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
 */