ctdb-protocol: Fix marshalling for GET_DB_SEQNUM control request
authorAmitay Isaacs <amitay@gmail.com>
Tue, 13 Sep 2016 06:05:14 +0000 (16:05 +1000)
committerMartin Schwenke <martins@samba.org>
Wed, 14 Sep 2016 06:39:28 +0000 (08:39 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12259

Even though database id is 32-bit, it's sent on wire as 64-bits.
The database id is the first 32-bits on the wire.  This needs fixing
eventually, but for now keep the same wire format.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/protocol/protocol_control.c

index d5237ecc60913832169ca6287f474ad2251b7187..a909fc651509dd28c3d2a719c56f41302d8df897 100644 (file)
@@ -49,7 +49,6 @@ struct ctdb_reply_control_wire {
 static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
 {
        size_t len = 0;
-       uint64_t u64;
 
        if (cd == NULL) {
                return 0;
@@ -335,8 +334,7 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
                break;
 
        case CTDB_CONTROL_GET_DB_SEQNUM:
-               u64 = cd->data.db_id;
-               len = ctdb_uint64_len(u64);
+               len = ctdb_uint64_len((uint64_t)cd->data.db_id);
                break;
 
        case CTDB_CONTROL_DB_SET_HEALTHY:
@@ -452,8 +450,6 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
 static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd,
                                       uint8_t *buf)
 {
-       uint64_t u64;
-
        switch (cd->opcode) {
        case CTDB_CONTROL_PROCESS_EXISTS:
                ctdb_pid_push(cd->data.pid, buf);
@@ -635,8 +631,7 @@ static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd,
                break;
 
        case CTDB_CONTROL_GET_DB_SEQNUM:
-               u64 = cd->data.db_id;
-               ctdb_uint64_push(u64, buf);
+               ctdb_uint32_push(cd->data.db_id, buf);
                break;
 
        case CTDB_CONTROL_DB_SET_HEALTHY:
@@ -735,7 +730,6 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
                                      struct ctdb_req_control_data *cd)
 {
        int ret = 0;
-       uint64_t u64 = 0;
 
        cd->opcode = opcode;
 
@@ -964,8 +958,8 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
                break;
 
        case CTDB_CONTROL_GET_DB_SEQNUM:
-               ret = ctdb_uint64_pull(buf, buflen, mem_ctx, &u64);
-               cd->data.db_id = (uint32_t)u64;
+               ret = ctdb_uint32_pull(buf, buflen, mem_ctx,
+                                      &cd->data.db_id);
                break;
 
        case CTDB_CONTROL_DB_SET_HEALTHY: