s3: Move call to prctl_set_comment to reinit_after_fork
authorChristof Schmitt <cs@samba.org>
Wed, 23 Sep 2015 18:14:05 +0000 (11:14 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 24 Sep 2015 06:00:16 +0000 (08:00 +0200)
This save a few lines of code.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
18 files changed:
source3/include/proto.h
source3/lib/background.c
source3/lib/util.c
source3/nmbd/asyncdns.c
source3/nmbd/nmbd.c
source3/printing/print_cups.c
source3/printing/queue_process.c
source3/printing/spoolssd.c
source3/rpc_server/epmd.c
source3/rpc_server/fssd.c
source3/rpc_server/lsasd.c
source3/rpc_server/mdssd.c
source3/smbd/process.c
source3/smbd/scavenger.c
source3/smbd/server.c
source3/smbd/server_exit.c
source3/winbindd/winbindd.c
source3/winbindd/winbindd_dual.c

index 0af8cdd..5b63897 100644 (file)
@@ -376,10 +376,12 @@ int set_blocking(int fd, bool set);
 NTSTATUS init_before_fork(void);
 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
                           struct tevent_context *ev_ctx,
-                          bool parent_longlived);
+                          bool parent_longlived,
+                          const char *comment);
 NTSTATUS smbd_reinit_after_fork(struct messaging_context *msg_ctx,
                                struct tevent_context *ev_ctx,
-                               bool parent_longlived);
+                               bool parent_longlived,
+                               const char *comment);
 void *malloc_(size_t size);
 void *Realloc(void *p, size_t size, bool free_old_on_error);
 void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size,
index 4ea1282..3c8eb58 100644 (file)
@@ -176,7 +176,7 @@ static void background_job_waited(struct tevent_req *subreq)
 
                close(fds[0]);
 
-               status = reinit_after_fork(state->msg, state->ev, true);
+               status = reinit_after_fork(state->msg, state->ev, true, NULL);
                if (NT_STATUS_IS_OK(status)) {
                        res = state->fn(state->private_data);
                } else {
index d38d53a..2ac4dbd 100644 (file)
@@ -32,6 +32,7 @@
 #include "serverid.h"
 #include "lib/sys_rw.h"
 #include "lib/sys_rw_data.h"
+#include "lib/util/util_process.h"
 
 #ifdef HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
@@ -430,7 +431,8 @@ static void reinit_after_fork_pipe_handler(struct tevent_context *ev,
 
 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
                           struct tevent_context *ev_ctx,
-                          bool parent_longlived)
+                          bool parent_longlived,
+                          const char *comment)
 {
        NTSTATUS status = NT_STATUS_OK;
 
@@ -481,6 +483,11 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
                                 nt_errstr(status)));
                }
        }
+
+       if (comment) {
+               prctl_set_comment(comment);
+       }
+
  done:
        return status;
 }
index 5973c8e..66e3674 100644 (file)
@@ -167,7 +167,7 @@ void start_async_dns(struct messaging_context *msg)
        CatchSignal(SIGHUP, SIG_IGN);
         CatchSignal(SIGTERM, sig_term);
 
-       status = reinit_after_fork(msg, nmbd_event_context(), true);
+       status = reinit_after_fork(msg, nmbd_event_context(), true, NULL);
 
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
index c7e72de..14eaef6 100644 (file)
@@ -988,8 +988,7 @@ static bool open_sockets(bool isdaemon, int port)
 
        pidfile_create(lp_pid_directory(), "nmbd");
 
