<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14565">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_queue: Read latest wrapuptime instead of (possibly stale) copy<br><br>Before this changeset, it was possible that a queue member (agent) was<br>called even though they just got out of a call, and wrapuptime seconds<br>hadn't passed yet.<br><br>This could happen if a member ended a call _between_ a new call attempt<br>and asterisk trying that particular member for a new call.<br><br>In that case, Asterisk would check the hangup time of the<br>call-before-the-last-call instead of the hangup time of the-last-call.<br><br>ASTERISK-28952<br><br>Change-Id: Ie0cab8f0e8d639c01cba633d4968ba19873d80b3<br>---<br>M apps/app_queue.c<br>1 file changed, 16 insertions(+), 19 deletions(-)<br><br></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 87e2f05..b6d857b 100644</span><br><span>--- a/apps/app_queue.c</span><br><span>+++ b/apps/app_queue.c</span><br><span>@@ -1546,8 +1546,6 @@</span><br><span> struct ast_channel *chan;</span><br><span> char interface[256]; /*!< An Asterisk dial string (not a channel name) */</span><br><span> int metric;</span><br><span style="color: hsl(0, 100%, 40%);">- time_t lastcall;</span><br><span style="color: hsl(0, 100%, 40%);">- struct call_queue *lastqueue;</span><br><span> struct member *member;</span><br><span> /*! Saved connected party info from an AST_CONTROL_CONNECTED_LINE. */</span><br><span> struct ast_party_connected_line connected;</span><br><span>@@ -4389,42 +4387,43 @@</span><br><span> */</span><br><span> static int can_ring_entry(struct queue_ent *qe, struct callattempt *call)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct member *memberp = call->member;</span><br><span> int wrapuptime;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (call->member->paused) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (memberp->paused) {</span><br><span> ast_debug(1, "%s paused, can't receive call\n", call->interface);</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!call->member->ringinuse && !member_status_available(call->member->status)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!memberp->ringinuse && !member_status_available(memberp->status)) {</span><br><span> ast_debug(1, "%s not available, can't receive call\n", call->interface);</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (call->lastqueue) {</span><br><span style="color: hsl(0, 100%, 40%);">- wrapuptime = get_wrapuptime(call->lastqueue, call->member);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (memberp->lastqueue) {</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapuptime = get_wrapuptime(memberp->lastqueue, memberp);</span><br><span> } else {</span><br><span style="color: hsl(0, 100%, 40%);">- wrapuptime = get_wrapuptime(qe->parent, call->member);</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapuptime = get_wrapuptime(qe->parent, memberp);</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (wrapuptime && time(NULL) - call->lastcall < wrapuptime) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (wrapuptime && (time(NULL) - memberp->lastcall) < wrapuptime) {</span><br><span> ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n",</span><br><span style="color: hsl(0, 100%, 40%);">- (call->lastqueue ? call->lastqueue->name : qe->parent->name),</span><br><span style="color: hsl(120, 100%, 40%);">+ (memberp->lastqueue ? memberp->lastqueue->name : qe->parent->name),</span><br><span> call->interface);</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (use_weight && compare_weight(qe->parent, call->member)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (use_weight && compare_weight(qe->parent, memberp)) {</span><br><span> ast_debug(1, "Priority queue delaying call to %s:%s\n",</span><br><span> qe->parent->name, call->interface);</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!call->member->ringinuse) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!memberp->ringinuse) {</span><br><span> struct member *mem;</span><br><span> </span><br><span> ao2_lock(pending_members);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- mem = ao2_find(pending_members, call->member,</span><br><span style="color: hsl(120, 100%, 40%);">+ mem = ao2_find(pending_members, memberp,</span><br><span> OBJ_SEARCH_OBJECT | OBJ_NOLOCK);</span><br><span> if (mem) {</span><br><span> /*</span><br><span>@@ -4442,8 +4441,8 @@</span><br><span> * If not found add it to the container so another queue</span><br><span> * won't attempt to call this member at the same time.</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(3, "Add %s to pending_members\n", call->member->membername);</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_link(pending_members, call->member);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "Add %s to pending_members\n", memberp->membername);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_link(pending_members, memberp);</span><br><span> ao2_unlock(pending_members);</span><br><span> </span><br><span> /*</span><br><span>@@ -4451,10 +4450,10 @@</span><br><span> * because the device state and extension state callbacks may</span><br><span> * not have updated the status yet.</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">- if (!member_status_available(get_queue_member_status(call->member))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!member_status_available(get_queue_member_status(memberp))) {</span><br><span> ast_debug(1, "%s actually not available, can't receive call\n",</span><br><span> call->interface);</span><br><span style="color: hsl(0, 100%, 40%);">- pending_members_remove(call->member);</span><br><span style="color: hsl(120, 100%, 40%);">+ pending_members_remove(memberp);</span><br><span> return 0;</span><br><span> }</span><br><span> }</span><br><span>@@ -6857,9 +6856,7 @@</span><br><span> </span><br><span> tmp->block_connected_update = block_connected_line;</span><br><span> tmp->stillgoing = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- tmp->member = cur;/* Place the reference for cur into callattempt. */</span><br><span style="color: hsl(0, 100%, 40%);">- tmp->lastcall = cur->lastcall;</span><br><span style="color: hsl(0, 100%, 40%);">- tmp->lastqueue = cur->lastqueue;</span><br><span style="color: hsl(120, 100%, 40%);">+ tmp->member = cur; /* Place the reference for cur into callattempt. */</span><br><span> ast_copy_string(tmp->interface, cur->interface, sizeof(tmp->interface));</span><br><span> /* Calculate the metric for the appropriate strategy. */</span><br><span> if (!calc_metric(qe->parent, cur, x++, qe, tmp)) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14565">change 14565</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/+/14565"/><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: Ie0cab8f0e8d639c01cba633d4968ba19873d80b3 </div>
<div style="display:none"> Gerrit-Change-Number: 14565 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Walter Doekes <walter+asterisk@wjd.nu> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>