s3:dbwrap: add dbwrap_tdb_require_mutexes:*= option
authorStefan Metzmacher <metze@samba.org>
Sat, 16 Jan 2016 09:19:23 +0000 (10:19 +0100)
committerRalph Boehme <slow@samba.org>
Mon, 8 Feb 2016 21:32:23 +0000 (22:32 +0100)
This is similar to dbwrap_tdb_mutexes:*= (which is autodetected by default),
but dbwrap_tdb_require_mutexes is off by default.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/lib/dbwrap/dbwrap_open.c

index 59fb3e4e8daf2d0029e9b3f9292573855fb917d4..98e4f41cb00ac944a1940d8d9f583eadb7a7a3df 100644 (file)
@@ -97,6 +97,7 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
        if (tdb_flags & TDB_CLEAR_IF_FIRST) {
                const char *base;
                bool try_mutex = false;
+               bool require_mutex = false;
 
                base = strrchr_m(name, '/');
                if (base != NULL) {
@@ -111,6 +112,15 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
                if (try_mutex && tdb_runtime_check_for_robust_mutexes()) {
                        tdb_flags |= TDB_MUTEX_LOCKING;
                }
+
+               require_mutex = lp_parm_bool(-1, "dbwrap_tdb_require_mutexes",
+                                          "*", require_mutex);
+               require_mutex = lp_parm_bool(-1, "dbwrap_tdb_require_mutexes",
+                                          base, require_mutex);
+
+               if (require_mutex) {
+                       tdb_flags |= TDB_MUTEX_LOCKING;
+               }
        }
 
        sockname = lp_ctdbd_socket();