X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb%2Ftdb.c;h=7317a3aa521554c898d12a5e5b8f57c7dafea36f;hp=bf767099d2028908c68eb4dd0e2d77efe7874d30;hb=cc2d609dfca7192305ad477b8c2b52cfdc1aa9be;hpb=d6b6780d0bc3dbdaaf679bbc308f74042f933cfd diff --git a/ccan/tdb/tdb.c b/ccan/tdb/tdb.c index bf767099..7317a3aa 100644 --- a/ccan/tdb/tdb.c +++ b/ccan/tdb/tdb.c @@ -59,14 +59,14 @@ static void tdb_increment_seqnum(struct tdb_context *tdb) return; } - if (tdb_brlock(tdb, F_WRLCK, TDB_SEQNUM_OFS, 1, - TDB_LOCK_WAIT|TDB_LOCK_PROBE) != 0) { + if (tdb_nest_lock(tdb, TDB_SEQNUM_OFS, F_WRLCK, + TDB_LOCK_WAIT|TDB_LOCK_PROBE) != 0) { return; } tdb_increment_seqnum_nonblock(tdb); - tdb_brunlock(tdb, F_WRLCK, TDB_SEQNUM_OFS, 1); + tdb_nest_unlock(tdb, TDB_SEQNUM_OFS, F_WRLCK, false); } static int tdb_key_compare(TDB_DATA key, TDB_DATA data, void *private_data) @@ -213,7 +213,7 @@ TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key) * function. The parsing function is executed under the chain read lock, so it * should be fast and should not block on other syscalls. * - * DONT CALL OTHER TDB CALLS FROM THE PARSER, THIS MIGHT LEAD TO SEGFAULTS. + * DON'T CALL OTHER TDB CALLS FROM THE PARSER, THIS MIGHT LEAD TO SEGFAULTS. * * For mmapped tdb's that do not have a transaction open it points the parsing * function directly at the mmap area, it avoids the malloc/memcpy in this @@ -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->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; @@ -805,7 +805,7 @@ static int tdb_free_region(struct tdb_context *tdb, tdb_off_t offset, ssize_t le /* wipe the entire database, deleting all records. This can be done - very fast by using a global lock. The entire data portion of the + very fast by using a allrecord lock. The entire data portion of the file becomes a single entry in the freelist. This code carefully steps around the recovery area, leaving it alone