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

George Joseph asteriskteam at digium.com
Wed Feb 6 07:12:27 CST 2019


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/10747 )

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(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/main/cdr.c b/main/cdr.c
index 462c3e6..53f3362 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -796,19 +796,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->base->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->base->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);
 }
 
 /*!
@@ -1944,7 +1955,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/10747
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I921bc04064b6cff1deb2eea56a94d86489561cdc
Gerrit-Change-Number: 10747
Gerrit-PatchSet: 6
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
Gerrit-Reviewer: Friendly Automation (1000185)
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua C. Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: sungtae kim <pchero21 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190206/facbe6ee/attachment-0001.html>


More information about the asterisk-code-review mailing list