From c8d05e934ea03fffbc34944d2d51a016b89a7eca Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 4 Nov 2014 09:51:51 +0100 Subject: tdb: allow tdb_open_ex() with O_RDONLY of TDB_FEATURE_FLAG_MUTEX tdbs. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10781 Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam --- lib/tdb/common/open.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/tdb/common/open.c') diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c index 16a76a347f..3b53fa7e3e 100644 --- a/lib/tdb/common/open.c +++ b/lib/tdb/common/open.c @@ -232,6 +232,14 @@ static bool tdb_mutex_open_ok(struct tdb_context *tdb, { int locked; + if (tdb->flags & TDB_NOLOCK) { + /* + * We don't look at locks, so it does not matter to have a + * compatible mutex implementation. Allow the open. + */ + return true; + } + locked = tdb_nest_lock(tdb, ACTIVE_LOCK, F_WRLCK, TDB_LOCK_NOWAIT|TDB_LOCK_PROBE); @@ -261,14 +269,6 @@ static bool tdb_mutex_open_ok(struct tdb_context *tdb, return false; } - if (tdb->flags & TDB_NOLOCK) { - /* - * We don't look at locks, so it does not matter to have a - * compatible mutex implementation. Allow the open. - */ - return true; - } - check_local_settings: if (!(tdb->flags & TDB_MUTEX_LOCKING)) { @@ -399,7 +399,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td tdb->read_only = 1; /* read only databases don't do locking or clear if first */ tdb->flags |= TDB_NOLOCK; - tdb->flags &= ~TDB_CLEAR_IF_FIRST; + tdb->flags &= ~(TDB_CLEAR_IF_FIRST|TDB_MUTEX_LOCKING); } if ((tdb->flags & TDB_ALLOW_NESTING) && -- cgit