[Asterisk-code-review] app queue: Fix duplicate queue log entries for EXITEMPTY and... (asterisk[master])

Joshua Colp asteriskteam at digium.com
Mon May 22 05:37:32 CDT 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/5617 )

Change subject: app_queue: Fix duplicate queue_log entries for EXITEMPTY and ABANDON
......................................................................


app_queue: Fix duplicate queue_log entries for EXITEMPTY and ABANDON

There are 2 places in app_queue.c that log EXITEMPTY event: one in
wait_our_turn, and another one in queue_exec in the loop trying to
call an agent after wait_our_turn.

In most cases it leads to logging EXITEMPTY twice.

ABANDON is also logged on two places, and in the rare case when an agent
and caller hang up simultaneously it's also possible to get duplicates
in queue_log.

This commit changes wait_our_turn to return -1 ("the caller should exit
the queue") instead of 0 ("the caller's turn has arrived") in case of
leaving when empty, so queue_exec skips the agent calling loop.

Also, leave_queue is now executed only once in this case, because 2nd
time is just a noop when the queue entry has already been removed.

Also, it sets qe->handled to -1 to indicate that the call was not
answered by an agent, but the necessary handling has already been done
in order to avoid logging an extra ABANDON entry.

ASTERISK-25665 #close
Reported by: Ove Aursand

Change-Id: I4578dd383bf2ac41589cf167865e8aaebcd4c11e
---
M apps/app_queue.c
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/apps/app_queue.c b/apps/app_queue.c
index 2389f0b..0f46d28 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -5465,7 +5465,8 @@
 			if ((status = get_member_status(qe->parent, qe->max_penalty, qe->min_penalty, qe->parent->leavewhenempty, 0))) {
 				*reason = QUEUE_LEAVEEMPTY;
 				ast_queue_log(qe->parent->name, ast_channel_uniqueid(qe->chan), "NONE", "EXITEMPTY", "%d|%d|%ld", qe->pos, qe->opos, (long) (time(NULL) - qe->start));
-				leave_queue(qe);
+				res = -1;
+				qe->handled = -1;
 				break;
 			}
 		}
@@ -6803,6 +6804,7 @@
 				ast_log(LOG_NOTICE, "Caller was about to talk to agent on %s but the caller hungup.\n", ast_channel_name(peer));
 				ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "ABANDON", "%d|%d|%ld", qe->pos, qe->opos, (long) (time(NULL) - qe->start));
 				record_abandoned(qe);
+				qe->handled = -1;
 				ast_channel_publish_dial(qe->chan, peer, member->interface, ast_hangup_cause_to_dial_status(ast_channel_hangupcause(peer)));
 				ast_autoservice_chan_hangup_peer(qe->chan, peer);
 				ao2_ref(member, -1);

-- 
To view, visit https://gerrit.asterisk.org/5617
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4578dd383bf2ac41589cf167865e8aaebcd4c11e
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Ivan Poddubny <ivan.poddubny at gmail.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-code-review mailing list