#include "includes.h"
#include "messages.h"
#include "util_tdb.h"
-
-#ifdef CLUSTER_SUPPORT
+#include "lib/iov_buf.h"
/*
* It is not possible to include ctdb.h and tdb_compat.h (included via
if (global_ctdb_connection_pid == 0 &&
global_ctdbd_connection == NULL) {
- struct event_context *ev;
+ struct tevent_context *ev;
struct messaging_context *msg;
ev = samba_tevent_context_init(NULL);
if (global_ctdb_connection_pid != getpid()) {
DEBUG(0,("messaging_ctdbd_connection():"
- "valid for pid[%d] but it's [%d]\n",
- global_ctdb_connection_pid, getpid()));
+ "valid for pid[%jd] but it's [%jd]\n",
+ (intmax_t)global_ctdb_connection_pid,
+ (intmax_t)getpid()));
smb_panic("messaging_ctdbd_connection() invalid process\n");
}
return global_ctdbd_connection;
}
-static NTSTATUS messaging_ctdb_send(struct messaging_context *msg_ctx,
- struct server_id pid, int msg_type,
- const DATA_BLOB *data,
- struct messaging_backend *backend)
+static int messaging_ctdb_send(struct server_id src,
+ struct server_id pid, int msg_type,
+ const struct iovec *iov, int iovlen,
+ const int *fds, size_t num_fds,
+ 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;
+ ssize_t buflen;
+ NTSTATUS status;
- msg.msg_version = MESSAGE_VERSION;
- msg.msg_type = msg_type;
- msg.dest = pid;
- msg.src = msg_ctx->id;
- msg.buf = *data;
+ if (num_fds > 0) {
+ return ENOSYS;
+ }
- return ctdbd_messaging_send(ctx->conn, pid.vnn, pid.pid, &msg);
+ buflen = iov_buflen(iov, iovlen);
+ if (buflen == -1) {
+ return EMSGSIZE;
+ }
+
+ buf = talloc_array(talloc_tos(), uint8_t, buflen);
+ if (buflen == NULL) {
+ return ENOMEM;
+ }
+ iov_buf(iov, iovlen, buf, buflen);
+
+ msg = (struct messaging_rec) {
+ .msg_version = MESSAGE_VERSION,
+ .msg_type = msg_type,
+ .dest = pid,
+ .src = src,
+ .buf = data_blob_const(buf, talloc_get_size(buf)),
+ };
+
+ status = ctdbd_messaging_send(ctx->conn, pid.vnn, pid.pid, &msg);
+
+ TALLOC_FREE(buf);
+
+ if (NT_STATUS_IS_OK(status)) {
+ return 0;
+ }
+ return map_errno_from_nt_status(status);
}
static int messaging_ctdbd_destructor(struct messaging_ctdbd_context *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