From 153547a9b14937e04c0c97dc23ba756f50330c57 Mon Sep 17 00:00:00 2001
From: Matt Jordan <mjordan@digium.com>
Date: Sat, 2 Jan 2016 10:23:39 -0600
Subject: [PATCH] main/cdr: Set the end time on a CDR if endbeforehexten is Yes

Prior to this patch, the CDR engine attempted to set the end time on a CDR
that was executing hangup logic and with endbeforehexten set to Yes by
calling a function that inspects the properties on the Party A snapshot to
determine if we are ready to set the end time. That always failed. This is
because a Party A snapshot is not updated for CDRs that are executing hangup
logic with endbeforehexten=Yes.

Instead of calling a function that looks at the Party A snapshot, we just
simply set the end time on the CDR. This is safe to call multiple times, and is
safe to call at this point as we know that (a) we are executing hangup logic,
and (b) we are supposed to set the end time at this point.

ASTERISK-25458

Change-Id: I0c27b493861f9c13c43addbbb21257f79047a3b3
---
 main/cdr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/main/cdr.c b/main/cdr.c
index 5e24075029..b5df79fc78 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -1359,10 +1359,10 @@ static int base_process_party_a(struct cdr_object *cdr, struct ast_channel_snaps
 
 	ast_assert(strcasecmp(snapshot->name, cdr->party_a.snapshot->name) == 0);
 
-	/* Ignore any snapshots from a dead or dying channel */
+	/* Finalize the CDR if we're in hangup logic and we're set to do so */
 	if (ast_test_flag(&snapshot->softhangup_flags, AST_SOFTHANGUP_HANGUP_EXEC)
-			&& ast_test_flag(&mod_cfg->general->settings, CDR_END_BEFORE_H_EXTEN)) {
-		cdr_object_check_party_a_hangup(cdr);
+		&& ast_test_flag(&mod_cfg->general->settings, CDR_END_BEFORE_H_EXTEN)) {
+		cdr_object_finalize(cdr);
 		return 0;
 	}
 
-- 
GitLab