-       status = reinit_after_fork(msg, nmbd_event_context(),
-                                  false);
+       status = reinit_after_fork(msg, nmbd_event_context(), false, NULL);
 
        if (!NT_STATUS_IS_OK(status)) {
                exit_daemon("reinit_after_fork() failed", map_errno_from_nt_status(status));
index 3ebb2e6..110711c 100644 (file)
@@ -475,7 +475,7 @@ static bool cups_pcap_load_async(struct tevent_context *ev,
 
        close_all_print_db();
 
-       status = reinit_after_fork(msg_ctx, ev, true);
+       status = reinit_after_fork(msg_ctx, ev, true, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("cups_pcap_load_async: reinit_after_fork() failed\n"));
                smb_panic("cups_pcap_load_async: reinit_after_fork() failed");
index 50622dc..6e31ee4 100644 (file)
@@ -373,15 +373,13 @@ pid_t start_background_queue(struct tevent_context *ev,
                close(pause_pipe[0]);
                pause_pipe[0] = -1;
 
-               status = smbd_reinit_after_fork(msg_ctx, ev, true);
+               status = smbd_reinit_after_fork(msg_ctx, ev, true, "lpqd");
 
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("reinit_after_fork() failed\n"));
                        smb_panic("reinit_after_fork() failed");
                }
 
-               prctl_set_comment("lpqd");
-
                bq_reopen_logs(logfile);
                bq_setup_sig_term_handler();
                bq_setup_sig_hup_handler(ev, msg_ctx);
index 9f533b3..51d10b6 100644 (file)
@@ -20,8 +20,6 @@
 #include "serverid.h"
 #include "smbd/smbd.h"
 
-#include "lib/util/util_process.h"
-
 #include "messages.h"
 #include "include/printing.h"
 #include "printing/nt_printing_migrate_internal.h"
@@ -268,15 +266,12 @@ static bool spoolss_child_init(struct tevent_context *ev_ctx,
        struct messaging_context *msg_ctx = server_messaging_context();
        bool ok;
 
-       status = reinit_after_fork(msg_ctx, ev_ctx,
-                                  true);
+       status = reinit_after_fork(msg_ctx, ev_ctx, true, "spoolssd-child");
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                smb_panic("reinit_after_fork() failed");
        }
 
-       prctl_set_comment("spoolssd-child");
-
        spoolss_child_id = child_id;
        spoolss_reopen_logs(child_id);
 
@@ -645,14 +640,13 @@ pid_t start_spoolssd(struct tevent_context *ev_ctx,
                return pid;
        }
 
-       status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true);
+       status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true,
+                                       "spoolssd-master");
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                smb_panic("reinit_after_fork() failed");
        }
 
-       prctl_set_comment("spoolssd-master");
-
        /* save the parent process id so the children can use it later */
        parent_id = messaging_server_id(msg_ctx);
 
index f87edd8..faf60f5 100644 (file)
@@ -25,8 +25,6 @@
 #include "ntdomain.h"
 #include "messages.h"
 
-#include "lib/util/util_process.h"
-
 #include "librpc/rpc/dcerpc_ep.h"
 #include "../librpc/gen_ndr/srv_epmapper.h"
 #include "rpc_server/rpc_server.h"
@@ -162,14 +160,12 @@ void start_epmd(struct tevent_context *ev_ctx,
                return;
        }
 
-       status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true);
+       status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true, "epmd");
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                smb_panic("reinit_after_fork() failed");
        }
 
-       prctl_set_comment("epmd");
-
        epmd_reopen_logs();
 
        epmd_setup_sig_term_handler(ev_ctx);
index 81c65a6..1e96afe 100644 (file)
@@ -171,7 +171,7 @@ void start_fssd(struct tevent_context *ev_ctx,
        }
 
        /* child */
-       status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true);
+       status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                smb_panic("reinit_after_fork() failed");
index 6fd0817..8cd89a9 100644 (file)
@@ -24,8 +24,6 @@
 #include "messages.h"
 #include "ntdomain.h"
 
-#include "lib/util/util_process.h"
-
 #include "lib/id_cache.h"
 
 #include "../lib/tsocket/tsocket.h"
@@ -249,14 +247,12 @@ static bool lsasd_child_init(struct tevent_context *ev_ctx,
        bool ok;
 
        status = reinit_after_fork(msg_ctx, ev_ctx,
-                                  true);
+                                  true, "lsasd-child");
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                smb_panic("reinit_after_fork() failed");
        }
 
-       prctl_set_comment("lsasd-child");
-
        lsasd_child_id = child_id;
        lsasd_reopen_logs(child_id);
 
@@ -861,14 +857,12 @@ void start_lsasd(struct tevent_context *ev_ctx,
                return;
        }
 
-       status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true);
+       status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true, "lsasd-master");
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                smb_panic("reinit_after_fork() failed");
        }
 
-       prctl_set_comment("lsasd-master");
-
        /* save the parent process id so the children can use it later */
        parent_id = messaging_server_id(msg_ctx);
 
index fac386b..f76d13e 100644 (file)
@@ -24,8 +24,6 @@
 #include "messages.h"
 #include "ntdomain.h"
 
-#include "lib/util/util_process.h"
-
 #include "lib/id_cache.h"
 
 #include "../lib/tsocket/tsocket.h"
@@ -206,14 +204,12 @@ static bool mdssd_child_init(struct tevent_context *ev_ctx,
        bool ok;
 
        status = reinit_after_fork(msg_ctx, ev_ctx,
-                                  true);
+                                  true, "mdssd-child");
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                smb_panic("reinit_after_fork() failed");
        }
 
-       prctl_set_comment("mdssd-child");
-
        mdssd_child_id = child_id;
        reopen_logs();
 
@@ -671,15 +667,12 @@ void start_mdssd(struct tevent_context *ev_ctx,
                return;
        }
 
