diff -urN asterisk-11.2.1.orig/channels/chan_dahdi.c asterisk-11.2.1/channels/chan_dahdi.c --- asterisk-11.2.1.orig/channels/chan_dahdi.c 2013-01-09 12:43:00.000000000 -0800 +++ asterisk-11.2.1/channels/chan_dahdi.c 2013-03-25 13:50:01.961196138 -0700 @@ -2163,18 +2163,16 @@ ast_channel_unlock(ast); if (ast_exists_extension(ast, target_context, "fax", 1, S_COR(ast_channel_caller(ast)->id.number.valid, ast_channel_caller(ast)->id.number.str, NULL))) { - ast_channel_lock(ast); - ast_mutex_lock(&p->lock); ast_verb(3, "Redirecting %s to fax extension\n", ast_channel_name(ast)); /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */ pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast_channel_exten(ast)); if (ast_async_goto(ast, target_context, "fax", 1)) ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(ast), target_context); } else { - ast_channel_lock(ast); - ast_mutex_lock(&p->lock); ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n"); } + ast_channel_lock(ast); + ast_mutex_lock(&p->lock); } else { ast_debug(1, "Already in a fax extension, not redirecting\n"); } @@ -7980,18 +7978,16 @@ ast_channel_unlock(ast); if (ast_exists_extension(ast, target_context, "fax", 1, S_COR(ast_channel_caller(ast)->id.number.valid, ast_channel_caller(ast)->id.number.str, NULL))) { - ast_channel_lock(ast); - ast_mutex_lock(&p->lock); ast_verb(3, "Redirecting %s to fax extension\n", ast_channel_name(ast)); /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */ pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast_channel_exten(ast)); if (ast_async_goto(ast, target_context, "fax", 1)) ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(ast), target_context); } else { - ast_channel_lock(ast); - ast_mutex_lock(&p->lock); ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n"); } + ast_channel_lock(ast); + ast_mutex_lock(&p->lock); } else { ast_debug(1, "Already in a fax extension, not redirecting\n"); } diff -urN asterisk-11.2.1.orig/channels/chan_sip.c asterisk-11.2.1/channels/chan_sip.c --- asterisk-11.2.1.orig/channels/chan_sip.c 2013-01-09 12:43:00.000000000 -0800 +++ asterisk-11.2.1/channels/chan_sip.c 2013-03-25 14:06:00.740193835 -0700 @@ -8397,8 +8397,6 @@ ast_channel_unlock(ast); if (ast_exists_extension(ast, target_context, "fax", 1, S_COR(ast_channel_caller(ast)->id.number.valid, ast_channel_caller(ast)->id.number.str, NULL))) { - ast_channel_lock(ast); - sip_pvt_lock(p); ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n", ast_channel_name(ast)); pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast_channel_exten(ast)); if (ast_async_goto(ast, target_context, "fax", 1)) { @@ -8407,10 +8405,10 @@ ast_frfree(fr); fr = &ast_null_frame; } else { - ast_channel_lock(ast); - sip_pvt_lock(p); ast_log(LOG_NOTICE, "FAX CNG detected but no fax extension\n"); } + ast_channel_lock(ast); + sip_pvt_lock(p); } } @@ -10637,6 +10635,7 @@ ast_channel_unlock(p->owner); if (ast_exists_extension(p->owner, target_context, "fax", 1, S_COR(ast_channel_caller(p->owner)->id.number.valid, ast_channel_caller(p->owner)->id.number.str, NULL))) { + ast_log(LOG_WARNING, "Usage of 'faxdetect=[yes|t38]' setting in sip.conf is not recommended. Please consider Set(FAXOPT(faxdetect)=[yes|t38]) instead.\n"); ast_verb(2, "Redirecting '%s' to fax extension due to peer T.38 re-INVITE\n", ast_channel_name(p->owner)); pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", ast_channel_exten(p->owner)); if (ast_async_goto(p->owner, target_context, "fax", 1)) { diff -urN asterisk-11.2.1.orig/res/res_fax.c asterisk-11.2.1/res/res_fax.c --- asterisk-11.2.1.orig/res/res_fax.c 2012-11-08 14:08:58.000000000 -0800 +++ asterisk-11.2.1/res/res_fax.c 2013-03-25 13:57:11.990193578 -0700 @@ -3388,10 +3388,13 @@ switch (result) { case 'f': case 't': + if (!strcmp(ast_channel_exten(chan), "fax")) { + ast_debug(1, "Already in a fax extension, not redirecting\n"); + break; + } ast_channel_unlock(chan); if (ast_exists_extension(chan, target_context, "fax", 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { - ast_channel_lock(chan); ast_verb(2, "Redirecting '%s' to fax extension due to %s detection\n", ast_channel_name(chan), (result == 'f') ? "CNG" : "T38"); pbx_builtin_setvar_helper(chan, "FAXEXTEN", ast_channel_exten(chan)); @@ -3401,10 +3404,10 @@ ast_frfree(f); f = &ast_null_frame; } else { - ast_channel_lock(chan); ast_log(LOG_NOTICE, "FAX %s detected but no fax extension in context (%s)\n", (result == 'f') ? "CNG" : "T38", target_context); } + ast_channel_lock(chan); } ast_framehook_detach(chan, details->faxdetect_id); details->faxdetect_id = -1;