}
}
+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
*/
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,
#include "cluster/cluster.h"
#include "param/param.h"
#include "ldb_wrap.h"
+#include "lib/messaging/messaging.h"
struct standard_child_state {
const char *name;
/* 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) {
void *private_data)
{
pid_t pid;
+ NTSTATUS status;
struct standard_child_state *state;
state = setup_standard_child_pipe(ev, service_name);
/* 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) {
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
)