mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
ctdb-protocol: Fix marshalling for ctdb_reply_control_data
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
c88c317a66
commit
e4fa09fae3
@ -1425,9 +1425,9 @@ static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data *cd)
|
||||
}
|
||||
|
||||
static void ctdb_reply_control_data_push(struct ctdb_reply_control_data *cd,
|
||||
uint8_t *buf)
|
||||
uint8_t *buf, size_t *npush)
|
||||
{
|
||||
size_t np;
|
||||
size_t np = 0;
|
||||
|
||||
switch (cd->opcode) {
|
||||
case CTDB_CONTROL_STATISTICS:
|
||||
@ -1581,13 +1581,16 @@ static void ctdb_reply_control_data_push(struct ctdb_reply_control_data *cd,
|
||||
ctdb_uint32_push(&cd->data.db_id, buf, &np);
|
||||
break;
|
||||
}
|
||||
|
||||
*npush = np;
|
||||
}
|
||||
|
||||
static int ctdb_reply_control_data_pull(uint8_t *buf, size_t buflen,
|
||||
uint32_t opcode, TALLOC_CTX *mem_ctx,
|
||||
struct ctdb_reply_control_data *cd)
|
||||
struct ctdb_reply_control_data *cd,
|
||||
size_t *npull)
|
||||
{
|
||||
size_t np;
|
||||
size_t np = 0;
|
||||
int ret = 0;
|
||||
|
||||
cd->opcode = opcode;
|
||||
@ -1771,7 +1774,12 @@ static int ctdb_reply_control_data_pull(uint8_t *buf, size_t buflen,
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
*npull = np;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t ctdb_req_control_len(struct ctdb_req_header *h,
|
||||
@ -1888,7 +1896,7 @@ int ctdb_reply_control_push(struct ctdb_req_header *h,
|
||||
if (reply->status == 0) {
|
||||
wire->datalen = ctdb_reply_control_data_len(&reply->rdata);
|
||||
wire->errorlen = 0;
|
||||
ctdb_reply_control_data_push(&reply->rdata, wire->data);
|
||||
ctdb_reply_control_data_push(&reply->rdata, wire->data, &np);
|
||||
} else {
|
||||
wire->datalen = 0;
|
||||
wire->errorlen = ctdb_string_len(&reply->errmsg);
|
||||
@ -1939,7 +1947,7 @@ int ctdb_reply_control_pull(uint8_t *buf, size_t buflen, uint32_t opcode,
|
||||
if (c->status != -1) {
|
||||
ret = ctdb_reply_control_data_pull(wire->data, wire->datalen,
|
||||
opcode, mem_ctx,
|
||||
&c->rdata);
|
||||
&c->rdata, &np);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -26,8 +26,7 @@ output=$(
|
||||
echo "ctdb_req_dmaster"
|
||||
echo "ctdb_reply_dmaster"
|
||||
generate_control_output "ctdb_req_control_data"
|
||||
echo "ctdb_reply_control_data"
|
||||
echo "$control_output"
|
||||
generate_control_output "ctdb_reply_control_data"
|
||||
echo "ctdb_req_control"
|
||||
echo "$control_output"
|
||||
echo "ctdb_reply_control"
|
||||
|
@ -292,36 +292,7 @@ PROTOCOL_CTDB4_TEST(struct ctdb_reply_dmaster, ctdb_reply_dmaster,
|
||||
#define NUM_CONTROLS 151
|
||||
|
||||
PROTOCOL_CTDB2_TEST(struct ctdb_req_control_data, ctdb_req_control_data);
|
||||
|
||||
static void test_ctdb_reply_control_data(void)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx;
|
||||
size_t buflen;
|
||||
int ret;
|
||||
struct ctdb_reply_control_data cd, cd2;
|
||||
uint32_t opcode;
|
||||
|
||||
printf("ctdb_reply_control_data\n");
|
||||
fflush(stdout);
|
||||
|
||||
for (opcode=0; opcode<NUM_CONTROLS; opcode++) {
|
||||
mem_ctx = talloc_new(NULL);
|
||||
assert(mem_ctx != NULL);
|
||||
|
||||
printf("%u.. ", opcode);
|
||||
fflush(stdout);
|
||||
fill_ctdb_reply_control_data(mem_ctx, &cd, opcode);
|
||||
buflen = ctdb_reply_control_data_len(&cd);
|
||||
ctdb_reply_control_data_push(&cd, BUFFER);
|
||||
ret = ctdb_reply_control_data_pull(BUFFER, buflen, opcode, mem_ctx, &cd2);
|
||||
assert(ret == 0);
|
||||
verify_ctdb_reply_control_data(&cd, &cd2);
|
||||
talloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
PROTOCOL_CTDB2_TEST(struct ctdb_reply_control_data, ctdb_reply_control_data);
|
||||
|
||||
static void test_ctdb_req_control(void)
|
||||
{
|
||||
@ -476,7 +447,9 @@ int main(int argc, char *argv[])
|
||||
for (opcode=0; opcode<NUM_CONTROLS; opcode++) {
|
||||
TEST_FUNC(ctdb_req_control_data)(opcode);
|
||||
}
|
||||
test_ctdb_reply_control_data();
|
||||
for (opcode=0; opcode<NUM_CONTROLS; opcode++) {
|
||||
TEST_FUNC(ctdb_reply_control_data)(opcode);
|
||||
}
|
||||
|
||||
test_ctdb_req_control();
|
||||
test_ctdb_reply_control();
|
||||
|
Loading…
x
Reference in New Issue
Block a user