From: Richard Mudgett Date: Fri, 13 May 2011 16:28:26 +0000 (+0000) Subject: CDR's are being written immediately on caller hangup. X-Git-Tag: 1.8.5-rc1~11^2~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a0766e4ada50d5396a274546146a3eca4fdc9c6;p=thirdparty%2Fasterisk.git 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/branches/1.8@318868 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/features.c b/main/features.c index e86ffca42d..bcbc6814b4 100644 --- a/main/features.c +++ b/main/features.c @@ -3448,6 +3448,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); @@ -3843,12 +3844,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 */ @@ -3869,8 +3881,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); @@ -3889,6 +3905,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) {