ctdb-client: Fix ctdb_rec_buffer traversal routine
authorAmitay Isaacs <amitay@gmail.com>
Tue, 19 Apr 2016 06:01:05 +0000 (16:01 +1000)
committerMartin Schwenke <martins@samba.org>
Tue, 5 Jul 2016 08:53:14 +0000 (10:53 +0200)
In commit 1ee7053180057ea526870182b5619a206b4d103b, the
ctdb_rec_buffer_traverse always passes NULL for header.  So explicitly
extract header from the data.

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

index 85d14e3fce3ec4c4f8edc939dcd7a6943477423e..4bc30fcd6bd2fc0360507977d6ff92b00596c079 100644 (file)
@@ -1802,19 +1802,26 @@ struct ctdb_transaction_record_fetch_state {
        bool found;
 };
 
-static int ctdb_transaction_record_fetch_traverse(uint32_t reqid,
-                                                 struct ctdb_ltdb_header *header,
-                                                 TDB_DATA key,
-                                                 TDB_DATA data,
-                                                 void *private_data)
+static int ctdb_transaction_record_fetch_traverse(
+                               uint32_t reqid,
+                               struct ctdb_ltdb_header *nullheader,
+                               TDB_DATA key, TDB_DATA data,
+                               void *private_data)
 {
        struct ctdb_transaction_record_fetch_state *state =
                (struct ctdb_transaction_record_fetch_state *)private_data;
 
        if (state->key.dsize == key.dsize &&
            memcmp(state->key.dptr, key.dptr, key.dsize) == 0) {
+               int ret;
+
+               ret = ctdb_ltdb_header_extract(&data, &state->header);
+               if (ret != 0) {
+                       DEBUG(DEBUG_ERR, ("Failed to extract header\n"));
+                       return 1;
+               }
+
                state->data = data;
-               state->header = *header;
                state->found = true;
        }