[asterisk-commits] irroot: branch 1.8 r337839 - /branches/1.8/apps/app_queue.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 23 03:34:09 CDT 2011


Author: irroot
Date: Fri Sep 23 03:34:03 2011
New Revision: 337839

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=337839
Log:
Make sure a CDR is on the stack for call in the Queue.
Only let update_cdr act on the last CDR in the stack.

In some circumstances [Attended transfer to queue] a 
CDR record is not inserted for this call where it should.

(closes issue ASTERISK-18567)

Review: https://reviewboard.asterisk.org/r/1266


Modified:
    branches/1.8/apps/app_queue.c

Modified: branches/1.8/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_queue.c?view=diff&rev=337839&r1=337838&r2=337839
==============================================================================
--- branches/1.8/apps/app_queue.c (original)
+++ branches/1.8/apps/app_queue.c Fri Sep 23 03:34:03 2011
@@ -4986,8 +4986,34 @@
 		qe->handled++;
 		ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "CONNECT", "%ld|%s|%ld", (long) time(NULL) - qe->start, peer->uniqueid,
 													(long)(orig - to > 0 ? (orig - to) / 1000 : 0));
-		if (update_cdr && qe->chan->cdr) 
-			ast_copy_string(qe->chan->cdr->dstchannel, member->membername, sizeof(qe->chan->cdr->dstchannel));
+
+		if (qe->chan->cdr) {
+			struct ast_cdr *cdr;
+			struct ast_cdr *newcdr;
+
+			/* Only work with the last CDR in the stack*/
+			cdr = qe->chan->cdr;
+			while (cdr->next) {
+				cdr = cdr->next;
+			}
+
+			/* If this CDR is not related to us add new one*/
+			if ((strcasecmp(cdr->uniqueid, qe->chan->uniqueid)) &&
+			    (strcasecmp(cdr->linkedid, qe->chan->uniqueid)) &&
+			    (newcdr = ast_cdr_dup(cdr))) {
+				ast_cdr_init(newcdr, qe->chan);
+				ast_cdr_reset(newcdr, 0);
+				ast_channel_lock(qe->chan);
+				cdr = ast_cdr_append(cdr, newcdr);
+				cdr = cdr->next;
+				ast_channel_unlock(qe->chan);
+			}
+
+			if (update_cdr) {
+				ast_copy_string(cdr->dstchannel, member->membername, sizeof(cdr->dstchannel));
+			}
+		}
+
 		if (qe->parent->eventwhencalled)
 			manager_event(EVENT_FLAG_AGENT, "AgentConnect",
 					"Queue: %s\r\n"




More information about the asterisk-commits mailing list