summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-02-08 00:58:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:44:49 -0500
commit07478016d7354274cd53ff2b4ec1dda3f0f439d1 (patch)
treeae2e3fdfd7a12fab6fc4ca244bda786d7a5bd09b /source4/lib
parentecf2c1effb778a95fd863a5e87ec7e378d228b57 (diff)
downloadsamba-07478016d7354274cd53ff2b4ec1dda3f0f439d1.tar.gz
samba-07478016d7354274cd53ff2b4ec1dda3f0f439d1.tar.bz2
samba-07478016d7354274cd53ff2b4ec1dda3f0f439d1.zip
r21230: added the hooks needed in the cluster layer and the messaging code for
handling messages to remote nodes. Implemented dummy functions in the 'local' cluster backend for the messaging hooks, and modified the messaging layer to check if the destination is remote and redirect messages via the cluster layer (This used to be commit 4474552e8fb73efebef32ad8480d7fe9a1e379ef)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/messaging/messaging.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 691db2b961..a043937733 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -152,6 +152,37 @@ static void messaging_dispatch(struct messaging_context *msg, struct messaging_r
rec->header->length = 0;
}
+/*
+ handler for messages that arrive from other nodes in the cluster
+*/
+static void cluster_message_handler(struct messaging_context *msg, struct server_id from,
+ uint32_t msg_type, DATA_BLOB packet)
+{
+ struct messaging_rec *rec;
+
+ rec = talloc(msg, struct messaging_rec);
+ if (rec == NULL) {
+ smb_panic("Unable to allocate messaging_rec");
+ }
+
+ talloc_steal(rec, packet.data);
+ rec->msg = msg;
+ rec->path = msg->path;
+ rec->header = (struct messaging_header *)packet.data;
+ rec->packet = packet;
+
+ if (packet.length != sizeof(*rec->header) + rec->header->length) {
+ DEBUG(0,("messaging: bad message header size %d should be %d\n",
+ rec->header->length, (int)(packet.length - sizeof(*rec->header))));
+ talloc_free(rec);
+ return;
+ }
+
+ messaging_dispatch(msg, rec);
+ talloc_free(rec);
+}
+
+
/*
try to send the message
@@ -375,6 +406,12 @@ NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server,
NTSTATUS status;
size_t dlength = data?data->length:0;
+ if (!cluster_node_equal(&msg->server_id, &server)) {
+ /* the destination is on another node - dispatch via
+ the cluster layer */
+ return cluster_message_send(server, msg_type, data);
+ }
+
rec = talloc(msg, struct messaging_rec);
if (rec == NULL) {
return NT_STATUS_NO_MEMORY;
@@ -464,6 +501,13 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
return NULL;
}
+ /* setup a handler for messages from other cluster nodes, if appropriate */
+ status = cluster_message_init(msg, server_id, cluster_message_handler);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(msg);
+ return NULL;
+ }
+
if (ev == NULL) {
ev = event_context_init(msg);
}