Skip to content

Commit

Permalink
ctdbd_conn: Move ndr marshalling to messages_ctdb.c
Browse files Browse the repository at this point in the history
The inter-node message format belongs into messages_ctdb, not into the
generic ctdb connection layer

Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Stefan Metzmacher <[email protected]>
  • Loading branch information
vlendec committed May 28, 2015
1 parent 7ce9f3f commit 1052d31
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 39 deletions.
3 changes: 0 additions & 3 deletions source3/include/ctdbd_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn);

int ctdbd_conn_get_fd(struct ctdbd_connection *conn);

NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn,
uint32_t dst_vnn, uint64_t dst_srvid,
struct messaging_rec *msg);
NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn,
uint32_t dst_vnn, uint64_t dst_srvid,
const uint8_t *buf, size_t buflen);
Expand Down
7 changes: 0 additions & 7 deletions source3/lib/ctdb_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ NTSTATUS ctdbd_probe(void)
return NT_STATUS_NOT_IMPLEMENTED;
}

NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn,
uint32_t dst_vnn, uint64_t dst_srvid,
struct messaging_rec *msg)
{
return NT_STATUS_NOT_IMPLEMENTED;
}

NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn,
uint32_t dst_vnn, uint64_t dst_srvid,
const uint8_t *buf, size_t buflen)
Expand Down
28 changes: 0 additions & 28 deletions source3/lib/ctdbd_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,34 +608,6 @@ NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
return NT_STATUS_OK;
}

/*
* Send a messaging message across a ctdbd
*/

NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn,
uint32_t dst_vnn, uint64_t dst_srvid,
struct messaging_rec *msg)
{
DATA_BLOB blob;
NTSTATUS status;
enum ndr_err_code ndr_err;

ndr_err = ndr_push_struct_blob(
&blob, talloc_tos(), msg,
(ndr_push_flags_fn_t)ndr_push_messaging_rec);

if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
DEBUG(0, ("ndr_push_struct_blob failed: %s\n",
ndr_errstr(ndr_err)));
return ndr_map_error2ntstatus(ndr_err);
}

status = ctdbd_messaging_send_blob(conn, dst_vnn, dst_srvid,
blob.data, blob.length);
TALLOC_FREE(blob.data);
return status;
}

NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn,
uint32_t dst_vnn, uint64_t dst_srvid,
const uint8_t *buf, size_t buflen)
Expand Down
15 changes: 14 additions & 1 deletion source3/lib/messages_ctdbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ static int messaging_ctdb_send(struct server_id src,
struct messaging_rec msg;
uint8_t *buf;
ssize_t buflen;
DATA_BLOB blob;
NTSTATUS status;
enum ndr_err_code ndr_err;

if (num_fds > 0) {
return ENOSYS;
Expand All @@ -108,8 +110,19 @@ static int messaging_ctdb_send(struct server_id src,
.buf = data_blob_const(buf, talloc_get_size(buf)),
};

status = ctdbd_messaging_send(ctx->conn, pid.vnn, pid.pid, &msg);
ndr_err = ndr_push_struct_blob(
&blob, buf, &msg,
(ndr_push_flags_fn_t)ndr_push_messaging_rec);

if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
DEBUG(0, ("ndr_push_struct_blob failed: %s\n",
ndr_errstr(ndr_err)));
TALLOC_FREE(buf);
return ndr_map_error2errno(ndr_err);
}

status = ctdbd_messaging_send_blob(ctx->conn, pid.vnn, pid.pid,
blob.data, blob.length);
TALLOC_FREE(buf);

if (NT_STATUS_IS_OK(status)) {
Expand Down

0 comments on commit 1052d31

Please sign in to comment.