From: Fredrik Kuivinen Date: Thu, 08 Apr 2010 08:42:28 GMT Subject: Re: [PATCH] Thread-safe xmalloc and xrealloc needs a recursive mutex Message-ID: In-Reply-To: <4BBD829B.8040700@viscovery.net> On Thu, Apr 8, 2010 at 09:15, Johannes Sixt wrote: > From: Johannes Sixt > > The mutex used to protect object access (read_mutex) may need to be > acquired recursively.  Introduce init_recursive_mutex() helper function > in thread-utils.c that constructs a mutex with the PHREAD_MUTEX_RECURSIVE > attribute. > > pthread_mutex_init() emulation on Win32 is already recursive as it is > implemented on top of the CRITICAL_SECTION type, which is recursive. > >    http://msdn.microsoft.com/en-us/library/ms682530%28VS.85%29.aspx > > Add do-nothing compatibility wrappers for pthread_mutexattr* functions. > > Initial-version-by: Fredrik Kuivinen > Signed-off-by: Johannes Sixt > --- > Am 4/7/2010 16:45, schrieb Fredrik Kuivinen: >> We only need something like the following (on top of Nico's previous >> patch). Warning: It hasn't even been compile tested on WIN32. > > Unfortunately, it doesn't build. This patch replaces the tip of > nd/malloc-threading. > > BTW, your uses of strerror(errno) in init_recursive_mutex() were wrong > (pthread functions do not set errno), but it is better in any case to > avoid die() in this function. Very true. Thanks. - Fredrik