From: Christof Schmitt Date: Wed, 23 Sep 2015 18:14:05 +0000 (-0700) Subject: s3: Move call to prctl_set_comment to reinit_after_fork X-Git-Tag: talloc-2.1.4~173 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=96c48b3c06034a64ee4fb90650dfd5a1059fe83a s3: Move call to prctl_set_comment to reinit_after_fork This save a few lines of code. Signed-off-by: Christof Schmitt Reviewed-by: Andreas Schneider --- diff --git a/source3/include/proto.h b/source3/include/proto.h index 0af8cdd9e65..5b638977bb2 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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, diff --git a/source3/lib/background.c b/source3/lib/background.c index 4ea128211e7..3c8eb5897cd 100644 --- a/source3/lib/background.c +++ b/source3/lib/background.c @@ -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 { diff --git a/source3/lib/util.c b/source3/lib/util.c index d38d53a5cb8..2ac4dbddf64 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -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 @@ -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; } diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 5973c8efc06..66e3674c63a 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -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")); diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index c7e72de5530..14eaef647d0 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -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)); diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c index 3ebb2e67ab2..110711c40c2 100644 --- a/source3/printing/print_cups.c +++ b/source3/printing/print_cups.c @@ -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"); diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c index 50622dcb752..6e31ee4c21a 100644 --- a/source3/printing/queue_process.c +++ b/source3/printing/queue_process.c @@ -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); diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c index 9f533b31779..51d10b63e05 100644 --- a/source3/printing/spoolssd.c +++ b/source3/printing/spoolssd.c @@ -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); diff --git a/source3/rpc_server/epmd.c b/source3/rpc_server/epmd.c index f87edd80b01..faf60f5c95b 100644 --- a/source3/rpc_server/epmd.c +++ b/source3/rpc_server/epmd.c @@ -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); diff --git a/source3/rpc_server/fssd.c b/source3/rpc_server/fssd.c index 81c65a6af9c..1e96afe6aff 100644 --- a/source3/rpc_server/fssd.c +++ b/source3/rpc_server/fssd.c @@ -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"); diff --git a/source3/rpc_server/lsasd.c b/source3/rpc_server/lsasd.c index 6fd08179074..8cd89a9fd38 100644 --- a/source3/rpc_server/lsasd.c +++ b/source3/rpc_server/lsasd.c @@ -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); diff --git a/source3/rpc_server/mdssd.c b/source3/rpc_server/mdssd.c index fac386bd9f6..f76d13eda33 100644 --- a/source3/rpc_server/mdssd.c +++ b/source3/rpc_server/mdssd.c @@ -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 */ diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 6c8a31c594e..677e1df8174 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -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))); diff --git a/source3/smbd/scavenger.c b/source3/smbd/scavenger.c index 6989466ef88..baf71d8b93e 100644 --- a/source3/smbd/scavenger.c +++ b/source3/smbd/scavenger.c @@ -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); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 8c775008406..23ec1686747 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -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)); } diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c index 700f595a488..7f1bbbdd273 100644 --- a/source3/smbd/server_exit.c +++ b/source3/smbd/server_exit.c @@ -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); } diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index c878ce2e220..e6dd0e75fff 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -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)); } diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 350ec7d2778..213462ec108 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -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;