]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
messaging: Move parsing of ctdb_req_message to ctdbd_conn.c
authorVolker Lendecke <vl@samba.org>
Tue, 2 Jun 2015 20:30:06 +0000 (20:30 +0000)
committerMichael Adam <obnox@samba.org>
Fri, 5 Jun 2015 15:51:13 +0000 (17:51 +0200)
This way we can remove the ctdb-specific includes from messages_ctdbd.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/include/ctdbd_conn.h
source3/lib/ctdb_dummy.c
source3/lib/ctdbd_conn.c
source3/lib/messages_ctdbd.c
source3/smbd/server.c

index a404724f4e236e250904b0fc47e000fd64070eb3..6cf123ff9358ae80ca7f91e341fca13307f3e937 100644 (file)
@@ -89,7 +89,9 @@ NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn);
 struct ctdb_req_message;
 
 NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
-                            void (*cb)(struct ctdb_req_message *msg,
+                            void (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
+                                       uint64_t dst_srvid,
+                                       const uint8_t *msg, size_t msglen,
                                        void *private_data),
                             void *private_data);
 NTSTATUS ctdbd_probe(void);
index bea707dee3747c7c546290e5673e625044741f68..2df6c287d929c9b7fcb68640ea9a28bc32273248 100644 (file)
@@ -38,7 +38,9 @@ NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
 }
 
 NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
-                            void (*cb)(struct ctdb_req_message *msg,
+                            void (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
+                                       uint64_t dst_srvid,
+                                       const uint8_t *msg, size_t msglen,
                                        void *private_data),
                             void *private_data)
 {
index 3aa5ced5fb013ab9a6e967faf84cbab962a18827..9ad58fe1415649e4a58dfbec090000bcfcea141f 100644 (file)
 
 struct ctdbd_srvid_cb {
        uint64_t srvid;
-       void (*cb)(struct ctdb_req_message *msg, void *private_data);
+       void (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
+                  uint64_t dst_srvid,
+                  const uint8_t *msg, size_t msglen,
+                  void *private_data);
        void *private_data;
 };
 
@@ -98,7 +101,9 @@ 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,
-                            void (*cb)(struct ctdb_req_message *msg,
+                            void (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
+                                       uint64_t dst_srvid,
+                                       const uint8_t *msg, size_t msglen,
                                        void *private_data),
                             void *private_data)
 {
@@ -134,15 +139,32 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
 static void ctdbd_msg_call_back(struct ctdbd_connection *conn,
                                struct ctdb_req_message *msg)
 {
+       size_t msg_len;
        size_t i, num_callbacks;
 
+       msg_len = msg->hdr.length;
+       if (msg_len < offsetof(struct ctdb_req_message, data)) {
+               DEBUG(10, ("%s: len %u too small\n", __func__,
+                          (unsigned)msg_len));
+               return;
+       }
+       msg_len -= offsetof(struct ctdb_req_message, data);
+
+       if (msg_len < msg->datalen) {
+               DEBUG(10, ("%s: msg_len=%u < msg->datalen=%u\n", __func__,
+                          (unsigned)msg_len, (unsigned)msg->datalen));
+               return;
+       }
+
        num_callbacks = talloc_array_length(conn->callbacks);
 
        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);
+                       cb->cb(msg->hdr.srcnode, msg->hdr.destnode,
+                              msg->srvid, msg->data, msg->datalen,
+                              cb->private_data);
                }
        }
 }
index 0ce4da7649abc39f1610f86df9c16edd01996cfc..b4f4d63c6dbad8746b6a15c9aed6ee550f6713a9 100644 (file)
@@ -22,9 +22,6 @@
 #include "util_tdb.h"
 #include "lib/util/iov_buf.h"
 #include "lib/messages_util.h"
-
-#include "ctdb.h"
-#include "ctdb_private.h"
 #include "ctdbd_conn.h"
 
 
@@ -111,44 +108,31 @@ static int messaging_ctdbd_destructor(struct messaging_ctdbd_context *ctx)
        return 0;
 }
 
-static void messaging_ctdb_recv(struct ctdb_req_message *msg,
-                               void *private_data)
+static void messaging_ctdb_recv(
+       uint32_t src_vnn, uint32_t dst_vnn, uint64_t dst_srvid,
+       const uint8_t *msg, size_t msg_len, void *private_data)
 {
        struct messaging_context *msg_ctx = talloc_get_type_abort(
                private_data, struct messaging_context);
        struct server_id me = messaging_server_id(msg_ctx);
        NTSTATUS status;
        struct iovec iov;
-       size_t msg_len;
-       uint8_t *msg_buf;
        struct server_id src, dst;
        enum messaging_type msg_type;
        struct server_id_buf idbuf;
 
-       msg_len = msg->hdr.length;
-       if (msg_len < offsetof(struct ctdb_req_message, data)) {
-               DEBUG(10, ("%s: len %u too small\n", __func__,
-                          (unsigned)msg_len));
-               return;
-       }
-       msg_len -= offsetof(struct ctdb_req_message, data);
-
-       if (msg_len < msg->datalen) {
-               DEBUG(10, ("%s: msg_len=%u < msg->datalen=%u\n", __func__,
-                          (unsigned)msg_len, (unsigned)msg->datalen));
-               return;
-       }
-
        if (msg_len < MESSAGE_HDR_LENGTH) {
                DEBUG(1, ("%s: message too short: %u\n", __func__,
                          (unsigned)msg_len));
                return;
        }
 
-       message_hdr_get(&msg_type, &src, &dst, msg->data);
+       message_hdr_get(&msg_type, &src, &dst, msg);
 
-       msg_len -= MESSAGE_HDR_LENGTH;
-       msg_buf = msg->data + MESSAGE_HDR_LENGTH;
+       iov = (struct iovec) {
+               .iov_base = discard_const_p(uint8_t, msg) + MESSAGE_HDR_LENGTH,
+               .iov_len = msg_len - MESSAGE_HDR_LENGTH
+       };
 
        DEBUG(10, ("%s: Received message 0x%x len %u from %s\n",
                   __func__, (unsigned)msg_type, (unsigned)msg_len,
@@ -163,8 +147,6 @@ static void messaging_ctdb_recv(struct ctdb_req_message *msg,
                return;
        }
 
-       iov = (struct iovec) { .iov_base = msg_buf, .iov_len = msg_len };
-
        /*
         * Go through the event loop
         */
index 9746d849be047661dd386ed96c73fabd31f2d646..20aed163ba278f39e1283b0cd5bda5e43005fe7d 100644 (file)
@@ -261,13 +261,14 @@ static void smbd_parent_id_cache_delete(struct messaging_context *ctx,
        messaging_send_to_children(ctx, msg_type, msg_data);
 }
 
-static void smbd_parent_ctdb_reconfigured(struct ctdb_req_message *msg,
-                                         void *private_data)
+static void smbd_parent_ctdb_reconfigured(
+       uint32_t src_vnn, uint32_t dst_vnn, uint64_t dst_srvid,
+       const uint8_t *msg, size_t msglen, void *private_data)
 {
        struct messaging_context *msg_ctx = talloc_get_type_abort(
                private_data, struct messaging_context);
 
-       DEBUG(10, ("Got %s message\n", (msg->srvid == CTDB_SRVID_RECONFIGURE)
+       DEBUG(10, ("Got %s message\n", (dst_srvid == CTDB_SRVID_RECONFIGURE)
                   ? "cluster reconfigure" : "SAMBA_NOTIFY"));
 
        /*