diff options
author | Amitay Isaacs <amitay@gmail.com> | 2017-07-10 18:35:12 +1000 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2017-09-01 08:52:07 +0200 |
commit | 164d65ace283188d00224dd1e001b8776d393fd8 (patch) | |
tree | 3dacce08f4b6f02145b81638b6aa8ea564566f08 /ctdb | |
parent | 1787a4b63292aee0e9df4e4031188ac239d804d8 (diff) | |
download | samba-164d65ace283188d00224dd1e001b8776d393fd8.tar.gz |
ctdb-protocol: Replace ctdb_event_header with sock_packet_header
This removes the static declaration and adds prototype declarations
of ctdb_event_header marshalling functions to avoid compiler warnings.
These functions will be removed.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/client/client_event.c | 2 | ||||
-rw-r--r-- | ctdb/protocol/protocol.h | 4 | ||||
-rw-r--r-- | ctdb/protocol/protocol_event.c | 30 | ||||
-rw-r--r-- | ctdb/server/ctdb_eventd.c | 3 | ||||
-rw-r--r-- | ctdb/server/eventscript.c | 3 | ||||
-rw-r--r-- | ctdb/tests/src/protocol_common_event.c | 8 | ||||
-rw-r--r-- | ctdb/tests/src/protocol_event_test.c | 1 |
7 files changed, 29 insertions, 22 deletions
diff --git a/ctdb/client/client_event.c b/ctdb/client/client_event.c index 533ed39d240..9441e33aa60 100644 --- a/ctdb/client/client_event.c +++ b/ctdb/client/client_event.c @@ -224,7 +224,7 @@ struct tevent_req *ctdb_event_msg_send(TALLOC_CTX *mem_ctx, talloc_set_destructor(state, ctdb_event_msg_state_destructor); - ctdb_event_header_fill(&request->header, state->reqid); + sock_packet_header_set_reqid(&request->header, state->reqid); buflen = ctdb_event_request_len(request); buf = talloc_size(state, buflen); diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h index ad757d8c27d..15d2faa80f1 100644 --- a/ctdb/protocol/protocol.h +++ b/ctdb/protocol/protocol.h @@ -1087,12 +1087,12 @@ struct ctdb_event_header { }; struct ctdb_event_request { - struct ctdb_event_header header; + struct sock_packet_header header; struct ctdb_event_request_data rdata; }; struct ctdb_event_reply { - struct ctdb_event_header header; + struct sock_packet_header header; struct ctdb_event_reply_data rdata; }; diff --git a/ctdb/protocol/protocol_event.c b/ctdb/protocol/protocol_event.c index b1a7498be08..40e21ce2dfb 100644 --- a/ctdb/protocol/protocol_event.c +++ b/ctdb/protocol/protocol_event.c @@ -801,13 +801,19 @@ static int ctdb_event_reply_data_pull(uint8_t *buf, size_t buflen, return 0; } -static size_t ctdb_event_header_len(struct ctdb_event_header *in) +size_t ctdb_event_header_len(struct ctdb_event_header *in); +void ctdb_event_header_push(struct ctdb_event_header *in, uint8_t *buf, + size_t *npush); +int ctdb_event_header_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx, + struct ctdb_event_header *out, size_t *npull); + +size_t ctdb_event_header_len(struct ctdb_event_header *in) { return ctdb_uint32_len(&in->length) + ctdb_uint32_len(&in->reqid); } -static void ctdb_event_header_push(struct ctdb_event_header *in, uint8_t *buf, - size_t *npush) +void ctdb_event_header_push(struct ctdb_event_header *in, uint8_t *buf, + size_t *npush) { size_t offset = 0, np; @@ -820,10 +826,8 @@ static void ctdb_event_header_push(struct ctdb_event_header *in, uint8_t *buf, *npush = offset; } -static int ctdb_event_header_pull(uint8_t *buf, size_t buflen, - TALLOC_CTX *mem_ctx, - struct ctdb_event_header *out, - size_t *npull) +int ctdb_event_header_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx, + struct ctdb_event_header *out, size_t *npull) { size_t offset = 0, np; int ret; @@ -852,7 +856,7 @@ void ctdb_event_header_fill(struct ctdb_event_header *h, uint32_t reqid) size_t ctdb_event_request_len(struct ctdb_event_request *in) { - return ctdb_event_header_len(&in->header) + + return sock_packet_header_len(&in->header) + ctdb_event_request_data_len(&in->rdata); } @@ -869,7 +873,7 @@ int ctdb_event_request_push(struct ctdb_event_request *in, in->header.length = *buflen; - ctdb_event_header_push(&in->header, buf, &np); + sock_packet_header_push(&in->header, buf, &np); offset += np; ctdb_event_request_data_push(&in->rdata, buf+offset, &np); @@ -889,7 +893,7 @@ int ctdb_event_request_pull(uint8_t *buf, size_t buflen, size_t offset = 0, np; int ret; - ret = ctdb_event_header_pull(buf, buflen, mem_ctx, &out->header, &np); + ret = sock_packet_header_pull(buf, buflen, &out->header, &np); if (ret != 0) { return ret; } @@ -911,7 +915,7 @@ int ctdb_event_request_pull(uint8_t *buf, size_t buflen, size_t ctdb_event_reply_len(struct ctdb_event_reply *in) { - return ctdb_event_header_len(&in->header) + + return sock_packet_header_len(&in->header) + ctdb_event_reply_data_len(&in->rdata); } @@ -928,7 +932,7 @@ int ctdb_event_reply_push(struct ctdb_event_reply *in, in->header.length = *buflen; - ctdb_event_header_push(&in->header, buf, &np); + sock_packet_header_push(&in->header, buf, &np); offset += np; ctdb_event_reply_data_push(&in->rdata, buf+offset, &np); @@ -948,7 +952,7 @@ int ctdb_event_reply_pull(uint8_t *buf, size_t buflen, size_t offset = 0, np; int ret; - ret = ctdb_event_header_pull(buf, buflen, mem_ctx, &out->header, &np); + ret = sock_packet_header_pull(buf, buflen, &out->header, &np); if (ret != 0) { return ret; } diff --git a/ctdb/server/ctdb_eventd.c b/ctdb/server/ctdb_eventd.c index 52a2e757ee7..68ba2761b42 100644 --- a/ctdb/server/ctdb_eventd.c +++ b/ctdb/server/ctdb_eventd.c @@ -1019,7 +1019,8 @@ static void client_process_reply(struct tevent_req *req, size_t buflen; int ret; - ctdb_event_header_fill(&reply->header, state->request.header.reqid); + sock_packet_header_set_reqid(&reply->header, + state->request.header.reqid); buflen = ctdb_event_reply_len(reply); buf = talloc_zero_size(state, buflen); diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index 16d3b633bf6..41807ffdcb0 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -367,7 +367,8 @@ static int eventd_client_write(struct eventd_context *ectx, talloc_set_destructor(state, eventd_client_state_destructor); - ctdb_event_header_fill(&request->header, state->reqid); + sock_packet_header_set_reqid(&request->header, state->reqid); + state->buflen = ctdb_event_request_len(request); state->buf = talloc_size(state, state->buflen); if (state->buf == NULL) { diff --git a/ctdb/tests/src/protocol_common_event.c b/ctdb/tests/src/protocol_common_event.c index ff04fce33a9..6c71802aec2 100644 --- a/ctdb/tests/src/protocol_common_event.c +++ b/ctdb/tests/src/protocol_common_event.c @@ -272,27 +272,27 @@ void verify_ctdb_event_header(struct ctdb_event_header *h, void fill_ctdb_event_request(TALLOC_CTX *mem_ctx, struct ctdb_event_request *r, uint32_t command) { - fill_ctdb_event_header(&r->header); + fill_sock_packet_header(&r->header); fill_ctdb_event_request_data(mem_ctx, &r->rdata, command); } void verify_ctdb_event_request(struct ctdb_event_request *r, struct ctdb_event_request *r2) { - verify_ctdb_event_header(&r->header, &r2->header); + verify_sock_packet_header(&r->header, &r2->header); verify_ctdb_event_request_data(&r->rdata, &r2->rdata); } void fill_ctdb_event_reply(TALLOC_CTX *mem_ctx, struct ctdb_event_reply *r, uint32_t command) { - fill_ctdb_event_header(&r->header); + fill_sock_packet_header(&r->header); fill_ctdb_event_reply_data(mem_ctx, &r->rdata, command); } void verify_ctdb_event_reply(struct ctdb_event_reply *r, struct ctdb_event_reply *r2) { - verify_ctdb_event_header(&r->header, &r2->header); + verify_sock_packet_header(&r->header, &r2->header); verify_ctdb_event_reply_data(&r->rdata, &r2->rdata); } diff --git a/ctdb/tests/src/protocol_event_test.c b/ctdb/tests/src/protocol_event_test.c index 63d53011905..c48fdb12401 100644 --- a/ctdb/tests/src/protocol_event_test.c +++ b/ctdb/tests/src/protocol_event_test.c @@ -23,6 +23,7 @@ #include "protocol/protocol_types.c" #include "protocol/protocol_event.c" #include "protocol/protocol_packet.c" +#include "protocol/protocol_sock.c" #include "tests/src/protocol_common.h" #include "tests/src/protocol_common_event.h" |