From: Rusty Russell Date: Tue, 1 Mar 2011 12:49:18 +0000 (+1030) Subject: tdb2: allow read-only databases to use locking. X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=a39bf3aca1b60365efaf8b1eeb2b2c58b09ffab6;ds=sidebyside tdb2: allow read-only databases to use locking. You can always specify the TDB_NOLOCK flag along with O_RDONLY for the old behaviour. --- diff --git a/ccan/tdb2/lock.c b/ccan/tdb2/lock.c index c5dd084e..b57c5344 100644 --- a/ccan/tdb2/lock.c +++ b/ccan/tdb2/lock.c @@ -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++; diff --git a/ccan/tdb2/tdb.c b/ccan/tdb2/tdb.c index c087aad2..f6ca0165 100644 --- a/ccan/tdb2/tdb.c +++ b/ccan/tdb2/tdb.c @@ -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;