fixed a bug found by volker - initialse the record on disk when initialised in memory
authorAndrew Tridgell <tridge@samba.org>
Thu, 19 Apr 2007 08:31:49 +0000 (18:31 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 19 Apr 2007 08:31:49 +0000 (18:31 +1000)
common/ctdb_ltdb.c

index d8c69c59c0b951f8abb1ed2979a99c59a7b05ddb..cb07a72375b51f1ff2d1da83d903057bbe51af78 100644 (file)
@@ -156,13 +156,15 @@ int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db,
 
        rec = tdb_fetch(ctdb_db->ltdb->tdb, key);
        if (rec.dsize < sizeof(*header)) {
+               TDB_DATA d2;
                /* return an initial header */
-               free(rec.dptr);
+               if (rec.dptr) free(rec.dptr);
                ltdb_initial_header(ctdb_db, key, header);
+               ZERO_STRUCT(d2);
                if (data) {
-                       data->dptr = NULL;
-                       data->dsize = 0;
+                       *data = d2;
                }
+               ctdb_ltdb_store(ctdb_db, key, header, d2);
                return 0;
        }