[PATCH] tdb: runtime check for robust mutexes may hang

Ralph Böhme slow at samba.org
Sun Mar 12 13:14:43 UTC 2017


Hi!

Attached is a fix for bug:

<https://bugzilla.samba.org/show_bug.cgi?id=12593>

Calling tdb_runtime_check_for_robust_mutexes() in multithreaded programs can
hang in sigsuspend() due to lost SIGCHLD.

Example stack back-trace from the bugreport:

  Thread 5 (Thread 0x7f2ea5037700 (LWP 1054)):
  #0  0x00007f2eb6325506 in sigsuspend () at /usr/lib/libc.so.6
  #1  0x00007f2ead463802 in tdb_runtime_check_for_robust_mutexes () at /usr/lib/libtdb.so.1
  #2  0x00007f2eade9b05d in tdb_wrap_open () at /usr/lib/samba/libtdb-wrap-samba4.so
  #3  0x00007f2eb4e49b21 in  () at /usr/lib/libsmbconf.so.0
  #4  0x00007f2eb4e4a305 in gencache_parse () at /usr/lib/libsmbconf.so.0
  #5  0x00007f2eb4e4a862 in gencache_get_data_blob () at /usr/lib/libsmbconf.so.0
  #6  0x00007f2eb4e4a90b in gencache_get () at /usr/lib/libsmbconf.so.0
  #7  0x00007f2eb422f74a in sitename_fetch () at /usr/lib/samba/libgse-samba4.so
  #8  0x00007f2eb422d7da in resolve_name () at /usr/lib/samba/libgse-samba4.so
  #9  0x00007f2eb762a5e2 in  () at /usr/lib/libsmbclient.so.0
  #10 0x0000000000406ebd in do_mount (...)
  #11 0x00007f2eb7407f4a in g_vfs_job_run (job=0x12b72b0 [GVfsJobMount]) ...
  #12 0x00007f2eb6920c9e in g_thread_pool_thread_proxy (data=<optimized out>) ...
  #13 0x00007f2eb69202a5 in g_thread_proxy (data=0x7f2e98004720) at gthread.c:784
  #14 0x00007f2eb6697444 in start_thread () at /usr/lib/libpthread.so.0
  #15 0x00007f2eb63d9cff in clone () at /usr/lib/libc.so.6

As there's no POSIX function to change the signal mask of all threads in a
process, this problem can't be solved by a change to
tdb_runtime_check_for_robust_mutexes().

Attached patch *moves* the runtime check to a library initializer which
guarantees that only one thread exists in the process when the function is run.

tdb_runtime_check_for_robust_mutexes() is marked as deprecated but not removed
from the API in order to prevent a incompatible ABI change that requires a major
version number bump (which could be done of course).

I'm adding a new function to the API that merely fetches the stored result of
the runtime check done at library initialisation. All existing callers of
tdb_runtime_check_for_robust_mutexes() are changed to call the new function.

This means we're essentially tying the support for robust mutexes to compiler
support for library initializers via a contructor attribute.

Again:

this means we're essentially tying the support for robust mutexes to compiler
support for library initializers via a contructor attribute.

sleep(60);

To the best of my knowledge, only Linux, FreeBSD and Solaris have support for
robust mutexes and the following OS/compiler combinations have been successfully
tested with this change:

o Linux with gcc and clang

o FreeBSD with gcc and clang

o Solaris with gcc

Having code still directly or indirectly calling
tdb_runtime_check_for_robust_mutexes() just doesn't feel right as we know it's
broken by design for multi-threaded programs and we're already using threads
under the hoods in some places.

Thoughts? Please review and comment, but don't push yet, I believe this needs
some time to sink into the minds of everyone interested.

Cheerio!
-slow
-------------- next part --------------
From 4d8620bc803880decb4330dae83a5f1cb1ef48f0 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sat, 11 Mar 2017 08:48:25 +0100
Subject: [PATCH 1/7] lib/tdb: rename basic robust mutex checking func

