Hi,
I have a problem with an accompanying solution that I wish to share, but I am 
not sure if it is valuable enough or correct enough to be suggested as a patch 
to Asterisk.

When SIP-phones are members of a queue, they tend to accumulate "missed calls" 
unless the C-flag is applied. When the C-flag is applied there is no missed 
calls at all, since all hangups are marked as "answered elsewhere". I have 
created and attached a patch which makes the C-flag "answer elsewhere" all 
hangups that are caused by app_queue canceling the dial or the call is really 
answered elsewhere, but sets normal cause when caller actually hangs up before 
the call is answered.

I know the patch alters the behavior of the C-flag, and altering behavior of 
existing flags is probably a bad thing. I can try to create a new flag for this 
"missed call on caller hangup"-behavior if that is of any value. Also, I don't 
have much experience with the Asterisk source code, so if I break something by 
setting normal cause here I would be very happy if anyone would give me a hint 
about it. The only problem I have seen so far is that if the caller hangs up 
during an announcement or between app_queue's dial outs, the call is not marked 
as missed (as the previous call was "answered elsewhere" and no new calls went 
out to the phones).

The code is running a few places without causing any trouble as far as I can 
tell. I wrote this after a customer had a few thousand missed calls on his 
queue-connected phone...

Best regards and thanks for a great project!
Stian Hvatum
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 234543f..76fc6a2 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -4002,6 +4002,8 @@ static void hangupcalls(struct queue_ent *qe, struct callattempt *outgoing, stru
 		if (outgoing->chan && (outgoing->chan != exception)) {
 			if (exception || cancel_answered_elsewhere) {
 				ast_channel_hangupcause_set(outgoing->chan, AST_CAUSE_ANSWERED_ELSEWHERE);
+			} else {
+				ast_channel_hangupcause_set(outgoing->chan, AST_CAUSE_NORMAL);
 			}
 			ast_channel_publish_dial(qe->chan, outgoing->chan, outgoing->interface, "CANCEL");
 			ast_hangup(outgoing->chan);
@@ -6832,7 +6834,7 @@ static int try_calling(struct queue_ent *qe, struct ast_flags opts, char **opt_a
 		ao2_ref(member, -1);
 	}
 out:
-	hangupcalls(qe, outgoing, NULL, qe->cancel_answered_elsewhere);
+	hangupcalls(qe, outgoing, NULL, qe->cancel_answered_elsewhere && res != -1);
 
 	return res;
 }
-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Reply via email to