<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16411">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_queue: Fix hint updates for included contexts<br><br>Previously, if custom hints were used with the hint:<br>format in app_queue, when device state changes occured,<br>app_queue would only do a literal string comparison of<br>the context used for the hint in app_queue and the context<br>of the hint which just changed state. This caused hints<br>to not update and become stale if the context associated<br>with the agent included the context which actually changes<br>state, essentially completely breaking device state for<br>any such agents defined in this manner.<br><br>This fix adds an additional check to ensure that included<br>contexts are also compared against the context which changed<br>state, so that the behavior is correct no matter whether the<br>context is specified to app_queue directly or indirectly.<br><br>ASTERISK-29578 #close<br><br>Change-Id: I8caf2f8da8157ef3d9ea71a8568c1eec95592b78<br>---<br>M apps/app_queue.c<br>1 file changed, 31 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/11/16411/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 fdc5211..5fe262c 100644</span><br><span>--- a/apps/app_queue.c</span><br><span>+++ b/apps/app_queue.c</span><br><span>@@ -2649,7 +2649,30 @@</span><br><span> </span><br><span>           miter = ao2_iterator_init(q->members, 0);</span><br><span>                 for (; (m = ao2_iterator_next(&miter)); ao2_ref(m, -1)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                 unsigned short int context_found = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                      if (!strcmp(m->state_context, context) && !strcmp(m->state_exten, exten)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                             context_found = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+                    } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                              /* context could be included in m->state_context. We need to check. */</span><br><span style="color: hsl(120, 100%, 40%);">+                             struct ast_context *c = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+                         int idx;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                            while ((c = ast_walk_contexts(c))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                  if (!strcmp(ast_get_context_name(c), m->state_context)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                          /* found the context of the hint app_queue is using. Now, see</span><br><span style="color: hsl(120, 100%, 40%);">+                                                 if that context includes the one that just changed state */</span><br><span style="color: hsl(120, 100%, 40%);">+                                           for (idx = 0; idx < ast_context_includes_count(c); idx++) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                                        const struct ast_include *inc = ast_context_includes_get(c, idx);</span><br><span style="color: hsl(120, 100%, 40%);">+                                                     if (!strcasecmp(context, ast_get_include_name(inc))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                                                context_found = 1;</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%);">+                                             break;</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%);">+                     if (context_found) {</span><br><span>                                 update_status(q, m, device_state);</span><br><span>                           ao2_ref(m, -1);</span><br><span>                              found = 1;</span><br><span>@@ -2663,7 +2686,7 @@</span><br><span>   }</span><br><span>    ao2_iterator_destroy(&qiter);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        if (found) {</span><br><span style="color: hsl(120, 100%, 40%);">+     if (found) {</span><br><span>                 ast_debug(1, "Extension '%s@%s' changed to state '%d' (%s)\n", exten, context, device_state, ast_devstate2str(device_state));</span><br><span>      } else {</span><br><span>             ast_debug(3, "Extension '%s@%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n",</span><br><span>@@ -9339,9 +9362,13 @@</span><br><span>       if ((newm = create_queue_member(interface, membername, penalty, cur ? cur->paused : 0, state_interface, ringinuse, wrapuptime))) {</span><br><span>                newm->wrapuptime = wrapuptime;</span><br><span>            if (cur) {</span><br><span style="color: hsl(0, 100%, 40%);">-                      /* Round Robin Queue Position must be copied if this is replacing an existing member */</span><br><span>                      ao2_lock(q->members);</span><br><span style="color: hsl(120, 100%, 40%);">+                      /* Round Robin Queue Position must be copied if this is replacing an existing member */</span><br><span>                      newm->queuepos = cur->queuepos;</span><br><span style="color: hsl(120, 100%, 40%);">+                 /* Don't reset agent stats either */</span><br><span style="color: hsl(120, 100%, 40%);">+                      newm->calls = cur->calls;</span><br><span style="color: hsl(120, 100%, 40%);">+                       newm->lastcall = cur->lastcall;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                      ao2_link(q->members, newm);</span><br><span>                       ao2_unlink(q->members, cur);</span><br><span>                      ao2_unlock(q->members);</span><br><span>@@ -10407,7 +10434,7 @@</span><br><span>         }</span><br><span> </span><br><span>        if (!header_found) {</span><br><span style="color: hsl(0, 100%, 40%);">-            ast_set_flag(&mask, AST_FLAGS_ALL);</span><br><span style="color: hsl(120, 100%, 40%);">+               ast_set_flag(&mask, AST_FLAGS_ALL & ~QUEUE_RESET_STATS);</span><br><span>     }</span><br><span> </span><br><span>        if (!reload_handler(1, &mask, queuename)) {</span><br><span>@@ -11146,7 +11173,7 @@</span><br><span>    } else if (!strcasecmp(a->argv[2], "parameters")) {</span><br><span>             ast_set_flag(&mask, QUEUE_RELOAD_PARAMETERS);</span><br><span>    } else if (!strcasecmp(a->argv[2], "all")) {</span><br><span style="color: hsl(0, 100%, 40%);">-               ast_set_flag(&mask, AST_FLAGS_ALL);</span><br><span style="color: hsl(120, 100%, 40%);">+               ast_set_flag(&mask, AST_FLAGS_ALL & ~QUEUE_RESET_STATS);</span><br><span>     }</span><br><span> </span><br><span>        if (a->argc == 3) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16411">change 16411</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/+/16411"/><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-Change-Id: I8caf2f8da8157ef3d9ea71a8568c1eec95592b78 </div>
<div style="display:none"> Gerrit-Change-Number: 16411 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>