[asterisk-dev] ast_mutex_t usage

Alex Massover alex at jajah.com
Fri Feb 26 15:19:41 CST 2010


Hello,

Let me rephrase the question, maybe someone will help me :)

Is there any chance that ast_mutex in module will “miss”, for example because of multiple processes (fork() in core maybe)?

From: asterisk-dev-bounces at lists.digium.com [mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of Alex Massover
Sent: יום ה 25 פברואר 2010 19:58
To: asterisk-dev at lists.digium.com
Subject: [asterisk-dev] ast_mutex_t usage

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.


This mail was received via Mail-SeCure System.

This mail was sent via Mail-SeCure System.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20100226/29ebf933/attachment.htm 


More information about the asterisk-dev mailing list