1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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>
This commit is contained in:
Volker Lendecke 2015-06-02 20:30:06 +00:00 committed by Michael Adam
parent fc5aadb57b
commit a4db3b30c5
5 changed files with 43 additions and 34 deletions

View 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);

View 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)
{

View File

@ -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);
}
}
}

View 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
*/

View 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"));
/*