mirror of
https://github.com/samba-team/samba.git
synced 2025-01-27 14:04:05 +03:00
ctdb-protocol: Use ctdb_string marshalling
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
fcb2ab7641
commit
324ae757c3
@ -1972,7 +1972,7 @@ int ctdb_reply_control_push(struct ctdb_req_header *h,
|
|||||||
{
|
{
|
||||||
struct ctdb_reply_control_wire *wire;
|
struct ctdb_reply_control_wire *wire;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
size_t length, buflen, datalen, errlen;
|
size_t length, buflen, datalen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (reply->status == 0) {
|
if (reply->status == 0) {
|
||||||
@ -1981,14 +1981,8 @@ int ctdb_reply_control_push(struct ctdb_req_header *h,
|
|||||||
datalen = 0;
|
datalen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply->errmsg == NULL) {
|
|
||||||
errlen = 0;
|
|
||||||
} else {
|
|
||||||
errlen = strlen(reply->errmsg) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
length = offsetof(struct ctdb_reply_control_wire, data) +
|
length = offsetof(struct ctdb_reply_control_wire, data) +
|
||||||
datalen + errlen;
|
datalen + ctdb_string_len(reply->errmsg);
|
||||||
|
|
||||||
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
ret = allocate_pkt(mem_ctx, length, &buf, &buflen);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
@ -2007,10 +2001,8 @@ int ctdb_reply_control_push(struct ctdb_req_header *h,
|
|||||||
ctdb_reply_control_data_push(&reply->rdata, wire->data);
|
ctdb_reply_control_data_push(&reply->rdata, wire->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
wire->errorlen = errlen;
|
wire->errorlen = ctdb_string_len(reply->errmsg);
|
||||||
if (errlen > 0) {
|
ctdb_string_push(reply->errmsg, wire->data + wire->datalen);
|
||||||
memcpy(wire->data + datalen, reply->errmsg, wire->errorlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
*pkt = buf;
|
*pkt = buf;
|
||||||
*pkt_len = buflen;
|
*pkt_len = buflen;
|
||||||
@ -2051,12 +2043,10 @@ int ctdb_reply_control_pull(uint8_t *pkt, size_t pkt_len, uint32_t opcode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wire->errorlen > 0) {
|
ret = ctdb_string_pull(wire->data + wire->datalen, wire->errorlen,
|
||||||
reply->errmsg = talloc_memdup(mem_ctx,
|
mem_ctx, &reply->errmsg);
|
||||||
wire->data + wire->datalen,
|
if (ret != 0) {
|
||||||
wire->errorlen);
|
return ret;
|
||||||
} else {
|
|
||||||
reply->errmsg = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user