summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2015-06-02 20:30:06 +0000
committerMichael Adam <obnox@samba.org>2015-06-05 17:51:13 +0200
commita4db3b30c5a8533943766486f72422a5eb072a62 (patch)
tree7b841c697632d549bf5c2739e7810717e87b4070 /source3/lib
parentfc5aadb57b8f26ed45c76a5c66e91e8a3583f673 (diff)
downloadsamba-a4db3b30c5a8533943766486f72422a5eb072a62.tar.gz
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@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/ctdb_dummy.c4
-rw-r--r--source3/lib/ctdbd_conn.c28
-rw-r--r--source3/lib/messages_ctdbd.c34
3 files changed, 36 insertions, 30 deletions
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index bea707dee37..2df6c287d92 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -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)
{
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 3aa5ced5fb0..9ad58fe1415 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 0ce4da7649a..b4f4d63c6db 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
*/