A subsequent commit will add a new public API function by the same name
tdb_mutex_locking_supported(). Rename this internal function so we can
then use the name for the new public funcion.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12593

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 lib/tdb/common/mutex.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/tdb/common/mutex.c b/lib/tdb/common/mutex.c
index cac3916..f4c2353 100644
--- a/lib/tdb/common/mutex.c
+++ b/lib/tdb/common/mutex.c
@@ -659,7 +659,7 @@ int tdb_mutex_munmap(struct tdb_context *tdb)
 
 static bool tdb_mutex_locking_cached;
 
-static bool tdb_mutex_locking_supported(void)
+static bool tdb_mutex_locking_basic_check(void)
 {
 	pthread_mutexattr_t ma;
 	pthread_mutex_t m;
@@ -800,7 +800,7 @@ _PUBLIC_ bool tdb_runtime_check_for_robust_mutexes(void)
 
 	sigemptyset(&suspend_mask);
 
-	ok = tdb_mutex_locking_supported();
+	ok = tdb_mutex_locking_basic_check();
 	if (!ok) {
 		return false;
 	}
-- 
2.9.3


From 4de1e57c58ce6d9656bd105371d43d4128f7761c Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Fri, 10 Mar 2017 15:22:42 +0100
Subject: [PATCH 2/7] lib/tdb: add library initializer to run robust mutex
 runtime check

The current runtime check for robust mutexes in
tdb_runtime_check_for_robust_mutexes() is not thread-safe.

When called in a multi-threaded program where any another thread doesn't
have SIGCHLD blocked, we may end up hung in sigsuspend() waiting for a
SIGCHLD of a child procecss and the signal was delivered to another
thread.

As there's no POSIX function to change the signal mask of all threads in
a process, this problem can't be solved by a change to
tdb_runtime_check_for_robust_mutexes().

Moving the runtime check to a library initializer guarantees that only
one thread exists in the process so the lost signal problem is solved.

To the best of my knowledge, only Linux, FreeBSD and Solaris have
support for robust mutexed.

The following OS/compiler combinations have been successfully tested
with this change:

o Linux with gcc and clang

o FreeBSD with gcc and clang

o Solaris with gcc

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12593

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 lib/tdb/common/mutex.c | 3 +++
 lib/tdb/common/tdb.c   | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/lib/tdb/common/mutex.c b/lib/tdb/common/mutex.c
index f4c2353..1020a71 100644
--- a/lib/tdb/common/mutex.c
+++ b/lib/tdb/common/mutex.c
@@ -776,6 +776,9 @@ static void tdb_robust_mutex_handler(int sig)
 	tdb_robust_mutext_old_handler(sig);
 }
 
