--- chan_sip.c 2012-07-05 19:07:27.000000000 -0400 +++ chan_sip-new.c 2012-09-05 11:05:38.341284155 -0400 @@ -7515,6 +7515,16 @@ ast_channel_lock(ast); sip_pvt_lock(p); ast_verbose(VERBOSE_PREFIX_2 "Redirecting '%s' to fax extension due to CNG detection\n", ast->name); + + // ejr 2/22/2011 - fix because if fax is detected while the call is bridged then we run hangup on the bridge + // before processing the fax and then later when the fax hangs up it aborts dialplan after + // running ReceiveFax +// ast_channel_lock(ast); // new version 1.8 already locks + ast_set_flag(ast, AST_FLAG_BRIDGE_HANGUP_DONT); +// ast_channel_unlock(ast); + ast_verbose(VERBOSE_PREFIX_2 "CNG Detect: Prevent hangup being run on (%s) bridge break so we can complete dialplan after ReceiveFax - ejr 2/22/2011\n", ast->name); + // ejr **** done *** + pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten); if (ast_async_goto(ast, target_context, "fax", 1)) { ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context); @@ -9400,6 +9410,16 @@ if (ast_exists_extension(p->owner, target_context, "fax", 1, S_COR(p->owner->caller.id.number.valid, p->owner->caller.id.number.str, NULL))) { ast_verbose(VERBOSE_PREFIX_2 "Redirecting '%s' to fax extension due to peer T.38 re-INVITE\n", p->owner->name); + + // ejr 2/22/2011 - fix because if fax is detected while the call is bridged then we run hangup on the bridge + // before processing the fax and then later when the fax hangs up it aborts dialplan after + // running ReceiveFax + ast_channel_lock(p->owner); + ast_set_flag(p->owner, AST_FLAG_BRIDGE_HANGUP_DONT); + ast_channel_unlock(p->owner); + ast_verbose(VERBOSE_PREFIX_2 "T.38 detect: Prevent hangup being run on (%s) bridge break so we can complete dialplan after ReceiveFax - ejr 2/22/2011\n", p->owner->name); + // ejr **** done *** + pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", p->owner->exten); if (ast_async_goto(p->owner, target_context, "fax", 1)) { ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", p->owner->name, target_context);