[asterisk-commits] mjordan: trunk r420309 - /trunk/main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 7 09:18:02 CDT 2014


Author: mjordan
Date: Thu Aug  7 09:17:54 2014
New Revision: 420309

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=420309
Log:
pbx: Filter out pattern matching hints in responses sent to ExtensionStateList

Hints that are a pattern match are technically stored in the hint container in
the same fashion as concrete implementations of hints. The pattern matching
hints, however, are not "real" in the sense that things can subscribe to them:
rather, they are stored in the hints container so that when a subscription is
made a "real" hint can be generated for the subscription if one does not yet
exist. The extension state core takes care of this correctly by matching
against non-pattern matching extensions prior to pattern matching extensions.

Because of this, however, the ExtensionStateList AMI action was returning
pattern matching hints when executed. These hints are meaningless from the
perspective of AMI clients: their state will never change, they cannot be
subscribed to, and events would never normally be generated from them. As such,
we now filter these out of the response.

Modified:
    trunk/main/pbx.c

Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=420309&r1=420308&r2=420309
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Thu Aug  7 09:17:54 2014
@@ -11980,6 +11980,7 @@
 	const char *action_id = astman_get_header(m, "ActionID");
 	struct ast_hint *hint;
 	struct ao2_iterator it_hints;
+	int hint_count = 0;
 
 	if (!hints) {
 		astman_send_error(s, m, "No dialplan hints are available");
@@ -11993,6 +11994,18 @@
 	for (; (hint = ao2_iterator_next(&it_hints)); ao2_ref(hint, -1)) {
 
 		ao2_lock(hint);
+
+		/* Ignore pattern matching hints; they are stored in the
+		 * hints container but aren't real from the perspective of
+		 * an AMI user
+		 */
+		if (hint->exten->exten[0] == '_') {
+			ao2_unlock(hint);
+			continue;
+		}
+
+		++hint_count;
+
 		astman_append(s, "Event: ExtensionStatus\r\n");
 		if (!ast_strlen_zero(action_id)) {
 			astman_append(s, "ActionID: %s\r\n", action_id);
@@ -12015,7 +12028,7 @@
 		astman_append(s, "ActionID: %s\r\n", action_id);
 	}
 	astman_append(s, "EventList: Complete\r\n"
-		"ListItems: %d\r\n\r\n", ao2_container_count(hints));
+		"ListItems: %d\r\n\r\n", hint_count);
 
 	ao2_iterator_destroy(&it_hints);
 	ao2_unlock(hints);




More information about the asterisk-commits mailing list