From: Matthew Jordan Date: Thu, 7 Aug 2014 14:17:54 +0000 (+0000) Subject: pbx: Filter out pattern matching hints in responses sent to ExtensionStateList X-Git-Tag: 13.0.0-beta1~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98af8fb7159e37d4a84950af75873da20bfda439;p=thirdparty%2Fasterisk.git 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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420309 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/pbx.c b/main/pbx.c index 2dda2003d2..785175fc4b 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -11980,6 +11980,7 @@ static int action_extensionstatelist(struct mansession *s, const struct message 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 @@ static int action_extensionstatelist(struct mansession *s, const struct message 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 @@ static int action_extensionstatelist(struct mansession *s, const struct message 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);