From 9136818df30c7179e1cffa18201cdfc990ebd7b7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 22 Feb 2010 13:58:07 +1030 Subject: 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 --- lib/tdb/common/open.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/tdb/common/open.c') 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; -- cgit