-       status = reinit_after_fork(msg_ctx,
-                                  ev_ctx,
-                                  true);
+       status = reinit_after_fork(msg_ctx, ev_ctx, true, "mdssd-master");
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                smb_panic("reinit_after_fork() failed");
        }
 
-       prctl_set_comment("mdssd-master");
        reopen_logs();
 
        /* save the parent process id so the children can use it later */
index 6c8a31c..677e1df 100644 (file)
@@ -3319,7 +3319,8 @@ bool fork_echo_handler(struct smbXsrv_connection *xconn)
                close(listener_pipe[0]);
                set_blocking(listener_pipe[1], false);
 
-               status = smbd_reinit_after_fork(xconn->msg_ctx, xconn->ev_ctx, true);
+               status = smbd_reinit_after_fork(xconn->msg_ctx, xconn->ev_ctx,
+                                               true, NULL);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(1, ("reinit_after_fork failed: %s\n",
                                  nt_errstr(status)));
index 6989466..baf71d8 100644 (file)
@@ -254,7 +254,8 @@ static bool smbd_scavenger_start(struct smbd_scavenger_state *state)
 
                set_my_unique_id(unique_id);
 
-               status = smbd_reinit_after_fork(state->msg, state->ev, true);
+               status = smbd_reinit_after_fork(state->msg, state->ev,
+                                               true, "smbd-scavenger");
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(2, ("reinit_after_fork failed: %s\n",
                                  nt_errstr(status)));
@@ -262,8 +263,6 @@ static bool smbd_scavenger_start(struct smbd_scavenger_state *state)
                        return false;
                }
 
-               prctl_set_comment("smbd-scavenger");
-
                state->am_scavenger = true;
                *state->scavenger_id = messaging_server_id(state->msg);
 
index 8c77500..23ec168 100644 (file)
@@ -389,7 +389,7 @@ static bool smbd_notifyd_init(struct messaging_context *msg, bool interactive)
                return true;
        }
 
-       status = reinit_after_fork(msg, ev, true);
+       status = reinit_after_fork(msg, ev, true, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("%s: reinit_after_fork failed: %s\n",
                          __func__, nt_errstr(status)));
@@ -588,7 +588,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
        }
 
        if (s->parent->interactive) {
-               reinit_after_fork(msg_ctx, ev, true);
+               reinit_after_fork(msg_ctx, ev, true, NULL);
                smbd_process(ev, msg_ctx, fd, true);
                exit_server_cleanly("end of interactive mode");
                return;
@@ -622,7 +622,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
                 * them, counting worker smbds. */
                CatchChild();
 
-               status = smbd_reinit_after_fork(msg_ctx, ev, true);
+               status = smbd_reinit_after_fork(msg_ctx, ev, true, NULL);
                if (!NT_STATUS_IS_OK(status)) {
                        if (NT_STATUS_EQUAL(status,
                                            NT_STATUS_TOO_MANY_OPENED_FILES)) {
@@ -1383,9 +1383,7 @@ extern void build_options(bool screen);
        if (is_daemon)
                pidfile_create(lp_pid_directory(), "smbd");
 
-       status = reinit_after_fork(msg_ctx,
-                                  ev_ctx,
-                                  false);
+       status = reinit_after_fork(msg_ctx, ev_ctx, false, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                exit_daemon("reinit_after_fork() failed", map_errno_from_nt_status(status));
        }
index 700f595..7f1bbbd 100644 (file)
@@ -275,8 +275,8 @@ void smbd_exit_server_cleanly(const char *const explanation)
  */
 NTSTATUS smbd_reinit_after_fork(struct messaging_context *msg_ctx,
                                struct tevent_context *ev_ctx,
-                               bool parent_longlived)
+                               bool parent_longlived, const char *comment)
 {
        am_parent = NULL;
-       return reinit_after_fork(msg_ctx, ev_ctx, parent_longlived);
+       return reinit_after_fork(msg_ctx, ev_ctx, parent_longlived, comment);
 }
index c878ce2..e6dd0e7 100644 (file)
@@ -1754,7 +1754,7 @@ int main(int argc, const char **argv)
 
        status = reinit_after_fork(winbind_messaging_context(),
                                   winbind_event_context(),
-                                  false);
+                                  false, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                exit_daemon("Winbindd reinit_after_fork() failed", map_errno_from_nt_status(status));
        }
index 350ec7d..213462e 100644 (file)
@@ -1254,7 +1254,7 @@ NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself,
        status = reinit_after_fork(
                winbind_messaging_context(),
                winbind_event_context(),
-               true);
+               true, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                return status;