[Asterisk-code-review] main/cdr: Allow setting properties on a finalized CDR if it ... (asterisk[13])

Matt Jordan asteriskteam at digium.com
Mon Jan 4 09:02:40 CST 2016


Matt Jordan has submitted this change and it was merged.

Change subject: main/cdr: Allow setting properties on a finalized CDR if it is the last one
......................................................................


main/cdr: Allow setting properties on a finalized CDR if it is the last one

Prior to this patch, we explicitly disallowed setting any properties on a
finalized CDR. This seemed like a good idea at the time; in practice, it was
more restrictive.

There are weird and strange scenarios where setting a property on a finalized
CDR is definitely wrong. For example, we may Fork a CDR, finalizing the
previous one, then change a property. In said case, the old CDR is supposed
to now be 'immutable' (so to speak), and should not be updated. From the
perspective of the code, a forked CDR that is finalized is just finalized.
Hence why we decided these should not be updated.

In practice, it is much more common to want to set a property on a CDR in
the h extension or in a hangup handler. Disallowing a common scenario to make
an esoteric behaviour work isn't good. This patch fixes this by allowing
callers to set a property IF we are the last CDR in the chain. This preserves
the finalized CDR if it was forked, while allowing the more common case to
function.

ASTERISK-25458 #close

Change-Id: Icf3553c607b9f561152a41e6d8381d594ccdf4b9
---
M main/cdr.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Matt Jordan: Looks good to me, approved
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/main/cdr.c b/main/cdr.c
index 5abfc74..7795a65 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -2953,7 +2953,7 @@
 		for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {
 			struct varshead *headp = NULL;
 
-			if (it_cdr->fn_table == &finalized_state_fn_table) {
+			if (it_cdr->fn_table == &finalized_state_fn_table && it_cdr->next != NULL) {
 				continue;
 			}
 			if (!strcasecmp(channel_name, it_cdr->party_a.snapshot->name)) {

-- 
To view, visit https://gerrit.asterisk.org/1898
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icf3553c607b9f561152a41e6d8381d594ccdf4b9
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-code-review mailing list