+#ifndef HAVE_CONSTRUCTOR_ATTRIBUTE
+#error "Runtime check for robust mutexes requires constructor attribute"
+#endif
 _PUBLIC_ bool tdb_runtime_check_for_robust_mutexes(void)
 {
 	void *ptr = NULL;
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index a67d8fb..ee12935 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -29,6 +29,14 @@
 
 _PUBLIC_ TDB_DATA tdb_null;
 
+#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
+void tdb_lib_init(void) __attribute__((constructor));
+void tdb_lib_init(void)
+{
+	tdb_runtime_check_for_robust_mutexes();
+}
+#endif
+
 /*
   non-blocking increment of the tdb sequence number if the tdb has been opened using
   the TDB_SEQNUM flag
-- 
2.9.3


From 8394ab0e7be1ce16e46ca0b8741c5c34c2caa4ac Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 12 Mar 2017 13:08:16 +0100
Subject: [PATCH 3/7] lib/tdb: mark tdb_runtime_check_for_robust_mutexes()
 deprecated

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12593

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 lib/tdb/include/tdb.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/tdb/include/tdb.h b/lib/tdb/include/tdb.h
index e86d267..904d8a7 100644
--- a/lib/tdb/include/tdb.h
+++ b/lib/tdb/include/tdb.h
@@ -895,7 +895,11 @@ int tdb_rescue(struct tdb_context *tdb,
  * This needs to be called and return true before TDB_MUTEX_LOCKING
  * can be used at runtime.
  *
- * @note This calls fork(), but the SIGCHILD handling should be transparent.
+ * @deprecated since 1.3.13, use tdb_mutex_locking_supported() instead
+ *
+ * @note This calls fork(), but the SIGCHILD handling should be transparent in
+ * single-threaded programs. Do not use it in multi-threaded programs, it may
+ * hang in sigsuspend() due to a lost SIGCHILD. Use tdb_mutex_locking_supported().
  *
  * @return              true if supported, false otherwise.
  *
-- 
2.9.3


From df4623f64ebe6597b8cfd6a965190c060bf1f337 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sat, 11 Mar 2017 12:27:48 +0100
Subject: [PATCH 4/7] lib/tdb: version 1.3.13

o add tdb_mutex_locking_supported() which returns the result of the
  checks done at library initialisation

o mark tdb_runtime_check_for_robust_mutexes() deprecated

o use the new tdb_mutex_locking_supported() instead of
  tdb_runtime_check_for_robust_mutexes()

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12593

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 lib/tdb/ABI/tdb-1.3.13.sigs                    | 71 ++++++++++++++++++++++++++
 lib/tdb/common/mutex.c                         | 10 ++++
 lib/tdb/common/open.c                          |  2 +-
 lib/tdb/include/tdb.h                          | 19 +++++++
 lib/tdb/test/run-allrecord-traverse-deadlock.c |  2 +-
 lib/tdb/test/run-marklock-deadlock.c           |  2 +-
 lib/tdb/test/run-mutex-allrecord-bench.c       |  2 +-
 lib/tdb/test/run-mutex-allrecord-block.c       |  2 +-
 lib/tdb/test/run-mutex-allrecord-trylock.c     |  2 +-
 lib/tdb/test/run-mutex-die.c                   |  2 +-
 lib/tdb/test/run-mutex-openflags2.c            |  2 +-
 lib/tdb/test/run-mutex-transaction1.c          |  2 +-
 lib/tdb/test/run-mutex-trylock.c               |  2 +-
 lib/tdb/test/run-mutex1.c                      |  2 +-
 lib/tdb/tools/tdbtorture.c                     |  4 +-
 lib/tdb/wscript                                |  2 +-
 16 files changed, 114 insertions(+), 14 deletions(-)
 create mode 100644 lib/tdb/ABI/tdb-1.3.13.sigs

diff --git a/lib/tdb/ABI/tdb-1.3.13.sigs b/lib/tdb/ABI/tdb-1.3.13.sigs
new file mode 100644
index 0000000..6ad5170
--- /dev/null
+++ b/lib/tdb/ABI/tdb-1.3.13.sigs
@@ -0,0 +1,71 @@
+tdb_add_flags: void (struct tdb_context *, unsigned int)
+tdb_append: int (struct tdb_context *, TDB_DATA, TDB_DATA)
+tdb_chainlock: int (struct tdb_context *, TDB_DATA)
+tdb_chainlock_mark: int (struct tdb_context *, TDB_DATA)
+tdb_chainlock_nonblock: int (struct tdb_context *, TDB_DATA)
+tdb_chainlock_read: int (struct tdb_context *, TDB_DATA)
+tdb_chainlock_read_nonblock: int (struct tdb_context *, TDB_DATA)
+tdb_chainlock_unmark: int (struct tdb_context *, TDB_DATA)
+tdb_chainunlock: int (struct tdb_context *, TDB_DATA)
+tdb_chainunlock_read: int (struct tdb_context *, TDB_DATA)
+tdb_check: int (struct tdb_context *, int (*)(TDB_DATA, TDB_DATA, void *), void *)
+tdb_close: int (struct tdb_context *)
+tdb_delete: int (struct tdb_context *, TDB_DATA)
+tdb_dump_all: void (struct tdb_context *)
+tdb_enable_seqnum: void (struct tdb_context *)
+tdb_error: enum TDB_ERROR (struct tdb_context *)
+tdb_errorstr: const char *(struct tdb_context *)
+tdb_exists: int (struct tdb_context *, TDB_DATA)
+tdb_fd: int (struct tdb_context *)
+tdb_fetch: TDB_DATA (struct tdb_context *, TDB_DATA)
+tdb_firstkey: TDB_DATA (struct tdb_context *)
+tdb_freelist_size: int (struct tdb_context *)
+tdb_get_flags: int (struct tdb_context *)
+tdb_get_logging_private: void *(struct tdb_context *)
+tdb_get_seqnum: int (struct tdb_context *)
+tdb_hash_size: int (struct tdb_context *)
+tdb_increment_seqnum_nonblock: void (struct tdb_context *)
+tdb_jenkins_hash: unsigned int (TDB_DATA *)
+tdb_lock_nonblock: int (struct tdb_context *, int, int)
+tdb_lockall: int (struct tdb_context *)
+tdb_lockall_mark: int (struct tdb_context *)
+tdb_lockall_nonblock: int (struct tdb_context *)
+tdb_lockall_read: int (struct tdb_context *)
+tdb_lockall_read_nonblock: int (struct tdb_context *)
+tdb_lockall_unmark: int (struct tdb_context *)
+tdb_log_fn: tdb_log_func (struct tdb_context *)
+tdb_map_size: size_t (struct tdb_context *)
+tdb_mutex_locking_supported: bool (void)
+tdb_name: const char *(struct tdb_context *)
+tdb_nextkey: TDB_DATA (struct tdb_context *, TDB_DATA)
+tdb_null: dptr = 0xXXXX, dsize = 0
+tdb_open: struct tdb_context *(const char *, int, int, int, mode_t)
+tdb_open_ex: struct tdb_context *(const char *, int, int, int, mode_t, const struct tdb_logging_context *, tdb_hash_func)
+tdb_parse_record: int (struct tdb_context *, TDB_DATA, int (*)(TDB_DATA, TDB_DATA, void *), void *)
+tdb_printfreelist: int (struct tdb_context *)
+tdb_remove_flags: void (struct tdb_context *, unsigned int)
+tdb_reopen: int (struct tdb_context *)
+tdb_reopen_all: int (int)
+tdb_repack: int (struct tdb_context *)
+tdb_rescue: int (struct tdb_context *, void (*)(TDB_DATA, TDB_DATA, void *), void *)
+tdb_runtime_check_for_robust_mutexes: bool (void)
+tdb_set_logging_function: void (struct tdb_context *, const struct tdb_logging_context *)
+tdb_set_max_dead: void (struct tdb_context *, int)
+tdb_setalarm_sigptr: void (struct tdb_context *, volatile sig_atomic_t *)
+tdb_store: int (struct tdb_context *, TDB_DATA, TDB_DATA, int)
+tdb_storev: int (struct tdb_context *, TDB_DATA, const TDB_DATA *, int, int)
+tdb_summary: char *(struct tdb_context *)
+tdb_transaction_cancel: int (struct tdb_context *)
+tdb_transaction_commit: int (struct tdb_context *)
+tdb_transaction_prepare_commit: int (struct tdb_context *)
+tdb_transaction_start: int (struct tdb_context *)
+tdb_transaction_start_nonblock: int (struct tdb_context *)
+tdb_transaction_write_lock_mark: int (struct tdb_context *)
+tdb_transaction_write_lock_unmark: int (struct tdb_context *)
+tdb_traverse: int (struct tdb_context *, tdb_traverse_func, void *)
+tdb_traverse_read: int (struct tdb_context *, tdb_traverse_func, void *)
+tdb_unlock: int (struct tdb_context *, int, int)
+tdb_unlockall: int (struct tdb_context *)
+tdb_unlockall_read: int (struct tdb_context *)
+tdb_validate_freelist: int (struct tdb_context *, int *)
+tdb_wipe_all: int (struct tdb_context *)
diff --git a/lib/tdb/common/mutex.c b/lib/tdb/common/mutex.c
index 1020a71..17db9ba 100644
--- a/lib/tdb/common/mutex.c
+++ b/lib/tdb/common/mutex.c
@@ -659,6 +659,11 @@ int tdb_mutex_munmap(struct tdb_context *tdb)
 
 static bool tdb_mutex_locking_cached;
 
+_PUBLIC_ bool tdb_mutex_locking_supported(void)
+{
+	return tdb_mutex_locking_cached;
+}
+
 static bool tdb_mutex_locking_basic_check(void)
 {
 	pthread_mutexattr_t ma;
@@ -1053,4 +1058,9 @@ _PUBLIC_ bool tdb_runtime_check_for_robust_mutexes(void)
 	return false;
 }
 
+_PUBLIC_ bool tdb_mutex_locking_supported(void)
+{
+	return false;
+}
+
 #endif
diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index f3ef856..9ede69e 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -459,7 +459,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
 		 * than with pure fcntl locking. E.g. multiple
 		 * read locks are not supported.
 		 */
-		if (!tdb_runtime_check_for_robust_mutexes()) {
+		if (!tdb_mutex_locking_supported()) {
 			TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: "
 				"invalid flags for %s - TDB_MUTEX_LOCKING "
 				"requires support for robust_mutexes\n",
diff --git a/lib/tdb/include/tdb.h b/lib/tdb/include/tdb.h
index 904d8a7..18c2631 100644
--- a/lib/tdb/include/tdb.h
+++ b/lib/tdb/include/tdb.h
@@ -907,6 +907,25 @@ int tdb_rescue(struct tdb_context *tdb,
  */
 bool tdb_runtime_check_for_robust_mutexes(void);
 
+/**
+ * @brief Check if support for TDB_MUTEX_LOCKING is available
+ *
+ * On some systems the API for pthread_mutexattr_setrobust() is not available.
+ * On other systems there are some bugs in the interaction between glibc and
+ * the linux kernel.
+ *
+ * This function provides the result of a runtime check done at library
+ * initialisation.
+ *
+ * This needs to be called and return true before TDB_MUTEX_LOCKING
+ * can be used at runtime.
+ *
+ * @return              true if supported, false otherwise.
+ *
+ * @see TDB_MUTEX_LOCKING
+ */
+bool tdb_mutex_locking_supported(void);
+
 /* @} ******************************************************************/
 
 /* Low level locking functions: use with care */
diff --git a/lib/tdb/test/run-allrecord-traverse-deadlock.c b/lib/tdb/test/run-allrecord-traverse-deadlock.c
index 2c58206..4adc1f8 100644
--- a/lib/tdb/test/run-allrecord-traverse-deadlock.c
+++ b/lib/tdb/test/run-allrecord-traverse-deadlock.c
@@ -180,7 +180,7 @@ int main(int argc, char *argv[])
 	int ret;
 	bool mutex_support;
 
-	mutex_support = tdb_runtime_check_for_robust_mutexes();
+	mutex_support = tdb_mutex_locking_supported();
 
 	ret = do_tests("marklock-deadlock-fcntl.tdb",
 		       TDB_CLEAR_IF_FIRST |
diff --git a/lib/tdb/test/run-marklock-deadlock.c b/lib/tdb/test/run-marklock-deadlock.c
index ff03a11..5eb588a 100644
--- a/lib/tdb/test/run-marklock-deadlock.c
+++ b/lib/tdb/test/run-marklock-deadlock.c
@@ -255,7 +255,7 @@ int main(int argc, char *argv[])
 	int ret;
 	bool mutex_support;
 
-	mutex_support = tdb_runtime_check_for_robust_mutexes();
+	mutex_support = tdb_mutex_locking_supported();
 
 	ret = do_tests("marklock-deadlock-fcntl.tdb",
 		       TDB_CLEAR_IF_FIRST |
diff --git a/lib/tdb/test/run-mutex-allrecord-bench.c b/lib/tdb/test/run-mutex-allrecord-bench.c
index b81e597..4ef7182 100644
--- a/lib/tdb/test/run-mutex-allrecord-bench.c
+++ b/lib/tdb/test/run-mutex-allrecord-bench.c
@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
 	double elapsed;
 	bool runtime_support;
 
-	runtime_support = tdb_runtime_check_for_robust_mutexes();
+	runtime_support = tdb_mutex_locking_supported();
 
 	if (!runtime_support) {
 		skip(1, "No robust mutex support");
diff --git a/lib/tdb/test/run-mutex-allrecord-block.c b/lib/tdb/test/run-mutex-allrecord-block.c
index fcd3b4f..2e09556 100644
--- a/lib/tdb/test/run-mutex-allrecord-block.c
+++ b/lib/tdb/test/run-mutex-allrecord-block.c
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
 	int tdb_flags;
 	bool runtime_support;
 
-	runtime_support = tdb_runtime_check_for_robust_mutexes();
+	runtime_support = tdb_mutex_locking_supported();
 
 	if (!runtime_support) {
 		skip(1, "No robust mutex support");
diff --git a/lib/tdb/test/run-mutex-allrecord-trylock.c b/lib/tdb/test/run-mutex-allrecord-trylock.c
index 4b683db..6859c5e 100644
--- a/lib/tdb/test/run-mutex-allrecord-trylock.c
+++ b/lib/tdb/test/run-mutex-allrecord-trylock.c
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
 	int tdb_flags;
 	bool runtime_support;
 
-	runtime_support = tdb_runtime_check_for_robust_mutexes();
+	runtime_support = tdb_mutex_locking_supported();
 
 	if (!runtime_support) {
 		skip(1, "No robust mutex support");
diff --git a/lib/tdb/test/run-mutex-die.c b/lib/tdb/test/run-mutex-die.c
index 4b8eac1..7c7c503 100644
--- a/lib/tdb/test/run-mutex-die.c
+++ b/lib/tdb/test/run-mutex-die.c
@@ -251,7 +251,7 @@ int main(int argc, char *argv[])
 	bool ret;
 	bool runtime_support;
 
-	runtime_support = tdb_runtime_check_for_robust_mutexes();
+	runtime_support = tdb_mutex_locking_supported();
 
 	if (!runtime_support) {
 		skip(1, "No robust mutex support");
diff --git a/lib/tdb/test/run-mutex-openflags2.c b/lib/tdb/test/run-mutex-openflags2.c
index 6522ae4..c210915 100644
--- a/lib/tdb/test/run-mutex-openflags2.c
+++ b/lib/tdb/test/run-mutex-openflags2.c
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
 	char c = 0;
 	bool runtime_support;
 
-	runtime_support = tdb_runtime_check_for_robust_mutexes();
+	runtime_support = tdb_mutex_locking_supported();
 
 	ret = pipe(pipefd);
 	ok1(ret == 0);
diff --git a/lib/tdb/test/run-mutex-transaction1.c b/lib/tdb/test/run-mutex-transaction1.c
index 7b9f7b1..ef24e11 100644
--- a/lib/tdb/test/run-mutex-transaction1.c
+++ b/lib/tdb/test/run-mutex-transaction1.c
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
 	int tdb_flags;
 	bool runtime_support;
 
-	runtime_support = tdb_runtime_check_for_robust_mutexes();
+	runtime_support = tdb_mutex_locking_supported();
 
 	if (!runtime_support) {
 		skip(1, "No robust mutex support");
diff --git a/lib/tdb/test/run-mutex-trylock.c b/lib/tdb/test/run-mutex-trylock.c
index c96b635..8eb5ed9 100644
--- a/lib/tdb/test/run-mutex-trylock.c
+++ b/lib/tdb/test/run-mutex-trylock.c
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
 	int tdb_flags;
 	bool runtime_support;
 
-	runtime_support = tdb_runtime_check_for_robust_mutexes();
+	runtime_support = tdb_mutex_locking_supported();
 
 	if (!runtime_support) {
 		skip(1, "No robust mutex support");
diff --git a/lib/tdb/test/run-mutex1.c b/lib/tdb/test/run-mutex1.c
index eb75946..770cd58 100644
--- a/lib/tdb/test/run-mutex1.c
+++ b/lib/tdb/test/run-mutex1.c
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
 	int tdb_flags;
 	bool runtime_support;
 
-	runtime_support = tdb_runtime_check_for_robust_mutexes();
+	runtime_support = tdb_mutex_locking_supported();
 
 	if (!runtime_support) {
 		skip(1, "No robust mutex support");
diff --git a/lib/tdb/tools/tdbtorture.c b/lib/tdb/tools/tdbtorture.c
index 3640dc7..13b3dcf 100644
--- a/lib/tdb/tools/tdbtorture.c
+++ b/lib/tdb/tools/tdbtorture.c
@@ -334,9 +334,9 @@ int main(int argc, char * const *argv)
 			kill_random = 1;
 			break;
 		case 'm':
-			mutex = tdb_runtime_check_for_robust_mutexes();
+			mutex = tdb_mutex_locking_supported();
 			if (!mutex) {
-				printf("tdb_runtime_check_for_robust_mutexes() returned false\n");
+				printf("tdb_mutex_locking_supported() returned false\n");
 				exit(1);
 			}
 			break;
diff --git a/lib/tdb/wscript b/lib/tdb/wscript
index 0d682eb..4f8439d 100644
--- a/lib/tdb/wscript
+++ b/lib/tdb/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'tdb'
-VERSION = '1.3.12'
+VERSION = '1.3.13'
 
 blddir = 'bin'
 
-- 
2.9.3


From 15481b9cb52c44ece7cecb7d8e8014dcf79dc52e Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sat, 11 Mar 2017 12:54:44 +0100
Subject: [PATCH 5/7] lib/tdb_wrap: use tdb_mutex_locking_supported()

Use the new tdb_mutex_locking_supported() from tdb 1.3.13. No change in
behaviour.
---
 lib/tdb_wrap/tdb_wrap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tdb_wrap/tdb_wrap.c b/lib/tdb_wrap/tdb_wrap.c
index 864656f..f467aff 100644
--- a/lib/tdb_wrap/tdb_wrap.c
+++ b/lib/tdb_wrap/tdb_wrap.c
@@ -144,7 +144,7 @@ struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
 	if (w == NULL) {
 
 		if (tdb_flags & TDB_MUTEX_LOCKING) {
-			if (!tdb_runtime_check_for_robust_mutexes()) {
+			if (!tdb_mutex_locking_supported()) {
 				tdb_flags &= ~TDB_MUTEX_LOCKING;
 			}
 		}
-- 
2.9.3


From 99f0255da8b252a325ecffa013354d1bc0a4f2bc Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sat, 11 Mar 2017 12:55:27 +0100
Subject: [PATCH 6/7] ctdb: use tdb_mutex_locking_supported()

Use the new tdb_mutex_locking_supported() from tdb 1.3.13. No change in
behaviour.
---
 ctdb/server/ctdb_ltdb_server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c
index 8ff9634..4c79348 100644
--- a/ctdb/server/ctdb_ltdb_server.c
+++ b/ctdb/server/ctdb_ltdb_server.c
@@ -856,7 +856,7 @@ static int ctdb_local_attach(struct ctdb_context *ctdb, const char *db_name,
 	}
 #ifdef TDB_MUTEX_LOCKING
 	if (ctdb->tunable.mutex_enabled && mutexes &&
-	    tdb_runtime_check_for_robust_mutexes()) {
+	    tdb_mutex_locking_supported()) {
 		tdb_flags |= (TDB_MUTEX_LOCKING | TDB_CLEAR_IF_FIRST);
 	}
 #endif
-- 
2.9.3


From 068bc873196cc5b2fae577f2bc80943bf1050355 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sat, 11 Mar 2017 12:55:43 +0100
Subject: [PATCH 7/7] s3: use tdb_mutex_locking_supported()

Use the new tdb_mutex_locking_supported() from tdb 1.3.13. No change in
behaviour.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12593

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source3/lib/dbwrap/dbwrap_open.c | 2 +-
 source3/smbd/process.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
index feb9f5e..1fb65ef 100644
--- a/source3/lib/dbwrap/dbwrap_open.c
+++ b/source3/lib/dbwrap/dbwrap_open.c
@@ -110,7 +110,7 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
 		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()) {
+		if (try_mutex && tdb_mutex_locking_supported()) {
 			tdb_flags |= TDB_MUTEX_LOCKING;
 		}
 
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 8f097ec..c1bdaa2 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -3334,7 +3334,7 @@ bool fork_echo_handler(struct smbXsrv_connection *xconn)
 	}
 
 #ifdef HAVE_ROBUST_MUTEXES
-	use_mutex = tdb_runtime_check_for_robust_mutexes();
+	use_mutex = tdb_mutex_locking_supported();
 
 	if (use_mutex) {
 		pthread_mutexattr_t a;
-- 
2.9.3



More information about the samba-technical mailing list