[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Thu May 28 06:01:05 MDT 2015


The branch, master has been updated
       via  a4cc7d4 messages_ctdb: Use message_hdr_[get/put]
       via  abc7b2f messaging: Remove an unused variable
       via  32d4419 ctdbd_conn: Introduce ctdbd_messaging_send_iov()
       via  2416984 messaging: Make messaging_dispatch_rec static
       via  25fab3e messaging: With dgm_ref, don't destroy the dgm ctx
       via  9406d09 ctdbd_conn: ctdb_handle_message does not need msg_ctx
       via  1052d31 ctdbd_conn: Move ndr marshalling to messages_ctdb.c
       via  7ce9f3f ctdbd_conn: simplify ctdbd_register_ips
       via  d669bd8 ctdbd_conn: Move ctdbd_register_reconfigure to a callback
       via  a37398b ctdbd_conn: Move message handling out of ctdbd_conn.c
       via  24eb365 ctdbd_conn: Call back when we get a msg
       via  467fee4 ctdbd_conn: Add callback args to register_with_ctdbd
       via  4d0572a ctdbd_conn: Add callback fields for registered serverids
       via  cc51e85 messaging: Register a tevent context for secondary dgm refs
       via  586a959 ctdbd_conn: Use read_data()
      from  d821456 KCC: more pythonic expression in select_istg

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit a4cc7d4746b1fff8bdad489233132bd6f3eef270
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 25 17:59:22 2015 +0000

    messages_ctdb: Use message_hdr_[get/put]
    
    This also avoids the message copy when sending to ctdb by
    using ctdbd_messaging_send_iov
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Thu May 28 14:00:29 CEST 2015 on sn-devel-104

commit abc7b2f179be2907e74f8a8da4f29c21faf9754a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 25 17:50:46 2015 +0000

    messaging: Remove an unused variable
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 32d441910568e0faa143d5e90e68bdf7099db74b
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 25 08:50:35 2015 +0200

    ctdbd_conn: Introduce ctdbd_messaging_send_iov()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 2416984b4006b3fb8a323addb0fae127dea85f7a
Author: Volker Lendecke <vl at samba.org>
Date:   Sun May 24 21:25:56 2015 +0200

    messaging: Make messaging_dispatch_rec static
    
    It's not needed in ctdbd_conn.c anymore
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 25fab3ebe9664107d2cd96fbf809a7493908243d
Author: Volker Lendecke <vl at samba.org>
Date:   Fri May 22 18:40:25 2015 +0200

    messaging: With dgm_ref, don't destroy the dgm ctx
    
    Since we use messaging_dgm_ref, we must rely on that to destroy the dgm
    context when the last reference goes.
    
    This is a real bugfix in case we have multiple messaging contexts.
    
    I'm not sure if we should move towards just one single messaging context
    per process, just like we have it for the dgm context.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 9406d09fec2bab28d7cd27d774744ab908dc1e68
Author: Volker Lendecke <vl at samba.org>
Date:   Wed May 20 17:59:53 2015 +0200

    ctdbd_conn: ctdb_handle_message does not need msg_ctx
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 1052d3164cb3089df8014f0d1edfad5a93e2032f
Author: Volker Lendecke <vl at samba.org>
Date:   Wed May 20 11:17:25 2015 +0200

    ctdbd_conn: Move ndr marshalling to messages_ctdb.c
    
    The inter-node message format belongs into messages_ctdb, not into the
    generic ctdb connection layer
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 7ce9f3f3f5c95506105b14022b1327f12bbcb229
Author: Volker Lendecke <vl at samba.org>
Date:   Wed May 20 08:12:46 2015 +0200

    ctdbd_conn: simplify ctdbd_register_ips
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit d669bd82436006e06a77e0eb9d8e47253324398a
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 19 22:15:57 2015 +0200

    ctdbd_conn: Move ctdbd_register_reconfigure to a callback
    
    Move functionality out of ctdbd_conn to its right place into smbd
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit a37398b9de835eaf95237cf5c8ade41d0800a37c
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 19 16:55:32 2015 +0200

    ctdbd_conn: Move message handling out of ctdbd_conn.c
    
    This also removes the deferred message handling. It's no longer required,
    because the messaging_send_iov_from always goes through the kernel which
    takes at least one round through tevent.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 24eb3659e3ee5a262a80aea1b36a8e5ef3c7be99
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 19 15:07:33 2015 +0200

    ctdbd_conn: Call back when we get a msg
    
    This activates the callbacks just added
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 467fee4d5afd7db7ee4005a040896d72ab499573
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 19 07:05:24 2015 +0200

    ctdbd_conn: Add callback args to register_with_ctdbd
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 4d0572a2a467a4fbde394e73f6d8c565f67807d8
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 19 07:01:55 2015 +0200

    ctdbd_conn: Add callback fields for registered serverids
    
    The idea is to move message handling out of ctdbd_conn
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit cc51e85f0aa49aad529eca5711fdc34f95bfe6d8
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 18 13:15:35 2015 +0200

    messaging: Register a tevent context for secondary dgm refs
    
    When a secondary messaging context is initialized, we need to register
    its tevent context with the lower level dgm context. Seen when using
    smbstatus with clustering.
    
    The TALLOC_FREE(r->tevent_handle) in the destructor might not be
    necessary, but I want to free the tevent reference before
    the context goes away.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 586a95948029ce0491f05dfba67c986085adbb55
Author: Volker Lendecke <vl at samba.org>
Date:   Sun May 17 20:23:35 2015 +0200

    ctdbd_conn: Use read_data()
    
    This is a much smaller dependency than read_data_ntstatus
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/include/ctdbd_conn.h   |  19 +--
 source3/include/messages.h     |   2 -
 source3/lib/ctdb_dummy.c       |  23 +---
 source3/lib/ctdbd_conn.c       | 303 +++++++++--------------------------------
 source3/lib/messages.c         |  16 +--
 source3/lib/messages_ctdbd.c   | 103 ++++++++++----
 source3/lib/messages_dgm_ref.c |  12 ++
 source3/lib/serverid.c         |   3 +-
 source3/smbd/notify_internal.c |  10 +-
 source3/smbd/server.c          |  25 +++-
 10 files changed, 210 insertions(+), 306 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 36932bd..a404724 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -38,12 +38,9 @@ struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn);
 
 int ctdbd_conn_get_fd(struct ctdbd_connection *conn);
 
-NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn,
-			      uint32_t dst_vnn, uint64_t dst_srvid,
-			      struct messaging_rec *msg);
-NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn,
-				   uint32_t dst_vnn, uint64_t dst_srvid,
-				   const uint8_t *buf, size_t buflen);
+NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
+				  uint32_t dst_vnn, uint64_t dst_srvid,
+				  const struct iovec *iov, int iovlen);
 
 bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn,
 			  pid_t pid);
@@ -82,15 +79,19 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
 						       void *private_data),
 			    void *private_data);
 
-NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn);
-
 NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
 			     uint64_t srvid, uint32_t flags, TDB_DATA data,
 			     TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
 			     int *cstatus);
 NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn);
 NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn);
-NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid);
+
+struct ctdb_req_message;
+
+NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
+			     void (*cb)(struct ctdb_req_message *msg,
+					void *private_data),
+			     void *private_data);
 NTSTATUS ctdbd_probe(void);
 
 #endif /* _CTDBD_CONN_H */
diff --git a/source3/include/messages.h b/source3/include/messages.h
index 6b5e3da..c620f92 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -132,8 +132,6 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
 			    struct server_id server, uint32_t msg_type,
 			    const struct iovec *iov, int iovlen,
 			    const int *fds, size_t num_fds);
-void messaging_dispatch_rec(struct messaging_context *msg_ctx,
-			    struct messaging_rec *rec);
 
 struct tevent_req *messaging_filtered_read_send(
 	TALLOC_CTX *mem_ctx, struct tevent_context *ev,
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index e19765b..bea707d 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -30,26 +30,17 @@ NTSTATUS ctdbd_probe(void)
 	return NT_STATUS_NOT_IMPLEMENTED;
 }
 
-NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn,
-			      uint32_t dst_vnn, uint64_t dst_srvid,
-			      struct messaging_rec *msg)
+NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
+				  uint32_t dst_vnn, uint64_t dst_srvid,
+				  const struct iovec *iov, int iovlen)
 {
 	return NT_STATUS_NOT_IMPLEMENTED;
 }
 
-NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn,
-				   uint32_t dst_vnn, uint64_t dst_srvid,
-				   const uint8_t *buf, size_t buflen)
-{
-	return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid)
-{
-	return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn)
+NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
+			     void (*cb)(struct ctdb_req_message *msg,
+					void *private_data),
+			     void *private_data)
 {
 	return NT_STATUS_NOT_IMPLEMENTED;
 }
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 1285e4b..66c87c5 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -24,6 +24,7 @@
 #include "ctdbd_conn.h"
 #include "system/select.h"
 #include "lib/sys_rw_data.h"
+#include "lib/util/iov_buf.h"
 
 #include "messages.h"
 
@@ -32,12 +33,18 @@
 #include "ctdb.h"
 #include "ctdb_private.h"
 
+struct ctdbd_srvid_cb {
+	uint64_t srvid;
+	void (*cb)(struct ctdb_req_message *msg, void *private_data);
+	void *private_data;
+};
+
 struct ctdbd_connection {
 	struct messaging_context *msg_ctx;
 	uint32_t reqid;
 	uint32_t our_vnn;
 	uint64_t rand_srvid;
-	uint64_t *srvids;
+	struct ctdbd_srvid_cb *callbacks;
 	int fd;
 	struct tevent_fd *fde;
 
@@ -90,13 +97,16 @@ static void ctdb_packet_dump(struct ctdb_req_header *hdr)
 /*
  * Register a srvid with ctdbd
  */
-NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid)
+NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
+			     void (*cb)(struct ctdb_req_message *msg,
+					void *private_data),
+			     void *private_data)
 {
 
 	NTSTATUS status;
 	int cstatus;
-	size_t num_srvids;
-	uint64_t *tmp;
+	size_t num_callbacks;
+	struct ctdbd_srvid_cb *tmp;
 
 	status = ctdbd_control(conn, CTDB_CURRENT_NODE,
 			       CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
@@ -105,31 +115,36 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid)
 		return status;
 	}
 
-	num_srvids = talloc_array_length(conn->srvids);
+	num_callbacks = talloc_array_length(conn->callbacks);
 
-	tmp = talloc_realloc(conn, conn->srvids, uint64_t,
-			     num_srvids + 1);
+	tmp = talloc_realloc(conn, conn->callbacks, struct ctdbd_srvid_cb,
+			     num_callbacks + 1);
 	if (tmp == NULL) {
 		return NT_STATUS_NO_MEMORY;
 	}
-	conn->srvids = tmp;
+	conn->callbacks = tmp;
+
+	conn->callbacks[num_callbacks] = (struct ctdbd_srvid_cb) {
+		.srvid = srvid, .cb = cb, .private_data = private_data
+	};
 
-	conn->srvids[num_srvids] = srvid;
 	return NT_STATUS_OK;
 }
 
