Index: channels/chan_local.c =================================================================== --- channels/chan_local.c (revision 110781) +++ channels/chan_local.c (working copy) @@ -214,6 +214,7 @@ ast_mutex_lock(&p->lock); isoutbound = IS_OUTBOUND(ast, p); + ast_log(LOG_NOTICE, "isoutbound is %d and ast's name is %s\n", isoutbound, ast->name); if (isoutbound) { /* Pass along answer since somebody answered us */ struct ast_frame answer = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER }; Index: main/channel.c =================================================================== --- main/channel.c (revision 110781) +++ main/channel.c (working copy) @@ -1896,7 +1896,17 @@ } chan->generatordata = NULL; /* reset, to let writes go through */ + /* This unlock is here based on two assumptions that hold true at this point in the + * code. 1) this function is only called from within __ast_read() and 2) all generators + * call ast_write() in their generate callback. + * + * The reason this is added is so that when ast_write is called, the lock that occurs + * there will not recursively lock the channel. Doing this will cause intended deadlock + * avoidance not to work in deeper functions + */ + ast_channel_unlock(chan); res = chan->generator->generate(chan, tmp, f->datalen, f->samples); + ast_channel_lock(chan); chan->generatordata = tmp; if (res) { if (option_debug > 1)