<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6771">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cdr.c: Set stringfields only if they are different.<br><br>The CDR performance gets worse the further it gets behind in processing<br>stasis messages. One of the reasons is we were repeatedly setting string<br>fields to potentially the same string in base_process_party_a(). Setting<br>a string field involves allocating room for the new string out of a memory<br>pool which may have to allocate even more memory.<br><br>* Check to see if the string field is already set to the desired string.<br><br>ASTERISK-27335<br><br>Change-Id: I3ccb7e23f1488417e08cafe477755033eed65a7c<br>---<br>M main/cdr.c<br>1 file changed, 18 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/71/6771/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/cdr.c b/main/cdr.c<br>index 28dab7e..aef3be5 100644<br>--- a/main/cdr.c<br>+++ b/main/cdr.c<br>@@ -1381,8 +1381,12 @@<br> */<br> if (!ast_test_flag(&snapshot->flags, AST_FLAG_SUBROUTINE_EXEC)<br> || ast_test_flag(&snapshot->softhangup_flags, AST_SOFTHANGUP_HANGUP_EXEC)) {<br>- ast_string_field_set(cdr, context, snapshot->context);<br>- ast_string_field_set(cdr, exten, snapshot->exten);<br>+ if (strcmp(cdr->context, snapshot->context)) {<br>+ ast_string_field_set(cdr, context, snapshot->context);<br>+ }<br>+ if (strcmp(cdr->exten, snapshot->exten)) {<br>+ ast_string_field_set(cdr, exten, snapshot->exten);<br>+ }<br> }<br> <br> cdr_object_swap_snapshot(&cdr->party_a, snapshot);<br>@@ -1392,11 +1396,15 @@<br> * of "AppDialX". Prevent that, and any other application changes we might not want<br> * here.<br> */<br>- if (!ast_strlen_zero(snapshot->appl)<br>- && (strncasecmp(snapshot->appl, "appdial", 7) || ast_strlen_zero(cdr->appl))<br>- && !ast_test_flag(&cdr->flags, AST_CDR_LOCK_APP)) {<br>- ast_string_field_set(cdr, appl, snapshot->appl);<br>- ast_string_field_set(cdr, data, snapshot->data);<br>+ if (!ast_test_flag(&cdr->flags, AST_CDR_LOCK_APP)<br>+ && !ast_strlen_zero(snapshot->appl)<br>+ && (strncasecmp(snapshot->appl, "appdial", 7) || ast_strlen_zero(cdr->appl))) {<br>+ if (strcmp(cdr->appl, snapshot->appl)) {<br>+ ast_string_field_set(cdr, appl, snapshot->appl);<br>+ }<br>+ if (strcmp(cdr->data, snapshot->data)) {<br>+ ast_string_field_set(cdr, data, snapshot->data);<br>+ }<br> <br> /* Dial (app_dial) is a special case. Because pre-dial handlers, which<br> * execute before the dial begins, will alter the application/data to<br>@@ -1408,7 +1416,9 @@<br> }<br> }<br> <br>- ast_string_field_set(cdr, linkedid, snapshot->linkedid);<br>+ if (strcmp(cdr->linkedid, snapshot->linkedid)) {<br>+ ast_string_field_set(cdr, linkedid, snapshot->linkedid);<br>+ }<br> cdr_object_check_party_a_answer(cdr);<br> cdr_object_check_party_a_hangup(cdr);<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6771">change 6771</a>. To unsubscribe, 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/6771"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 14 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I3ccb7e23f1488417e08cafe477755033eed65a7c </div>
<div style="display:none"> Gerrit-Change-Number: 6771 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>