summaryrefslogtreecommitdiff
path: root/source4/lib/tdb/common/tdb.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-09-22 13:12:46 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:44 -0500
commitbd310b792509f7305d7dc029eb4bec109322a4bf (patch)
tree7621c4474ccae12b9126e09c25bd6ff70fbc998e /source4/lib/tdb/common/tdb.c
parent05bd880626255c6547922204d7ba012aa9bc6d50 (diff)
downloadsamba-bd310b792509f7305d7dc029eb4bec109322a4bf.tar.gz
samba-bd310b792509f7305d7dc029eb4bec109322a4bf.tar.bz2
samba-bd310b792509f7305d7dc029eb4bec109322a4bf.zip
r10421: following on discussions with simo, I have worked out a way of
allowing searches to proceed while another process is in a transaction, then only upgrading the transaction lock to a write lock on commit. The solution is: - split tdb_traverse() into two calls, called tdb_traverse() and tdb_traverse_read(). The _read() version only gets read locks, and will fail any write operations made in the callback from the traverse. - the normal tdb_traverse() call allows for read or write operations in the callback, but gets the transaction lock, preventing transastions from starting inside the traverse In addition we enforce the following rule that you may not start a transaction within a traverse callback, although you can start a traverse within a transaction With these rules in place I believe all the deadlock possibilities are removed, and we can now allow for searches to happen in parallel with transactions (This used to be commit 7dd31288a701d772e45b1960ac4ce4cc1be782ed)
Diffstat (limited to 'source4/lib/tdb/common/tdb.c')
-rw-r--r--source4/lib/tdb/common/tdb.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/source4/lib/tdb/common/tdb.c b/source4/lib/tdb/common/tdb.c
index c37d37a4f2..2e229e88cc 100644
--- a/source4/lib/tdb/common/tdb.c
+++ b/source4/lib/tdb/common/tdb.c
@@ -227,6 +227,11 @@ int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
char *p = NULL;
int ret = 0;
+ if (tdb->read_only) {
+ tdb->ecode = TDB_ERR_RDONLY;
+ return -1;
+ }
+
/* find which hash bucket it is in */
hash = tdb->hash_fn(&key);
if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1)