s3:dbwrap_ctdb: fix logic error in pull_newest_from_marshall_buffer().
authorMichael Adam <obnox@samba.org>
Tue, 5 Jan 2010 23:37:21 +0000 (00:37 +0100)
committerMichael Adam <obnox@samba.org>
Tue, 5 Jan 2010 23:37:21 +0000 (00:37 +0100)
The logic bug was that if a record was found in the marshall buffer,
then always the ctdb header of tha last record in the marshall buffer
was returned, and not the ctdb header of the last occurrence of the
requested record.

This is fixed by introducing an additional temporary variable.

Michael

source3/lib/dbwrap_ctdb.c

index d6fde3560d5b58ffc182cffcace05f13509e6634..4e97d26ae82675fcaa38740aa8ef88af3980b148 100644 (file)
@@ -403,8 +403,11 @@ static bool pull_newest_from_marshall_buffer(struct ctdb_marshall_buffer *buf,
        for (i=0; i<buf->count; i++) {
                TDB_DATA tkey, tdata;
                uint32_t reqid;
+               struct ctdb_ltdb_header hdr;
 
-               rec = db_ctdb_marshall_loop_next(buf, rec, &reqid, &h, &tkey,
+               ZERO_STRUCT(hdr);
+
+               rec = db_ctdb_marshall_loop_next(buf, rec, &reqid, &hdr, &tkey,
                                                 &tdata);
                if (rec == NULL) {
                        return false;
@@ -413,6 +416,7 @@ static bool pull_newest_from_marshall_buffer(struct ctdb_marshall_buffer *buf,
                if (tdb_data_equal(key, tkey)) {
                        found = true;
                        data = tdata;
+                       h = hdr;
                }
        }