<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11170">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_queue: Fix a few member pause bugs<br><br>* When setting member->paused, make sure to always set member->lastpaused<br> and member->reason_paused if applicable. Created a simple wrapper<br> function to handle this.<br><br>* When printing the time the member was paused, use member->lastpaused,<br> regardless of a reason phrase being present or not.<br><br>ASTERISK-27541 #close<br>Reported by: César Benjamín García Martínez<br><br>Change-Id: I80507e05e3c9bc61843104c405a9ed9c0de1594e<br>---<br>M apps/app_queue.c<br>1 file changed, 22 insertions(+), 21 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/11170/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_queue.c b/apps/app_queue.c</span><br><span>index 132621d..b2114a4 100644</span><br><span>--- a/apps/app_queue.c</span><br><span>+++ b/apps/app_queue.c</span><br><span>@@ -2683,6 +2683,19 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Wrapper to ensure that the last pause time is set */</span><br><span style="color: hsl(120, 100%, 40%);">+static void member_set_paused(struct member *mem, int paused, const char *reason)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ mem->reason_paused[0] = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+ mem->paused = paused;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (paused) {</span><br><span style="color: hsl(120, 100%, 40%);">+ time(&mem->lastpause);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(reason)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(mem->reason_paused, reason, sizeof(mem->reason_paused));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! \brief allocate space for new queue member and set fields based on parameters passed */</span><br><span> static struct member *create_queue_member(const char *interface, const char *membername, int penalty, int paused, const char *state_interface, int ringinuse, int wrapuptime)</span><br><span> {</span><br><span>@@ -2691,11 +2704,8 @@</span><br><span> if ((cur = ao2_alloc(sizeof(*cur), destroy_queue_member_cb))) {</span><br><span> cur->ringinuse = ringinuse;</span><br><span> cur->penalty = penalty;</span><br><span style="color: hsl(0, 100%, 40%);">- cur->paused = paused;</span><br><span> cur->wrapuptime = wrapuptime;</span><br><span style="color: hsl(0, 100%, 40%);">- if (paused) {</span><br><span style="color: hsl(0, 100%, 40%);">- time(&cur->lastpause); /* Update time of last pause */</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ member_set_paused(cur, paused, NULL);</span><br><span> ast_copy_string(cur->interface, interface, sizeof(cur->interface));</span><br><span> if (!ast_strlen_zero(state_interface)) {</span><br><span> ast_copy_string(cur->state_interface, state_interface, sizeof(cur->state_interface));</span><br><span>@@ -3461,7 +3471,7 @@</span><br><span> m->dead = 0; /* Do not delete this one. */</span><br><span> ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid));</span><br><span> if (paused_str) {</span><br><span style="color: hsl(0, 100%, 40%);">- m->paused = paused;</span><br><span style="color: hsl(120, 100%, 40%);">+ member_set_paused(m, paused, NULL);</span><br><span> ast_devstate_changed(m->paused ? QUEUE_PAUSED_DEVSTATE : QUEUE_UNPAUSED_DEVSTATE,</span><br><span> AST_DEVSTATE_CACHABLE, "Queue:%s_pause_%s", q->name, m->interface);</span><br><span> }</span><br><span>@@ -7488,15 +7498,7 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- mem->paused = paused;</span><br><span style="color: hsl(0, 100%, 40%);">- if (paused) {</span><br><span style="color: hsl(0, 100%, 40%);">- time(&mem->lastpause); /* update last pause field */</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- if (paused && !ast_strlen_zero(reason)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_string(mem->reason_paused, reason, sizeof(mem->reason_paused));</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- mem->reason_paused[0] = '\0';</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ member_set_paused(mem, paused, mem->reason_paused);</span><br><span> </span><br><span> ast_devstate_changed(mem->paused ? QUEUE_PAUSED_DEVSTATE : QUEUE_UNPAUSED_DEVSTATE,</span><br><span> AST_DEVSTATE_CACHABLE, "Queue:%s_pause_%s", q->name, mem->interface);</span><br><span>@@ -9749,13 +9751,12 @@</span><br><span> mem->realtime ? ast_term_color(COLOR_MAGENTA, COLOR_BLACK) : "", mem->realtime ? " (realtime)" : "", ast_term_reset(),</span><br><span> mem->starttime ? ast_term_color(COLOR_BROWN, COLOR_BLACK) : "", mem->starttime ? " (in call)" : "", ast_term_reset());</span><br><span> if (mem->paused) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_strlen_zero(mem->reason_paused)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&out, 0, " %s(paused was %ld secs ago)%s",</span><br><span style="color: hsl(0, 100%, 40%);">- ast_term_color(COLOR_BROWN, COLOR_BLACK), (long) (time(NULL) - mem->lastpause), ast_term_reset());</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&out, 0, " %s(paused:%s was %ld secs ago)%s", ast_term_color(COLOR_BROWN, COLOR_BLACK),</span><br><span style="color: hsl(0, 100%, 40%);">- mem->reason_paused, (long) (time(NULL) - mem->lastcall), ast_term_reset());</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&out, 0, " %s(paused%s%s was %ld secs ago)%s",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_term_color(COLOR_BROWN, COLOR_BLACK),</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_strlen_zero(mem->reason_paused) ? "" : ":",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_strlen_zero(mem->reason_paused) ? "" : mem->reason_paused,</span><br><span style="color: hsl(120, 100%, 40%);">+ (long) (time(NULL) - mem->lastpause),</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_term_reset());</span><br><span> }</span><br><span> </span><br><span> ast_str_append(&out, 0, " (%s%s%s)",</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11170">change 11170</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/+/11170"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I80507e05e3c9bc61843104c405a9ed9c0de1594e </div>
<div style="display:none"> Gerrit-Change-Number: 11170 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>