Browse Source

tdb2: allow read-only databases to use locking.

You can always specify the TDB_NOLOCK flag along with O_RDONLY for the old
behaviour.
Rusty Russell 15 years ago
parent
commit
a39bf3aca1
2 changed files with 0 additions and 8 deletions
  1. 0 6
      ccan/tdb2/lock.c
  2. 0 2
      ccan/tdb2/tdb.c

+ 0 - 6
ccan/tdb2/lock.c

@@ -452,12 +452,6 @@ enum TDB_ERROR tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
 	enum TDB_ERROR ecode;
 	enum TDB_ERROR ecode;
 	tdb_bool_err berr;
 	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
 	if (tdb->allrecord_lock.count
 	    && (ltype == F_RDLCK || tdb->allrecord_lock.ltype == F_WRLCK)) {
 	    && (ltype == F_RDLCK || tdb->allrecord_lock.ltype == F_WRLCK)) {
 		tdb->allrecord_lock.count++;
 		tdb->allrecord_lock.count++;

+ 0 - 2
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) {
 	if ((open_flags & O_ACCMODE) == O_RDONLY) {
 		tdb->read_only = true;
 		tdb->read_only = true;
-		/* read only databases don't do locking */
-		tdb->flags |= TDB_NOLOCK;
 		tdb->mmap_flags = PROT_READ;
 		tdb->mmap_flags = PROT_READ;
 	} else {
 	} else {
 		tdb->read_only = false;
 		tdb->read_only = false;