--- ../clean/asterisk-1.6.2.16.1/channels/chan_sip.c 2010-12-10 00:10:31.000000000 +0200 +++ channels/chan_sip.c 2011-02-11 09:11:01.000000000 +0200 @@ -7158,10 +7158,8 @@ /* If we detect a CNG tone and fax detection is enabled then send us off to the fax extension */ if (faxdetected && ast_test_flag(&p->flags[1], SIP_PAGE2_FAX_DETECT_CNG)) { - ast_channel_lock(ast); if (strcmp(ast->exten, "fax")) { const char *target_context = S_OR(ast->macrocontext, ast->context); - ast_channel_unlock(ast); if (ast_exists_extension(ast, target_context, "fax", 1, ast->cid.cid_num)) { ast_verbose(VERBOSE_PREFIX_2 "Redirecting '%s' to fax extension due to CNG detection\n", ast->name); pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten); @@ -7172,8 +7170,6 @@ } else { ast_log(LOG_NOTICE, "FAX CNG detected but no fax extension\n"); } - } else { - ast_channel_unlock(ast); } } @@ -18161,7 +18157,9 @@ if (ast_test_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE)) { /* Ready to send the next state we have on queue */ ast_clear_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE); + ast_rdlock_contexts(); cb_extensionstate((char *)p->context, (char *)p->exten, p->laststate, (void *) p); + ast_unlock_contexts(); } } break; @@ -18872,7 +18870,9 @@ if (ast_test_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE)) { /* Ready to send the next state we have on queue */ ast_clear_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE); + ast_rdlock_contexts(); cb_extensionstate((char *)p->context, (char *)p->exten, p->laststate, (void *) p); + ast_unlock_contexts(); } } } else if (sipmethod == SIP_BYE) {