[Asterisk-Dev] FreeBSD recursive mutexes - please help

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Wed May 5 09:17:53 MST 2004


On Wednesday 05 May 2004 00:06, Markus Wild wrote:
> > No, I was referring to the code in:
> > /usr/src/lib/libc/stdtime/localtime.c, which is the original code
> > for: /usr/src/asterisk/stdtime/localtime.c.
> >
> > There are a few changes I've made to that source, in order to
> > have it work in the Asterisk environment, but that's where I'm
> > getting that particular mutex initializer.
>
> But you're not getting (and you don't need) _recursive_ mutexes
> there... The problem currently is not whether we can statically
> initialize mutexes (we can), the problem is we can't initialize
> them to a specific type.

Actually, you _do_ need recursive mutexes there.

Functions call tzset(), which locks lcl_mutex, then calls
tzset_basic().  If the environmental variable TZ is unset,
then tzset_basic() calls tzset_wall(), which again locks
lcl_mutex.

If you do not have recursive mutexes, then at this point, you'll
get a deadlock.  I had to specifically change this in Asterisk,
because I was getting a deadlock between these two locks
(occurring in the same thread).

Please trace through the code, and I think you'll find that my
analysis of the code was and is correct.

-Tilghman




More information about the asterisk-dev mailing list