[PATCH] tdb_wrap: Make mutexes easier to use

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Sep 30 05:10:17 MDT 2014


Hi!

What do you think about the attached (untested!) patch? I've
just came across this because I wanted to invent a new tdb
that is purely local and could benefit tremendously from
mutexes (profile.tdb, holding source3/profile/profile.c
data).

Comments appreciated!

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From fb00f6dd63bcd83247708fb2d88d505a2af2399b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 30 Sep 2014 11:04:21 +0000
Subject: [PATCH] tdb_wrap: Make mutexes easier to use

This patch makes sure we have the required INCOMPATIBLE_HASH flag if
mutexes are requested and work fine and opens without mutexes if they
are not supported
---
 lib/tdb_wrap/tdb_wrap.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/tdb_wrap/tdb_wrap.c b/lib/tdb_wrap/tdb_wrap.c
index f2f32d1..2c5e517 100644
--- a/lib/tdb_wrap/tdb_wrap.c
+++ b/lib/tdb_wrap/tdb_wrap.c
@@ -149,6 +149,15 @@ 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()) {
+				tdb_flags |= TDB_INCOMPATIBLE_HASH;
+			} else {
+				tdb_flags &= ~TDB_MUTEX_LOCKING;
+			}
+		}
+
 		w = tdb_wrap_private_open(result, name, hash_size, tdb_flags,
 					  open_flags, mode);
 	} else {
-- 
1.7.9.5



More information about the samba-technical mailing list