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)
committerKarolin Seeger <kseeger@samba.org>
Fri, 16 Sep 2016 10:39:00 +0000 (12: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>
(cherry picked from commit bdff6255af113827340adc3da609e127503d9ba5)

Autobuild-User(v4-4-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-4-test): Fri Sep 16 12:39:00 CEST 2016 on sn-devel-144

ctdb/protocol/protocol_control.c

index e7487da117d12710482d5c56053a5e7bfc17d498..3a51b65fd09e0108e474e55363f35f986f688901 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;
@@ -384,8 +383,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:
@@ -501,8 +499,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);
@@ -724,8 +720,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:
@@ -824,7 +819,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;
 
@@ -1103,8 +1097,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: