messaging3: The backend send_fn doesn't need a messaging_context
[samba.git] / source3 / lib / messages_ctdbd.c
index 234f8f9e1b58b885ab1d8507d6e6d4842e9924ee..3b7fa0532282f8401a891d5611579fa89ac109f3 100644 (file)
@@ -21,8 +21,6 @@
 #include "messages.h"
 #include "util_tdb.h"
 
-#ifdef CLUSTER_SUPPORT
-
 /*
  * It is not possible to include ctdb.h and tdb_compat.h (included via
  * some other include above) without warnings. This fixes those
@@ -90,23 +88,35 @@ struct ctdbd_connection *messaging_ctdbd_connection(void)
        return global_ctdbd_connection;
 }
 
-static NTSTATUS messaging_ctdb_send(struct messaging_context *msg_ctx,
+static NTSTATUS messaging_ctdb_send(struct server_id src,
                                    struct server_id pid, int msg_type,
-                                   const DATA_BLOB *data,
+                                   const struct iovec *iov, int iovlen,
                                    struct messaging_backend *backend)
 {
        struct messaging_ctdbd_context *ctx = talloc_get_type_abort(
                backend->private_data, struct messaging_ctdbd_context);
 
        struct messaging_rec msg;
+       uint8_t *buf;
+       NTSTATUS status;
+
+       buf = iov_buf(talloc_tos(), iov, iovlen);
+       if (buf == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
 
        msg.msg_version = MESSAGE_VERSION;
        msg.msg_type    = msg_type;
        msg.dest        = pid;
-       msg.src         = msg_ctx->id;
-       msg.buf         = *data;
+       msg.src         = src;
+       msg.buf         = data_blob_const(buf, talloc_get_size(buf));
 
-       return ctdbd_messaging_send(ctx->conn, pid.vnn, pid.pid, &msg);
+       status = ctdbd_messaging_send(ctx->conn, pid.vnn, pid.pid, &msg);
+
+       TALLOC_FREE(buf);
+
+       return status;
 }
 
 static int messaging_ctdbd_destructor(struct messaging_ctdbd_context *ctx)
@@ -168,19 +178,3 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
        *presult = result;
        return NT_STATUS_OK;
 }
-
-#else
-
-NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
-                             TALLOC_CTX *mem_ctx,
-                             struct messaging_backend **presult)
-{
-       return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-struct ctdbd_connection *messaging_ctdbd_connection(void)
-{
-       return NULL;
-}
-
-#endif