tdb: commit 9b987e3923f7e8714acec6a2929435b1e6016645 from SAMBA
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 22 Feb 2010 02:51:24 +0000 (13:21 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 22 Feb 2010 02:51:24 +0000 (13:21 +1030)
Author: Volker Lendecke <vl@samba.org>
Date:   Tue Aug 12 22:31:52 2008 +0200

    Attempt to fix bug 5684

    With the ctdb checkin dde9f3f006 tdb optimized out write lock checks for
    write-enabled transaction. Sadly, this also removed the possibility to ever
    remove dead records left over from tdb_delete calls within a transaction.

    Tridge, please check this! Did dde9f3f006 have any reason beyond performance
    optimizations?

    Thanks,

    Volker
    (This used to be commit 3f884c4ae36f3260e63626bdd4989d9258ae6497)

ccan/tdb/tdb.c

index bf767099d2028908c68eb4dd0e2d77efe7874d30..c6ce4548542cfc5222d7415fea952d0adff99519 100644 (file)
@@ -286,7 +286,7 @@ int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct tdb_record
 
        if (tdb->read_only || tdb->traverse_read) return -1;
 
 
        if (tdb->read_only || tdb->traverse_read) return -1;
 
-       if (tdb->traverse_write != 0 || 
+       if (((tdb->traverse_write != 0) && (!TDB_DEAD(rec))) ||
            tdb_write_lock_record(tdb, rec_ptr) == -1) {
                /* Someone traversing here: mark it as dead */
                rec->magic = TDB_DEAD_MAGIC;
            tdb_write_lock_record(tdb, rec_ptr) == -1) {
                /* Someone traversing here: mark it as dead */
                rec->magic = TDB_DEAD_MAGIC;