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 0af8cdd9e65c7d8b8a3caec145a22abab238d13d..5b638977bb2f897ed69f56efbccecea7da86b31d 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 4ea128211e7379d383e2371e489dbc9e4117b76c..3c8eb5897cd90bf94dc913b13fb87c481b791550 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 d38d53a5cb8fd7f3234892dabd0e91563d2e554f..2ac4dbddf643fd8dd2c81bc4ea81241c2d67e336 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 5973c8efc06669051a7a4764fe3395bd6d6ca802..66e3674c63a695f7ec69691858fae55433e17d09 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 c7e72de5530aaba9df4aa4947debcce3fd69291f..14eaef647d0c4c46e9eff46f93805bbf506315c6 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 3ebb2e67ab2cf07c8553e6d2fb85edc03a55aa08..110711c40c2db5fed30fd6a24c8094f85985f2e4 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 50622dcb752e0f4689b5213433a5ad4fc83e853f..6e31ee4c21a928ded8edbb9336f91386cea19737 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 9f533b31779b6492a1da0ea90823d446560e9919..51d10b63e05626701092d108f8d2249f2d0cfd8a 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 f87edd80b01f96de67a4fefca8c6ba3a1c989d92..faf60f5c95b2b94c5c424201e24a874490561e42 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 81c65a6af9c8b932178a0b074fb8c5b7b08e59bd..1e96afe6affdc41adf17ef0e07b1dd5c86b745ba 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 6fd081790740ba920120d685d329f3851db56cc2..8cd89a9fd389c685da08045f315cf6c41644fcdf 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 fac386bd9f69158d30e4c004f7cf83f15d9eda1f..f76d13eda33e509a9f3bf707a9f1fba4781dd4a0 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 6c8a31c594edb2ad6e85522e14609f3ba0b8fa62..677e1df8174de4206601633d4b9e30f435903ad1 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 6989466ef8841187b1104007cad98d0447f8564e..baf71d8b93ec79b4946d4eef71904e0e462fb955 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 8c77500840676128d851c49cc2f0f35591325db6..23ec1686747d272069e2dc38e49a4e89fcd698c2 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 700f595a4880151d6897979a3537009a2be9115e..7f1bbbdd273fc1d0871bc1b86c33f7181e4e6878 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 c878ce2e220ff93708af21104ea59d09249b5384..e6dd0e75fff69b58ec059a1319c0dc5aef23bdb2 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 350ec7d277885520cf3f9fc24ce8941091a383dc..213462ec1086ee4c76c796e56b4060e73e5643a9 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;