<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13670">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cdr.c: Set event time on party b when leaving a parking bridge<br><br>When Alice calls Bob and Bob does a blind transfer to Charlie,<br>Bob's bridge leave event generates a finalize on both the party_a<br>and party_b CDRs but while the party_a CDR has the correct end time<br>set from the event time, party_b's leg did not. This caused that<br>CDR's end time to be equal to the answered time and resulted in a<br>billsec of 0.<br><br>* We now pass the bridge leave message event time to<br>cdr_object_party_b_left_bridge_cb() and set it on that CDR before<br>calling cdr_object_finalize() on it.<br><br>NOTE: This issue affected transfers using chan_sip most of the<br>time but also occasionally affected chan_pjsip probably due to<br>message timing.<br><br>ASTERISK-28677<br>Reported by: Maciej Michno<br><br>Change-Id: I790720f1e7326f9b8ce8293028743b0ef0fb2cca<br>---<br>M main/cdr.c<br>1 file changed, 10 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/70/13670/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/cdr.c b/main/cdr.c</span><br><span>index 7dfb74c..9b6dee4 100644</span><br><span>--- a/main/cdr.c</span><br><span>+++ b/main/cdr.c</span><br><span>@@ -1464,7 +1464,7 @@</span><br><span> }</span><br><span> </span><br><span> /* tv_usec is suseconds_t, which could be int or long */</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(1, "Finalized CDR for %s - start %ld.%06ld answer %ld.%06ld end %ld.%06ld dispo %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "Finalized CDR for %s - start %ld.%06ld answer %ld.%06ld end %ld.%06ld dur %.3f bill %.3f dispo %s\n",</span><br><span> cdr->party_a.snapshot->name,</span><br><span> (long)cdr->start.tv_sec,</span><br><span> (long)cdr->start.tv_usec,</span><br><span>@@ -1472,6 +1472,8 @@</span><br><span> (long)cdr->answer.tv_usec,</span><br><span> (long)cdr->end.tv_sec,</span><br><span> (long)cdr->end.tv_usec,</span><br><span style="color: hsl(120, 100%, 40%);">+ (double)ast_tvdiff_ms(cdr->end, cdr->start) / 1000.0,</span><br><span style="color: hsl(120, 100%, 40%);">+ (double)ast_tvdiff_ms(cdr->end, cdr->answer) / 1000.0,</span><br><span> ast_cdr_disp2str(cdr->disposition));</span><br><span> }</span><br><span> </span><br><span>@@ -2364,6 +2366,7 @@</span><br><span> struct bridge_leave_data {</span><br><span> struct ast_bridge_snapshot *bridge;</span><br><span> struct ast_channel_snapshot *channel;</span><br><span style="color: hsl(120, 100%, 40%);">+ const struct timeval *lastevent;</span><br><span> };</span><br><span> </span><br><span> /*! \brief Callback used to notify CDRs of a Party B leaving the bridge */</span><br><span>@@ -2382,9 +2385,10 @@</span><br><span> ast_assert(cdr->party_b.snapshot</span><br><span> && !strcasecmp(cdr->party_b.snapshot->name, leave_data->channel->name));</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* It is our Party B, in our bridge. Set the end time and let the handler</span><br><span style="color: hsl(120, 100%, 40%);">+ /* It is our Party B, in our bridge. Set the last event and let the handler</span><br><span> * transition our CDR appropriately when we leave the bridge.</span><br><span> */</span><br><span style="color: hsl(120, 100%, 40%);">+ cdr->lastevent = *leave_data->lastevent;</span><br><span> cdr_object_finalize(cdr);</span><br><span> }</span><br><span> return 0;</span><br><span>@@ -2420,6 +2424,7 @@</span><br><span> struct bridge_leave_data leave_data = {</span><br><span> .bridge = bridge,</span><br><span> .channel = channel,</span><br><span style="color: hsl(120, 100%, 40%);">+ .lastevent = stasis_message_timestamp(message)</span><br><span> };</span><br><span> int left_bridge = 0;</span><br><span> </span><br><span>@@ -2433,8 +2438,8 @@</span><br><span> </span><br><span> CDR_DEBUG("Bridge Leave message for %s: %u.%08u\n",</span><br><span> channel->name,</span><br><span style="color: hsl(0, 100%, 40%);">- (unsigned int)stasis_message_timestamp(message)->tv_sec,</span><br><span style="color: hsl(0, 100%, 40%);">- (unsigned int)stasis_message_timestamp(message)->tv_usec);</span><br><span style="color: hsl(120, 100%, 40%);">+ (unsigned int)leave_data.lastevent->tv_sec,</span><br><span style="color: hsl(120, 100%, 40%);">+ (unsigned int)leave_data.lastevent->tv_usec);</span><br><span> </span><br><span> cdr = ao2_find(active_cdrs_master, channel->uniqueid, OBJ_SEARCH_KEY);</span><br><span> if (!cdr) {</span><br><span>@@ -2446,7 +2451,7 @@</span><br><span> /* Party A */</span><br><span> ao2_lock(cdr);</span><br><span> for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {</span><br><span style="color: hsl(0, 100%, 40%);">- it_cdr->lastevent = *stasis_message_timestamp(message);</span><br><span style="color: hsl(120, 100%, 40%);">+ it_cdr->lastevent = *leave_data.lastevent;</span><br><span> if (!it_cdr->fn_table->process_bridge_leave) {</span><br><span> continue;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13670">change 13670</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13670"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: I790720f1e7326f9b8ce8293028743b0ef0fb2cca </div>
<div style="display:none"> Gerrit-Change-Number: 13670 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>