[asterisk-dev] Proper use of locking.
Kevin P. Fleming
kpfleming at digium.com
Wed Jul 18 16:11:41 CDT 2007
Michael Cargile wrote:
> 3. Last we checked Asterisk locks were non-reentrant, meaning a single
> thread cannot lock on the same lock twice. This is a problem that seems
> to be currently being worked on but I am not aware if it has been fixed
> as of yet. This means we need to be careful when locking. A deadlock we
> fixed was caused by a function locking the one lock, then calling a
> function that locks on the same lock.
Asterisk has always required and used recursive (reentrant is not the
right word) mutex locks (and now rwlocks, in trunk). All the code in
Asterisk that uses locks depends on this behavior and would break badly
if the mutexes were not recursive. This is documented in a comment very
early in include/asterisk/lock.h, so I'm not sure why you came to the
conclusion that non-recursive mutexes were in use.
--
Kevin P. Fleming
Director of Software Technologies
Digium, Inc. - "The Genuine Asterisk Experience" (TM)
More information about the asterisk-dev
mailing list