summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-11-04 09:51:51 +0100
committerMichael Adam <obnox@samba.org>2014-11-20 16:23:05 +0100
commitc8d05e934ea03fffbc34944d2d51a016b89a7eca (patch)
treeaee36d76ada21ac6c76bb582de885a64c3379be7
parent553b83c4d53a273a127e628d72c4edfc2950513d (diff)
downloadsamba-c8d05e934ea03fffbc34944d2d51a016b89a7eca.tar.gz
samba-c8d05e934ea03fffbc34944d2d51a016b89a7eca.tar.xz
samba-c8d05e934ea03fffbc34944d2d51a016b89a7eca.zip
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 <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
-rw-r--r--lib/tdb/common/open.c18
1 files changed, 9 insertions, 9 deletions
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) &&