]> git.ozlabs.org Git - ccan/commitdiff
tdb2: allow read-only databases to use locking.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 1 Mar 2011 12:49:18 +0000 (23:19 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 1 Mar 2011 12:49:18 +0000 (23:19 +1030)
You can always specify the TDB_NOLOCK flag along with O_RDONLY for the old
behaviour.

ccan/tdb2/lock.c
ccan/tdb2/tdb.c

index c5dd084e82bf04af7c1dee6b12996f25749276cc..b57c53449466437c7cdd16cdc21ff4c67866b8a9 100644 (file)
@@ -452,12 +452,6 @@ enum TDB_ERROR tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
        enum TDB_ERROR ecode;
        tdb_bool_err berr;
 
-       /* FIXME: There are no locks on read-only dbs */
-       if (tdb->read_only) {
-               return tdb_logerr(tdb, TDB_ERR_LOCK, TDB_LOG_USE_ERROR,
-                                 "tdb_allrecord_lock: read-only");
-       }
-
        if (tdb->allrecord_lock.count
            && (ltype == F_RDLCK || tdb->allrecord_lock.ltype == F_WRLCK)) {
                tdb->allrecord_lock.count++;
index c087aad25ea9c9e782f722de6bcacec720cac239..f6ca01657518af29c1111700c530abda29ba7d43 100644 (file)
@@ -245,8 +245,6 @@ struct tdb_context *tdb_open(const char *name, int tdb_flags,
 
        if ((open_flags & O_ACCMODE) == O_RDONLY) {
                tdb->read_only = true;
-               /* read only databases don't do locking */
-               tdb->flags |= TDB_NOLOCK;
                tdb->mmap_flags = PROT_READ;
        } else {
                tdb->read_only = false;