diff --git a/source3/include/proto.h b/source3/include/proto.h index 135820f1ce9..30a432521f3 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1226,8 +1226,9 @@ ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos int set_blocking(int fd, bool set); void smb_msleep(unsigned int t); NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx, - struct event_context *ev_ctx, - bool parent_longlived); + struct event_context *ev_ctx, + struct server_id id, + bool parent_longlived); void *malloc_(size_t size); void *memalign_array(size_t el_size, size_t align, unsigned int count); void *calloc_array(size_t size, size_t nmemb); diff --git a/source3/lib/util.c b/source3/lib/util.c index 1467c5445da..2a4d0501fe0 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -873,6 +873,7 @@ void smb_msleep(unsigned int t) NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx, struct event_context *ev_ctx, + struct server_id id, bool parent_longlived) { NTSTATUS status = NT_STATUS_OK; @@ -899,7 +900,7 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx, * For clustering, we need to re-init our ctdbd connection after the * fork */ - status = messaging_reinit(msg_ctx, procid_self()); + status = messaging_reinit(msg_ctx, id); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("messaging_reinit() failed: %s\n", nt_errstr(status))); diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 21ac5a0ff44..2701c96dd79 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -137,6 +137,7 @@ void kill_async_dns_child(void) void start_async_dns(void) { int fd1[2], fd2[2]; + NTSTATUS status; CatchChild(); @@ -164,8 +165,11 @@ void start_async_dns(void) CatchSignal(SIGHUP, SIG_IGN); CatchSignal(SIGTERM, sig_term); - if (!NT_STATUS_IS_OK(reinit_after_fork(nmbd_messaging_context(), - nmbd_event_context(), true))) { + status = reinit_after_fork(nmbd_messaging_context(), + nmbd_event_context(), + procid_self(), true); + + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); smb_panic("reinit_after_fork() failed"); } diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index d13607b1f54..dd42675cc60 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -779,6 +779,7 @@ static bool open_sockets(bool isdaemon, int port) { NULL } }; TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */ + NTSTATUS status; load_case_tables(); @@ -923,8 +924,11 @@ static bool open_sockets(bool isdaemon, int port) pidfile_create("nmbd"); - if (!NT_STATUS_IS_OK(reinit_after_fork(nmbd_messaging_context(), - nmbd_event_context(), false))) { + status = reinit_after_fork(nmbd_messaging_context(), + nmbd_event_context(), + procid_self(), false); + + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); exit(1); } diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c index 043cc96930e..cbefa07a336 100644 --- a/source3/printing/print_cups.c +++ b/source3/printing/print_cups.c @@ -397,6 +397,7 @@ static bool cups_pcap_load_async(int *pfd) { int fds[2]; pid_t pid; + NTSTATUS status; *pfd = -1; @@ -434,8 +435,10 @@ static bool cups_pcap_load_async(int *pfd) close_all_print_db(); - if (!NT_STATUS_IS_OK(reinit_after_fork(server_messaging_context(), - server_event_context(), true))) { + status = reinit_after_fork(server_messaging_context(), + server_event_context(), procid_self(), + true); + 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/printing.c b/source3/printing/printing.c index 93624f0f787..1b5decc696a 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -1430,6 +1430,7 @@ void start_background_queue(void) if(background_lpq_updater_pid == 0) { struct tevent_fd *fde; int ret; + NTSTATUS status; /* Child. */ DEBUG(5,("start_background_queue: background LPQ thread started\n")); @@ -1437,9 +1438,11 @@ void start_background_queue(void) close(pause_pipe[0]); pause_pipe[0] = -1; - if (!NT_STATUS_IS_OK(reinit_after_fork(server_messaging_context(), - server_event_context(), - true))) { + status = reinit_after_fork(server_messaging_context(), + server_event_context(), + procid_self(), true); + + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); smb_panic("reinit_after_fork() failed"); } diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 8c2060df1ad..b0bae927b98 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -2807,7 +2807,8 @@ static bool fork_echo_handler(struct smbd_server_connection *sconn) close(listener_pipe[0]); status = reinit_after_fork(smbd_messaging_context(), - smbd_event_context(), false); + smbd_event_context(), + procid_self(), false); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("reinit_after_fork failed: %s\n", nt_errstr(status))); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index a1250790cee..f30d7618654 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -409,7 +409,8 @@ static void smbd_accept_connection(struct tevent_context *ev, s = NULL; status = reinit_after_fork(smbd_messaging_context(), - smbd_event_context(), true); + smbd_event_context(), procid_self(), + true); if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_TOO_MANY_OPENED_FILES)) { @@ -806,6 +807,7 @@ extern void build_options(bool screen); }; struct smbd_parent_context *parent = NULL; TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */ + NTSTATUS status; smbd_init_globals(); @@ -998,8 +1000,10 @@ extern void build_options(bool screen); if (is_daemon) pidfile_create("smbd"); - if (!NT_STATUS_IS_OK(reinit_after_fork(smbd_messaging_context(), - smbd_event_context(), false))) { + status = reinit_after_fork(smbd_messaging_context(), + smbd_event_context(), + procid_self(), false); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); exit(1); } diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 34fd271194c..cdbf2d62ca6 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -1122,6 +1122,7 @@ int main(int argc, char **argv, char **envp) poptContext pc; int opt; TALLOC_CTX *frame = talloc_stackframe(); + NTSTATUS status; /* glibc (?) likes to print "User defined signal 1" and exit if a SIGUSR[12] is received before a handler is installed */ @@ -1278,9 +1279,10 @@ int main(int argc, char **argv, char **envp) * winbindd-specific resources we must free yet. JRA. */ - if (!NT_STATUS_IS_OK(reinit_after_fork(winbind_messaging_context(), - winbind_event_context(), - false))) { + status = reinit_after_fork(winbind_messaging_context(), + winbind_event_context(), + procid_self(), false); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); exit(1); } diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 2ae32e793c9..e506d2a53ac 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -1106,10 +1106,12 @@ bool winbindd_reinit_after_fork(const char *logfilename) { struct winbindd_domain *domain; struct winbindd_child *cl; + NTSTATUS status; - if (!NT_STATUS_IS_OK(reinit_after_fork(winbind_messaging_context(), - winbind_event_context(), - true))) { + status = reinit_after_fork(winbind_messaging_context(), + winbind_event_context(), + procid_self(), true); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); return false; }