<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/10618">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">taskprocessor: Do not use separate allocation for stats.<br><br>Merge the stats object into struct ast_taskprocessor.<br><br>Change-Id: I74fe9a7f357f0e6d63152f163cf5eef6428218e1<br>---<br>M main/taskprocessor.c<br>1 file changed, 8 insertions(+), 18 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/18/10618/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/taskprocessor.c b/main/taskprocessor.c</span><br><span>index 33acb37..2629eab 100644</span><br><span>--- a/main/taskprocessor.c</span><br><span>+++ b/main/taskprocessor.c</span><br><span>@@ -70,7 +70,7 @@</span><br><span> /*! \brief Friendly name of the taskprocessor */</span><br><span> const char *name;</span><br><span> /*! \brief Taskprocessor statistics */</span><br><span style="color: hsl(0, 100%, 40%);">- struct tps_taskprocessor_stats *stats;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct tps_taskprocessor_stats stats;</span><br><span> void *local_data;</span><br><span> /*! \brief Taskprocessor current queue size */</span><br><span> long tps_queue_size;</span><br><span>@@ -515,13 +515,8 @@</span><br><span> while ((tps = ao2_iterator_next(&iter))) {</span><br><span> ast_copy_string(name, tps->name, sizeof(name));</span><br><span> qsize = tps->tps_queue_size;</span><br><span style="color: hsl(0, 100%, 40%);">- if (tps->stats) {</span><br><span style="color: hsl(0, 100%, 40%);">- maxqsize = tps->stats->max_qsize;</span><br><span style="color: hsl(0, 100%, 40%);">- processed = tps->stats->_tasks_processed_count;</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- maxqsize = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- processed = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ maxqsize = tps->stats.max_qsize;</span><br><span style="color: hsl(120, 100%, 40%);">+ processed = tps->stats._tasks_processed_count;</span><br><span> ast_cli(a->fd, FMT_FIELDS, name, processed, qsize, maxqsize,</span><br><span> tps->tps_queue_low, tps->tps_queue_high);</span><br><span> ast_taskprocessor_unreference(tps);</span><br><span>@@ -645,8 +640,6 @@</span><br><span> tps_alert_add(t, -1);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_free(t->stats);</span><br><span style="color: hsl(0, 100%, 40%);">- t->stats = NULL;</span><br><span> ast_free((char *) t->name);</span><br><span> t->name = NULL;</span><br><span> ao2_cleanup(t->listener);</span><br><span>@@ -754,9 +747,8 @@</span><br><span> p->tps_queue_low = (AST_TASKPROCESSOR_HIGH_WATER_LEVEL * 9) / 10;</span><br><span> p->tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- p->stats = ast_calloc(1, sizeof(*p->stats));</span><br><span> p->name = ast_strdup(name);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!p->stats || !p->name) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!p->name) {</span><br><span> ao2_ref(p, -1);</span><br><span> return NULL;</span><br><span> }</span><br><span>@@ -985,13 +977,11 @@</span><br><span> size = ast_taskprocessor_size(tps);</span><br><span> </span><br><span> /* Update the stats */</span><br><span style="color: hsl(0, 100%, 40%);">- if (tps->stats) {</span><br><span style="color: hsl(0, 100%, 40%);">- ++tps->stats->_tasks_processed_count;</span><br><span style="color: hsl(120, 100%, 40%);">+ ++tps->stats._tasks_processed_count;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* Include the task we just executed as part of the queue size. */</span><br><span style="color: hsl(0, 100%, 40%);">- if (size >= tps->stats->max_qsize) {</span><br><span style="color: hsl(0, 100%, 40%);">- tps->stats->max_qsize = size + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Include the task we just executed as part of the queue size. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (size >= tps->stats.max_qsize) {</span><br><span style="color: hsl(120, 100%, 40%);">+ tps->stats.max_qsize = size + 1;</span><br><span> }</span><br><span> ao2_unlock(tps);</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10618">change 10618</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/10618"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I74fe9a7f357f0e6d63152f163cf5eef6428218e1 </div>
<div style="display:none"> Gerrit-Change-Number: 10618 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>