[PATCH] tdb_wrap: Make mutexes easier to use

Stefan (metze) Metzmacher metze at samba.org
Tue Sep 30 06:54:08 MDT 2014


Hi Volker,

>>> 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!
>>
>> tdb_open_ex() has
>>
>>         if (tdb_flags & TDB_MUTEX_LOCKING) {
>>                 tdb_flags |= TDB_INCOMPATIBLE_HASH;
>>         }
>>
>> so the tdb_flags |= TDB_INCOMPATIBLE_HASH; in your patch should not be
>> required.
> 
> Hmm. Ok. Thanks :-)
> 
>> However there's an interaction between TDB_MUTEX_LOCKING and
>> TDB_CLEAR_IF_FIRST.
>>
>> Maybe we want something like this?
>>
>> +		if (tdb_flags & TDB_CLEAR_IF_FIRST) {
>> +			if (tdb_runtime_check_for_robust_mutexes()) {
>> +				tdb_flags |= TDB_MUTEX_LOCKING;
>> +			}
>> +		}
> 
> That would of course also work for me. I just wanted to so
> "radical" :-)

Hmm, tdb_wrap_open() is used quite a few places, so maybe better
something like this?

+		if (tdb_flags & TDB_MUTEX_LOCKING) {
+			if (!tdb_runtime_check_for_robust_mutexes()) {
+				tdb_flags &= ~TDB_MUTEX_LOCKING;
+			}
+		}

metze

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140930/0f5e2cce/attachment.pgp>


More information about the samba-technical mailing list