-static bool ctdb_is_our_srvid(struct ctdbd_connection *conn, uint64_t srvid)
+static void ctdbd_msg_call_back(struct ctdbd_connection *conn,
+				struct ctdb_req_message *msg)
 {
-	size_t i, num_srvids;
+	size_t i, num_callbacks;
 
-	num_srvids = talloc_array_length(conn->srvids);
+	num_callbacks = talloc_array_length(conn->callbacks);
 
-	for (i=0; i<num_srvids; i++) {
-		if (srvid == conn->srvids[i]) {
-			return true;
+	for (i=0; i<num_callbacks; i++) {
+		struct ctdbd_srvid_cb *cb = &conn->callbacks[i];
+
+		if ((cb->srvid == msg->srvid) && (cb->cb != NULL)) {
+			cb->cb(msg, cb->private_data);
 		}
 	}
-	return false;
 }
 
 /*
@@ -264,78 +279,6 @@ static int ctdbd_connect(int *pfd)
 	return 0;
 }
 
-/*
- * State necessary to defer an incoming message while we are waiting for a
- * ctdb reply.
- */
-
-struct deferred_msg_state {
-	struct messaging_context *msg_ctx;
-	struct messaging_rec *rec;
-};
-
-/*
- * Timed event handler for the deferred message
- */
-
-static void deferred_message_dispatch(struct tevent_context *event_ctx,
-				      struct tevent_timer *te,
-				      struct timeval now,
-				      void *private_data)
-{
-	struct deferred_msg_state *state = talloc_get_type_abort(
-		private_data, struct deferred_msg_state);
-
-	messaging_dispatch_rec(state->msg_ctx, state->rec);
-	TALLOC_FREE(state);
-	TALLOC_FREE(te);
-}
-
-/*
- * Fetch a messaging_rec from an incoming ctdb style message
- */
-
-static struct messaging_rec *ctdb_pull_messaging_rec(TALLOC_CTX *mem_ctx,
-						     size_t overall_length,
-						     struct ctdb_req_message *msg)
-{
-	struct messaging_rec *result;
-	DATA_BLOB blob;
-	enum ndr_err_code ndr_err;
-
-	if ((overall_length < offsetof(struct ctdb_req_message, data))
-	    || (overall_length
-		< offsetof(struct ctdb_req_message, data) + msg->datalen)) {
-
-		cluster_fatal("got invalid msg length");
-	}
-
-	if (!(result = talloc(mem_ctx, struct messaging_rec))) {
-		DEBUG(0, ("talloc failed\n"));
-		return NULL;
-	}
-
-	blob = data_blob_const(msg->data, msg->datalen);
-
-	ndr_err = ndr_pull_struct_blob(
-		&blob, result, result,
-		(ndr_pull_flags_fn_t)ndr_pull_messaging_rec);
-
-	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-		DEBUG(0, ("ndr_pull_struct_blob failed: %s\n",
-			  ndr_errstr(ndr_err)));
-		TALLOC_FREE(result);
-		return NULL;
-	}
-
-	if (DEBUGLEVEL >= 11) {
-		DEBUG(11, ("ctdb_pull_messaging_rec:\n"));
-		NDR_PRINT_DEBUG(messaging_rec, result);
-	}
-
-	return result;
-}
-
 static NTSTATUS ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx,
 				 struct ctdb_req_header **result)
 {
@@ -343,7 +286,7 @@ static NTSTATUS ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx,
 	struct ctdb_req_header *req;
 	int ret, revents;
 	uint32_t msglen;
-	NTSTATUS status;
+	ssize_t nread;
 
 	if (timeout == 0) {
 		timeout = -1;
@@ -362,9 +305,12 @@ static NTSTATUS ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx,
 		}
 	}
 
