[asterisk-commits] murf: branch group/newcdr r155927 - /team/group/newcdr/main/cel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Nov 10 23:58:31 CST 2008


Author: murf
Date: Mon Nov 10 23:58:29 2008
New Revision: 155927

URL: http://svn.digium.com/view/asterisk?view=rev&rev=155927
Log:
Update to use Sean Bright's cool new channel find mechanism.


Modified:
    team/group/newcdr/main/cel.c

Modified: team/group/newcdr/main/cel.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/cel.c?view=diff&rev=155927&r1=155926&r2=155927
==============================================================================
--- team/group/newcdr/main/cel.c (original)
+++ team/group/newcdr/main/cel.c Mon Nov 10 23:58:29 2008
@@ -402,30 +402,28 @@
 	return "Unknown";
 }
 
+/* called whenever a channel is destroyed or a linkedid is changed to
+ * potentially emit a CEL_LINKEDID_END event */
+
+int linkedid_match(struct ast_channel *c) 
+{
+	return (c != chan && c->linkedid && !strcmp(linkedid, c->linkedid));
+}
+
 void ast_cel_check_retire_linkedid(const struct ast_channel *chan)
 {
-	int found=0;
-	struct ast_channel *tmp = NULL;
-	const char *linkedid = chan->linkedid;
-
-	/* make sure we need to do all this work */
-	if (!ast_strlen_zero(linkedid) && track_event(CEL_LINKEDID_END)) {
-
-		while ((tmp = ast_channel_walk_locked(tmp))) {
-
-			if (tmp != chan && tmp->linkedid && 0==strcmp(linkedid, tmp->linkedid)) {
-				found=1;
-				ast_channel_unlock(tmp);
-				break;
-			}
-
-			ast_channel_unlock(tmp);
-		}
-
-		if (!found) {
-			ast_cel_report_event(chan, CEL_LINKEDID_END, NULL, NULL, NULL);
-		}
-	}
+    const char *linkedid = chan->linkedid;
+
+    /* make sure we need to do all this work */
+    if (!ast_strlen_zero(linkedid) && track_event(CEL_LINKEDID_END)) {
+        struct ast_channel *tmp = NULL;
+        if ((tmp = ast_channel_search_locked(linkedid_match))) {
+            ast_channel_unlock(tmp);
+            tmp = NULL;
+        } else {
+            ast_cel_report_event(chan, CEL_LINKEDID_END, NULL, NULL, NULL);
+        }
+    }
 }
 
 /* this routine is only called to populate a dummy channel struct with the data,




More information about the asterisk-commits mailing list