summaryrefslogtreecommitdiff
path: root/lib/tdb/common/open.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2010-02-22 13:58:07 +1030
committerRusty Russell <rusty@rustcorp.com.au>2010-02-22 13:58:07 +1030
commit9136818df30c7179e1cffa18201cdfc990ebd7b7 (patch)
treee52bacd6be1238bdf194f7db72824227aca79593 /lib/tdb/common/open.c
parente8fa70a321d489b454b07bd65e9b0d95084168de (diff)
downloadsamba-9136818df30c7179e1cffa18201cdfc990ebd7b7.tar.gz
samba-9136818df30c7179e1cffa18201cdfc990ebd7b7.tar.bz2
samba-9136818df30c7179e1cffa18201cdfc990ebd7b7.zip
tdb: use tdb_nest_lock() for open lock.
This never nests, so it's overkill, but it centralizes the locking into lock.c and removes the ugly flag in the transaction code to track whether we have the lock or not. Note that we have a temporary hack so this places a real lock, despite the fact that we are in a transaction. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/tdb/common/open.c')
-rw-r--r--lib/tdb/common/open.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index 3fc9833863..1f948ff158 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -241,7 +241,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
fcntl(tdb->fd, F_SETFD, v | FD_CLOEXEC);
/* ensure there is only one process initialising at once */
- if (tdb->methods->brlock(tdb, F_WRLCK, OPEN_LOCK, 1, TDB_LOCK_WAIT) == -1) {
+ if (tdb_nest_lock(tdb, OPEN_LOCK, F_WRLCK, TDB_LOCK_WAIT) == -1) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: failed to get open lock on %s: %s\n",
name, strerror(errno)));
goto fail; /* errno set by tdb_brlock */
@@ -357,8 +357,9 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
/* Internal (memory-only) databases skip all the code above to
* do with disk files, and resume here by releasing their
* open lock and hooking into the active list. */
- if (tdb->methods->brunlock(tdb, F_WRLCK, OPEN_LOCK, 1) == -1)
+ if (tdb_nest_unlock(tdb, OPEN_LOCK, F_WRLCK, false) == -1) {
goto fail;
+ }
tdb->next = tdbs;
tdbs = tdb;
return tdb;