#include "includes.h"
#include "messages.h"
#include "util_tdb.h"
+#include "lib/iov_buf.h"
/*
* It is not possible to include ctdb.h and tdb_compat.h (included via
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 server_id src,
- struct server_id pid, int msg_type,
- const struct iovec *iov, int iovlen,
- 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;
- buf = iov_buf(talloc_tos(), iov, iovlen);
- if (buf == NULL) {
- return NT_STATUS_NO_MEMORY;
+ if (num_fds > 0) {
+ return ENOSYS;
+ }
+
+ 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.msg_version = MESSAGE_VERSION;
- msg.msg_type = msg_type;
- msg.dest = pid;
- msg.src = src;
- msg.buf = data_blob_const(buf, talloc_get_size(buf));
+ 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);
- return status;
+ 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)