[asterisk-dev] deadlock in ast_custom_function_register?

Yuan Qin yuan007qin at gmail.com
Tue Oct 24 04:48:45 MST 2006


Hi, all:

     Asterisk1.2.10,  in pbx.c, the ast_custom_function_register is

int ast_custom_function_register(struct ast_custom_function *acf)
{
    if (!acf)
        return -1;

    /* try to lock functions list ... */
    if (ast_mutex_lock(&acflock)) {
        ast_log(LOG_ERROR, "Unable to lock function list. Failed registering
function %s\n", acf->name);
        return -1;
    }

    if (ast_custom_function_find(acf->name)) {
        ast_log(LOG_ERROR, "Function %s already registered.\n", acf->name);
        ast_mutex_unlock(&acflock);
        return -1;
   }
   /* ......... */
}

struct ast_custom_function* ast_custom_function_find(char *name)
{
    struct ast_custom_function *acfptr;

    /* try to lock functions list ... */
    if (ast_mutex_lock(&acflock)) {
        ast_log(LOG_ERROR, "Unable to lock function list\n");
        return NULL;
    }
   /* ....... */
}

The mutex acflock is locked twice,  so, the process will be deadlock here,
but it's not in fact.
Why? Is there something that I missed?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20061024/35d6f752/attachment-0001.htm


More information about the asterisk-dev mailing list