[PATCH] messaging: Move parsing of ctdb_req_message to ctdbd_conn.c
Volker Lendecke
Volker.Lendecke at SerNet.DE
Thu Jun 4 08:49:13 MDT 2015
Hi!
Review&push appreciated!
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 059f18de8c0d68eff2b913b250fdc56750fc51db Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 2 Jun 2015 20:30:06 +0000
Subject: [PATCH] messaging: Move parsing of ctdb_req_message to ctdbd_conn.c
This way we can remove the ctdb-specific includes from messages_ctdbd.c
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 4 +++-
source3/lib/ctdbd_conn.c | 28 +++++++++++++++++++++++++---
source3/lib/messages_ctdbd.c | 34 ++++++++--------------------------
source3/smbd/server.c | 7 ++++---
4 files changed, 40 insertions(+), 33 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index a404724..6cf123f 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -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);
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 3aa5ced..9ad58fe 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -35,7 +35,10 @@
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);
}
}
}
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 0ce4da7..b4f4d63 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -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
*/
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 9746d84..20aed16 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -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"));
/*
--
1.7.9.5
More information about the samba-technical
mailing list