[asterisk-dev] IAX different reentrant locks depth in the same function
Yousf Ateya
y.ateya at starkbits.com
Tue Apr 21 14:42:30 CDT 2015
While testing the patch of
https://issues.asterisk.org/jira/browse/ASTERISK-24983, I found that in
some paths (ex. in call hangup procedure) we acquire the lock multiple
times from the same thread.
The lock implementation supports reentrant locks, so it works; until you
stuck in a deadlock!
For example (lock iaxs[callno]), the function iax2_destroy_helper is called
from multiple paths:
1 - iax2_hangup -> iax2_destroy_helper : In this path the lock is locked
only once (in iax2_hangup).
2 - socket_process_helper (ACK for hangup) -> iax2_destroy ->
pvt_destructor (because of ao2_ref(pvt,-1) -> iax2_destroy_helper : In this
path lock is locked twice, one in socket_process_helper and the other in
pvt_destructor.
The problem of this is that in function iax2_destroy_helper, I wanted to
avoid deadlock with other thread (sending scheduled lagrq), so I did
ast_mutex_unlock. But I still got deadlock!!
Why? Because you need to unlock it twice in path 2!
Personally, I didn't like it that much.
Is it common, and we live with it (will do a work around for this specific
case)?
Or this seems trouble making pattern and we should have deeper look
(probably in IAX and other components)?
--
Yousf Ateya,
StarkBits
www.starkbits.com
--
This e-mail message is intended only for the use of the intended recipient(s).
The information contained therein may be confidential or privileged,
and its disclosure or reproduction is strictly prohibited.
If you are not the intended recipient, please return it immediately to its sender
at the above address and destroy it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150421/3aee82e4/attachment.html>
More information about the asterisk-dev
mailing list