summaryrefslogtreecommitdiff
path: root/source3/tdb/tdb.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-11-09 03:37:01 +0000
committerJeremy Allison <jra@samba.org>2002-11-09 03:37:01 +0000
commit02c58f3fb92c18ffb31c77a397163c44d70e3c93 (patch)
treeeb19a326e3413f4a0927c86c0dd2522423dfad42 /source3/tdb/tdb.c
parent8ce292d96f4841861ee8caf60278cafdfd6b9f55 (diff)
downloadsamba-02c58f3fb92c18ffb31c77a397163c44d70e3c93.tar.gz
samba-02c58f3fb92c18ffb31c77a397163c44d70e3c93.tar.bz2
samba-02c58f3fb92c18ffb31c77a397163c44d70e3c93.zip
Add chainlock_read functions to get a read lock. Used in *massively*
contended tdb's (and I've got one :-). Jeremy. (This used to be commit 064fa201ab73f476a168c40c2b227507e7342ec4)
Diffstat (limited to 'source3/tdb/tdb.c')
-rw-r--r--source3/tdb/tdb.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index 2a6dca16a8..e539376ac7 100644
--- a/source3/tdb/tdb.c
+++ b/source3/tdb/tdb.c
@@ -186,7 +186,7 @@ static int tdb_brlock(TDB_CONTEXT *tdb, tdb_off offset,
if (tdb->flags & TDB_NOLOCK)
return 0;
- if (tdb->read_only) {
+ if ((rw_type == F_WRLCK) && (tdb->read_only)) {
errno = EACCES;
return -1;
}
@@ -1802,6 +1802,16 @@ int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key)
return tdb_unlock(tdb, BUCKET(tdb_hash(&key)), F_WRLCK);
}
+int tdb_chainlock_read(TDB_CONTEXT *tdb, TDB_DATA key)
+{
+ return tdb_lock(tdb, BUCKET(tdb_hash(&key)), F_RDLCK);
+}
+
+int tdb_chainunlock_read(TDB_CONTEXT *tdb, TDB_DATA key)
+{
+ return tdb_unlock(tdb, BUCKET(tdb_hash(&key)), F_RDLCK);
+}
+
/* register a loging function */
void tdb_logging_function(TDB_CONTEXT *tdb, void (*fn)(TDB_CONTEXT *, int , const char *, ...))