From 8b75a68f13ac545ab48054c3cd80c456010ec947 Mon Sep 17 00:00:00 2001
From: Matthew Jordan <mjordan@digium.com>
Date: Thu, 8 Aug 2013 02:58:01 +0000
Subject: [PATCH] Handle Surrogate channels in Dial message processing

Depending on when a Surrogate channel replaces an existing channel, it is
possible to get a Dial message for the Surrogate channel. When this occurs, no
CDR will exist for the channel as Surrogate channels are ignored. Safely handle
the case when a CDR doesn't exist for a Dial message.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396371 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 main/cdr.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/main/cdr.c b/main/cdr.c
index 276f15bc45..15f98ef1e1 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -1818,6 +1818,11 @@ static void handle_dial_message(void *data, struct stasis_subscription *sub, str
 		cdr = ao2_find(active_cdrs_by_channel, peer->name, OBJ_KEY);
 	}
 
+	if (!cdr) {
+		ast_log(AST_LOG_WARNING, "No CDR for channel %s\n", caller ? caller->name : peer->name);
+		return;
+	}
+
 	ao2_lock(cdr);
 	for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {
 		if (ast_strlen_zero(dial_status)) {
@@ -1896,7 +1901,7 @@ static int cdr_object_update_party_b(void *obj, void *arg, int flags)
 /*! \internal \brief Filter channel snapshots by technology */
 static int filter_channel_snapshot(struct ast_channel_snapshot *snapshot)
 {
-	return snapshot->tech_properties & (AST_CHAN_TP_ANNOUNCER | AST_CHAN_TP_RECORDER);
+	return snapshot->tech_properties & AST_CHAN_TP_INTERNAL;
 }
 
 /*! \internal \brief Filter a channel cache update */
-- 
GitLab