[asterisk-dev] ast_mutex_t usage

Alex Massover alex at jajah.com
Thu Feb 25 11:58:01 CST 2010


Hello,

I have a custom module, that exports foo(), the problem is that foo() is not safe-thread, i.e. calls to it should be serialized.

I tried to do it with ast_mutex like following:

AST_MUTEX_DEFINE_STATIC(mp);

static int foo(.....)
{
....
ast_mutex_lock(&mp);
[non-reentrant code here]
ast_mutex_unlock(&mp);
.....
}


But I still see  that [non-reentrant] part is entered more than once concurrently. Each channel can call foo() only once in dialplan, so it looks like other threads/channels are entering it.

Do I miss something please? Maybe there're a better ways to serialize a calls to module function?


--
Best Regards,
Alex Massover
VoIP R&D TL
Jajah Inc.


This mail was sent via Mail-SeCure System.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20100225/80fedc14/attachment.htm 


More information about the asterisk-dev mailing list