[Asterisk-code-review] main/cdr: Fixed cdr start overwriting (asterisk[13])

sungtae kim asteriskteam at digium.com
Tue Feb 5 14:45:19 CST 2019


sungtae kim has uploaded this change for review. ( https://gerrit.asterisk.org/10964


Change subject: main/cdr: Fixed cdr start overwriting
......................................................................

main/cdr: Fixed cdr start overwriting

The CDR was overwriting the start time when the call continued the
dialplan from the ARI stasis or a Local channel was originated.

This change fixes this by no longer reinitializing the CDR when
transitioning out of the dialed pending state to the single state.

ASTERISK-28181

Change-Id: I921bc04064b6cff1deb2eea56a94d86489561cdc
---
M main/cdr.c
1 file changed, 24 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/64/10964/1

diff --git a/main/cdr.c b/main/cdr.c
index c048761..ba0f337 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -803,19 +803,30 @@
 }
 
 /*!
+ * \brief Transition a \ref cdr_object to a new state with initiation flag
+ * \param cdr The \ref cdr_object to transition
+ * \param fn_table The \ref cdr_object_fn_table state to go to
+ */
+static void cdr_object_transition_state_init(struct cdr_object *cdr, struct cdr_object_fn_table *fn_table, int do_init)
+{
+	CDR_DEBUG("%p - Transitioning CDR for %s from state %s to %s\n",
+		cdr, cdr->party_a.snapshot->name,
+		cdr->fn_table ? cdr->fn_table->name : "NONE", fn_table->name);
+	cdr->fn_table = fn_table;
+
+	if (cdr->fn_table->init_function && do_init) {
+		cdr->fn_table->init_function(cdr);
+	}
+}
+
+/*!
  * \brief Transition a \ref cdr_object to a new state
  * \param cdr The \ref cdr_object to transition
  * \param fn_table The \ref cdr_object_fn_table state to go to
  */
 static void cdr_object_transition_state(struct cdr_object *cdr, struct cdr_object_fn_table *fn_table)
 {
-	CDR_DEBUG("%p - Transitioning CDR for %s from state %s to %s\n",
-		cdr, cdr->party_a.snapshot->name,
-		cdr->fn_table ? cdr->fn_table->name : "NONE", fn_table->name);
-	cdr->fn_table = fn_table;
-	if (cdr->fn_table->init_function) {
-		cdr->fn_table->init_function(cdr);
-	}
+	cdr_object_transition_state_init(cdr, fn_table, 1);
 }
 
 /*!
@@ -1955,7 +1966,12 @@
 			cdr->fn_table->process_party_a(cdr, snapshot);
 			return 1;
 		} else {
-			cdr_object_transition_state(cdr, &single_state_fn_table);
+			/* The CDR does not need to be reinitialized when transitioning
+			 * to its single state as this would overwrite the start time,
+			 * causing potentially both the answer and the start time to be
+			 * the same which is incorrect.
+			 */
+			cdr_object_transition_state_init(cdr, &single_state_fn_table, 0);
 			cdr->fn_table->process_party_a(cdr, snapshot);
 			return 0;
 		}

-- 
To view, visit https://gerrit.asterisk.org/10964
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I921bc04064b6cff1deb2eea56a94d86489561cdc
Gerrit-Change-Number: 10964
Gerrit-PatchSet: 1
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190205/b662435d/attachment.html>


More information about the asterisk-code-review mailing list