-	status = read_data_ntstatus(fd, (char *)&msglen, sizeof(msglen));
-	if (!NT_STATUS_IS_OK(status)) {
-		return status;
+	nread = read_data(fd, &msglen, sizeof(msglen));
+	if (nread == -1) {
+		return map_nt_error_from_unix(errno);
+	}
+	if (nread == 0) {
+		return NT_STATUS_UNEXPECTED_IO_ERROR;
 	}
 
 	if (msglen < sizeof(struct ctdb_req_header)) {
@@ -379,10 +325,13 @@ static NTSTATUS ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx,
 
 	req->length = msglen;
 
-	status = read_data_ntstatus(fd, ((char *)req) + sizeof(msglen),
-				    msglen - sizeof(msglen));
-	if (!NT_STATUS_IS_OK(status)) {
-		return status;
+	nread = read_data(fd, ((char *)req) + sizeof(msglen),
+			  msglen - sizeof(msglen));
+	if (nread == -1) {
+		return map_nt_error_from_unix(errno);
+	}
+	if (nread == 0) {
+		return NT_STATUS_UNEXPECTED_IO_ERROR;
 	}
 
 	*result = req;
@@ -413,8 +362,6 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
 	ctdb_packet_dump(hdr);
 
 	if (hdr->operation == CTDB_REQ_MESSAGE) {
-		struct tevent_timer *evt;
-		struct deferred_msg_state *msg_state;
 		struct ctdb_req_message *msg = (struct ctdb_req_message *)hdr;
 
 		if (conn->msg_ctx == NULL) {
@@ -448,55 +395,8 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
 			goto next_pkt;
 		}
 
-		if ((msg->srvid == CTDB_SRVID_RECONFIGURE)
-		    || (msg->srvid == CTDB_SRVID_SAMBA_NOTIFY)) {
-
-			DEBUG(1, ("ctdb_read_req: Got %s message\n",
-				  (msg->srvid == CTDB_SRVID_RECONFIGURE)
-				  ? "cluster reconfigure" : "SAMBA_NOTIFY"));
-
-			messaging_send(conn->msg_ctx,
-				       messaging_server_id(conn->msg_ctx),
-				       MSG_SMB_BRL_VALIDATE, &data_blob_null);
-			TALLOC_FREE(hdr);
-			goto next_pkt;
-		}
-
-		msg_state = talloc(NULL, struct deferred_msg_state);
-		if (msg_state == NULL) {
-			DEBUG(0, ("talloc failed\n"));
-			TALLOC_FREE(hdr);
-			goto next_pkt;
-		}
-
-		if (!(msg_state->rec = ctdb_pull_messaging_rec(
-			      msg_state, msg->hdr.length, msg))) {
-			DEBUG(0, ("ctdbd_pull_messaging_rec failed\n"));
-			TALLOC_FREE(msg_state);
-			TALLOC_FREE(hdr);
-			goto next_pkt;
-		}
-
+		ctdbd_msg_call_back(conn, msg);
 		TALLOC_FREE(hdr);
-
-		msg_state->msg_ctx = conn->msg_ctx;
-
-		/*
-		 * We're waiting for a call reply, but an async message has
-		 * crossed. Defer dispatching to the toplevel event loop.
-		 */
-		evt = tevent_add_timer(messaging_tevent_context(conn->msg_ctx),
-				      messaging_tevent_context(conn->msg_ctx),
-				      timeval_zero(),
-				      deferred_message_dispatch,
-				      msg_state);
-		if (evt == NULL) {
-			DEBUG(0, ("event_add_timed failed\n"));
-			TALLOC_FREE(msg_state);
-			TALLOC_FREE(hdr);
-			goto next_pkt;
-		}
-
 		goto next_pkt;
 	}
 
@@ -558,7 +458,7 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 	generate_random_buffer((unsigned char *)&conn->rand_srvid,
 			       sizeof(conn->rand_srvid));
 
-	status = register_with_ctdbd(conn, conn->rand_srvid);
+	status = register_with_ctdbd(conn, conn->rand_srvid, NULL, NULL);
 
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(5, ("Could not register random srvid: %s\n",
@@ -590,17 +490,7 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
 		return status;
 	}
 
-	status = register_with_ctdbd(conn, (uint64_t)getpid());
-	if (!NT_STATUS_IS_OK(status)) {
-		goto fail;
-	}
-
-	status = register_with_ctdbd(conn, MSG_SRVID_SAMBA);
-	if (!NT_STATUS_IS_OK(status)) {
-		goto fail;
-	}
-
-	status = register_with_ctdbd(conn, CTDB_SRVID_SAMBA_NOTIFY);
+	status = register_with_ctdbd(conn, MSG_SRVID_SAMBA, NULL, NULL);
 	if (!NT_STATUS_IS_OK(status)) {
 		goto fail;
 	}
@@ -626,12 +516,10 @@ int ctdbd_conn_get_fd(struct ctdbd_connection *conn)
 /*
  * Packet handler to receive and handle a ctdb message
  */
-static NTSTATUS ctdb_handle_message(struct messaging_context *msg_ctx,
-				    struct ctdbd_connection *conn,
+static NTSTATUS ctdb_handle_message(struct ctdbd_connection *conn,
 				    struct ctdb_req_header *hdr)
 {
 	struct ctdb_req_message *msg;
-	struct messaging_rec *msg_rec;
 
 	if (hdr->operation != CTDB_REQ_MESSAGE) {
 		DEBUG(0, ("Received async msg of type %u, discarding\n",
@@ -661,35 +549,8 @@ static NTSTATUS ctdb_handle_message(struct messaging_context *msg_ctx,
 		return NT_STATUS_OK;
 	}
 
-	SMB_ASSERT(conn->msg_ctx != NULL);
+	ctdbd_msg_call_back(conn, msg);
 
-	if ((msg->srvid == CTDB_SRVID_RECONFIGURE)
-	    || (msg->srvid == CTDB_SRVID_SAMBA_NOTIFY)){
-		DEBUG(0,("Got cluster reconfigure message\n"));
-		/*
-		 * when the cluster is reconfigured or someone of the
-		 * family has passed away (SAMBA_NOTIFY), we need to
-		 * clean the brl database
-		 */
-		messaging_send(conn->msg_ctx,
-			       messaging_server_id(conn->msg_ctx),
-			       MSG_SMB_BRL_VALIDATE, &data_blob_null);
-
-		return NT_STATUS_OK;
-	}
-
-	if (!ctdb_is_our_srvid(conn, msg->srvid)) {
-		DEBUG(0,("Got unexpected message with srvid=%llu\n",
-			 (unsigned long long)msg->srvid));
-		return NT_STATUS_OK;
-	}
-
-	msg_rec = ctdb_pull_messaging_rec(talloc_tos(), msg->hdr.length, msg);
-	if (msg_rec == NULL) {
-		DEBUG(10, ("ctdb_pull_messaging_rec failed\n"));
-		return NT_STATUS_NO_MEMORY;
-	}
-	messaging_dispatch_rec(conn->msg_ctx, msg_rec);
 	return NT_STATUS_OK;
 }
 
@@ -713,7 +574,7 @@ static void ctdbd_socket_handler(struct tevent_context *event_ctx,
 		cluster_fatal("ctdbd died\n");
 	}
 
-	status = ctdb_handle_message(conn->msg_ctx, conn, hdr);
+	status = ctdb_handle_message(conn, hdr);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(10, ("could not handle incoming message: %s\n",
 			   nt_errstr(status)));
@@ -745,40 +606,13 @@ NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
 	return NT_STATUS_OK;
 }
 
-/*
- * Send a messaging message across a ctdbd
- */
-
-NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn,
-			      uint32_t dst_vnn, uint64_t dst_srvid,
-			      struct messaging_rec *msg)
-{
-	DATA_BLOB blob;
-	NTSTATUS status;
-	enum ndr_err_code ndr_err;
-
-	ndr_err = ndr_push_struct_blob(
-		&blob, talloc_tos(), msg,
-		(ndr_push_flags_fn_t)ndr_push_messaging_rec);
-
-	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-		DEBUG(0, ("ndr_push_struct_blob failed: %s\n",
-			  ndr_errstr(ndr_err)));
-		return ndr_map_error2ntstatus(ndr_err);
-	}
-
-	status = ctdbd_messaging_send_blob(conn, dst_vnn, dst_srvid,
-					   blob.data, blob.length);
-	TALLOC_FREE(blob.data);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list