[asterisk-dev] Who can explain this? chanzap zt_fixup / zt_indicate

Russell Bryant russell at digium.com
Tue Nov 7 20:20:42 MST 2006


Paulo Garcia wrote:
> I'm trying to figure out how it works without a deadlock...
> 
> The zt_fixup function do a mutex_lock using p->lock handler. 
> (ast_mutex_lock(&p->lock);)
> 
> Within the mutex block, the zt_indicate function can be called:
> 
>     if (newchan->_state == AST_STATE_RINGING)
>         zt_indicate(newchan, AST_CONTROL_RINGING);
> 
> But, within zt_indicate function, the ast_mutex_lock(&p->lock); is 
> called again.
> 
> Is this correct?

Well, I would not say that it is incorrect, but it is surely not ideal.  In 
Asterisk, all of our mutex objects are created as recursive mutexes.  This means 
that they can be locked multiple times within the same thread.  That is why this 
code works without creating a deadlock.

-- 
Russell Bryant
Software Engineer
Digium, Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: russell.vcf
Type: text/x-vcard
Size: 266 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20061107/4c1cd99d/russell.vcf


More information about the asterisk-dev mailing list