dbwrap_tdb: Use mutexes on demand
authorVolker Lendecke <vl@samba.org>
Tue, 19 Mar 2013 11:02:22 +0000 (12:02 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 22 May 2014 19:05:15 +0000 (21:05 +0200)
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/dbwrap/dbwrap_open.c

index 81f20b048d5390460d7658a73ab9a3b29de2596b..64f484e70a5510d27717ebb39c3a010989e85ead 100644 (file)
@@ -93,6 +93,25 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
                }
        }
 
+       if (tdb_flags & TDB_CLEAR_IF_FIRST) {
+               const char *base;
+               bool try_mutex = false;
+
+               base = strrchr_m(name, '/');
+               if (base != NULL) {
+                       base += 1;
+               } else {
+                       base = name;
+               }
+
+               try_mutex = lp_parm_bool(-1, "dbwrap_tdb_mutexes", "*", try_mutex);
+               try_mutex = lp_parm_bool(-1, "dbwrap_tdb_mutexes", base, try_mutex);
+
+               if (try_mutex && tdb_runtime_check_for_robust_mutexes()) {
+                       tdb_flags |= TDB_MUTEX_LOCKING;
+               }
+       }
+
        sockname = lp_ctdbd_socket();
 
        if (lp_clustering()) {