From db89abf0bd854ae09a7044b622b1f0260ae77a7e Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Fri, 13 May 2011 16:30:29 +0000 Subject: Merged revisions 318868 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r318868 | rmudgett | 2011-05-13 11:28:26 -0500 (Fri, 13 May 2011) | 19 lines CDR's are being written immediately on caller hangup. CDR's are being written immediately on caller hangup. The dialplan is not able to modify it in the h exten. The h exten in the initial context is not run before closing CDR's when the bridge is unlinked if a macro is active and does not have an h exten. * Make ast_bridge_call() check for an h exten in the current context and if a macro is active then the initial context. The first h exten found is then run before closing the CDR. (closes issue #18212) Reported by: leearcher Patches: issue18212_v1.8.patch uploaded by rmudgett (license 664) Tested by: rmudgett Review: https://reviewboard.asterisk.org/r/1206/ ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318869 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/features.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'main') diff --git a/main/features.c b/main/features.c index 8cd0695ab..23f105e72 100644 --- a/main/features.c +++ b/main/features.c @@ -3480,6 +3480,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast struct ast_cdr *new_chan_cdr = NULL; /* the proper chan cdr, if there are forked cdrs */ struct ast_cdr *new_peer_cdr = NULL; /* the proper chan cdr, if there are forked cdrs */ struct ast_silence_generator *silgen = NULL; + const char *h_context; if (chan && peer) { pbx_builtin_setvar_helper(chan, "BRIDGEPEER", peer->name); @@ -3876,12 +3877,23 @@ before_you_go: * if it were, then chan belongs to a different thread now, and might have been hung up long * ago. */ - if (!ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) - && ast_exists_extension(chan, chan->context, "h", 1, + if (ast_test_flag(&config->features_caller, AST_FEATURE_NO_H_EXTEN)) { + h_context = NULL; + } else if (ast_exists_extension(chan, chan->context, "h", 1, + S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) { + h_context = chan->context; + } else if (!ast_strlen_zero(chan->macrocontext) + && ast_exists_extension(chan, chan->macrocontext, "h", 1, S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) { + h_context = chan->macrocontext; + } else { + h_context = NULL; + } + if (h_context) { struct ast_cdr *swapper = NULL; char savelastapp[AST_MAX_EXTENSION]; char savelastdata[AST_MAX_EXTENSION]; + char save_context[AST_MAX_CONTEXT]; char save_exten[AST_MAX_EXTENSION]; int save_prio; int found = 0; /* set if we find at least one match */ @@ -3902,8 +3914,12 @@ before_you_go: ast_copy_string(savelastdata, bridge_cdr->lastdata, sizeof(bridge_cdr->lastdata)); chan->cdr = bridge_cdr; } + ast_copy_string(save_context, chan->context, sizeof(save_context)); ast_copy_string(save_exten, chan->exten, sizeof(save_exten)); save_prio = chan->priority; + if (h_context != chan->context) { + ast_copy_string(chan->context, h_context, sizeof(chan->context)); + } ast_copy_string(chan->exten, "h", sizeof(chan->exten)); chan->priority = 1; ast_channel_unlock(chan); @@ -3922,6 +3938,7 @@ before_you_go: /* swap it back */ ast_channel_lock(chan); + ast_copy_string(chan->context, save_context, sizeof(chan->context)); ast_copy_string(chan->exten, save_exten, sizeof(chan->exten)); chan->priority = save_prio; if (bridge_cdr) { -- cgit v1.2.3