]> git.ozlabs.org Git - ccan/commitdiff
tdb2: unify tdb1_wipe into tdb_wipe.
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 31 Aug 2011 06:01:07 +0000 (15:31 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 31 Aug 2011 06:01:07 +0000 (15:31 +0930)
Switch on the TDB_VERSION1 flag.

ccan/tdb2/private.h
ccan/tdb2/tdb1.h
ccan/tdb2/traverse.c

index 2d4970fdc61c7ebc20760a6187b3de6f873d0b84..b801ffaf828f54b112a0116c436666e20da73461 100644 (file)
@@ -681,6 +681,7 @@ enum TDB_ERROR tdb1_parse_record(struct tdb_context *tdb, TDB_DATA key,
                                 void *private_data);
 void tdb1_increment_seqnum_nonblock(struct tdb_context *tdb);
 int tdb1_get_seqnum(struct tdb_context *tdb);
+int tdb1_wipe_all(struct tdb_context *tdb);
 
 /* tdb1_transaction.c: */
 int tdb1_transaction_start(struct tdb_context *tdb);
index 90cd7fa14abb9058629e22037ac676bc983609ac..3d9fcd70a466659b0291acab135891c76194d915 100644 (file)
@@ -42,8 +42,6 @@ uint64_t tdb1_incompatible_hash(const void *key, size_t len, uint64_t seed, void
 
 /* @} ******************************************************************/
 
-/* wipe and repack */
-int tdb1_wipe_all(struct tdb_context *tdb);
 int tdb1_repack(struct tdb_context *tdb);
 
 extern TDB_DATA tdb1_null;
index 8d9eeb45823a0809d0117f77488e0aaeddb19481..c525fdfe36a341e33ed65f2dff52bd974d8f693a 100644 (file)
@@ -115,6 +115,12 @@ enum TDB_ERROR tdb_wipe_all(struct tdb_context *tdb)
        enum TDB_ERROR ecode;
        int64_t count;
 
+       if (tdb->flags & TDB_VERSION1) {
+               if (tdb1_wipe_all(tdb) == -1)
+                       return tdb->last_error;
+               return TDB_SUCCESS;
+       }
+
        ecode = tdb_allrecord_lock(tdb, F_WRLCK, TDB_LOCK_WAIT, false);
        if (ecode != TDB_SUCCESS)
                return tdb->last_error = ecode;