[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Fri Mar 31 12:49:03 UTC 2017
The branch, master has been updated
via 3a9ea18 s4: messaging. Add imessaging_reinit_all() function.
from 5f49795 selftest: Define template homedir for 'ad_member' env
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 3a9ea1873ca8e07fad18d5aa07097f8ead335270
Author: Jeremy Allison <jra at samba.org>
Date: Wed Mar 29 11:11:37 2017 -0700
s4: messaging. Add imessaging_reinit_all() function.
Ensure it is called from process_standard.c after
every fork().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
Autobuild-User(master): Volker Lendecke <vl at samba.org>
Autobuild-Date(master): Fri Mar 31 14:48:17 CEST 2017 on sn-devel-144
-----------------------------------------------------------------------
Summary of changes:
source4/lib/messaging/messaging.c | 43 +++++++++++++++++++++++++++++++++++++++
source4/lib/messaging/messaging.h | 1 +
source4/smbd/process_standard.c | 14 +++++++++++++
source4/smbd/wscript_build | 2 +-
4 files changed, 59 insertions(+), 1 deletion(-)
Changeset truncated at 500 lines:
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 80ef597..844466d 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -271,6 +271,49 @@ void imessaging_dgm_unref_all(void)
}
}
+static NTSTATUS imessaging_reinit(struct imessaging_context *msg)
+{
+ int ret = -1;
+
+ TALLOC_FREE(msg->msg_dgm_ref);
+
+ msg->server_id.pid = getpid();
+
+ msg->msg_dgm_ref = messaging_dgm_ref(msg,
+ msg->ev,
+ &msg->server_id.unique_id,
+ msg->sock_dir,
+ msg->lock_dir,
+ imessaging_dgm_recv,
+ msg,
+ &ret);
+
+ if (msg->msg_dgm_ref == NULL) {
+ DEBUG(2, ("messaging_dgm_ref failed: %s\n",
+ strerror(ret)));
+ return map_nt_error_from_unix_common(ret);
+ }
+
+ server_id_db_reinit(msg->names, msg->server_id);
+ return NT_STATUS_OK;
+}
+
+/*
+ * Must be called after a fork.
+ */
+NTSTATUS imessaging_reinit_all(void)
+{
+ struct imessaging_context *msg = NULL;
+
+ for (msg = msg_ctxs; msg != NULL; msg = msg->next) {
+ NTSTATUS status = imessaging_reinit(msg);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ }
+ return NT_STATUS_OK;
+}
+
/*
create the listening socket and setup the dispatcher
*/
diff --git a/source4/lib/messaging/messaging.h b/source4/lib/messaging/messaging.h
index 3b76b45..e587fdf 100644
--- a/source4/lib/messaging/messaging.h
+++ b/source4/lib/messaging/messaging.h
@@ -45,6 +45,7 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
struct server_id server_id,
struct tevent_context *ev);
void imessaging_dgm_unref_all(void);
+NTSTATUS imessaging_reinit_all(void);
int imessaging_cleanup(struct imessaging_context *msg);
struct imessaging_context *imessaging_client_init(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx,
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index 1894657..ca93f93 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -28,6 +28,7 @@
#include "cluster/cluster.h"
#include "param/param.h"
#include "ldb_wrap.h"
+#include "lib/messaging/messaging.h"
struct standard_child_state {
const char *name;
@@ -270,6 +271,12 @@ static void standard_accept_connection(struct tevent_context *ev,
/* tdb needs special fork handling */
ldb_wrap_fork_hook();
+ /* Must be done after a fork() to reset messaging contexts. */
+ status = imessaging_reinit_all();
+ if (!NT_STATUS_IS_OK(status)) {
+ smb_panic("Failed to re-initialise imessaging after fork");
+ }
+
tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ,
standard_pipe_handler, NULL);
if (child_pipe[1] != -1) {
@@ -309,6 +316,7 @@ static void standard_new_task(struct tevent_context *ev,
void *private_data)
{
pid_t pid;
+ NTSTATUS status;
struct standard_child_state *state;
state = setup_standard_child_pipe(ev, service_name);
@@ -346,6 +354,12 @@ static void standard_new_task(struct tevent_context *ev,
/* ldb/tdb need special fork handling */
ldb_wrap_fork_hook();
+ /* Must be done after a fork() to reset messaging contexts. */
+ status = imessaging_reinit_all();
+ if (!NT_STATUS_IS_OK(status)) {
+ smb_panic("Failed to re-initialise imessaging after fork");
+ }
+
tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ,
standard_pipe_handler, NULL);
if (child_pipe[1] != -1) {
diff --git a/source4/smbd/wscript_build b/source4/smbd/wscript_build
index 98220d0..ca20396 100644
--- a/source4/smbd/wscript_build
+++ b/source4/smbd/wscript_build
@@ -40,7 +40,7 @@ bld.SAMBA_MODULE('process_model_standard',
source='process_standard.c',
subsystem='process_model',
init_function='process_model_standard_init',
- deps='events ldbsamba process_model samba-sockets cluster',
+ deps='MESSAGING events ldbsamba process_model samba-sockets cluster',
internal_module=False
)
--
Samba Shared Repository
More information about the samba-cvs
mailing list