This save a few lines of code.
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
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,
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 {
#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>
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;
nt_errstr(status)));
}
}
+
+ if (comment) {
+ prctl_set_comment(comment);
+ }
+
done:
return status;
}
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"));
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));
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");
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);
#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"
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);
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);
#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"
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);
}
/* 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");
#include "messages.h"
#include "ntdomain.h"
-#include "lib/util/util_process.h"
-
#include "lib/id_cache.h"
#include "../lib/tsocket/tsocket.h"
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);
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);
#include "messages.h"
#include "ntdomain.h"
-#include "lib/util/util_process.h"
-
#include "lib/id_cache.h"
#include "../lib/tsocket/tsocket.h"
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();
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 */
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)));
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)));
return false;
}
- prctl_set_comment("smbd-scavenger");
-
state->am_scavenger = true;
*state->scavenger_id = messaging_server_id(state->msg);
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)));
}
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;
* 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)) {
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));
}
*/
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);
}
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));
}
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;