From: Mark Michelson Date: Mon, 19 Jan 2015 18:18:23 +0000 (+0000) Subject: Call extension state callbacks at hint creation. X-Git-Tag: certified/13.1-cert1-rc3~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0cc80d5134bea5ab1e2c789e0a05c330346396d;p=thirdparty%2Fasterisk.git Call extension state callbacks at hint creation. When a hint gets created, any subsequent device or presence state changes result in extension status events getting sent out to interested parties. However, at the time of hint creation, no such event gets sent out, so watchers of extension state are potentially left in the dark until the first state change after hint creation. Patch contributed by John Hardin (License #6512) ........ Merged revisions 430776 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/13.1@430782 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/pbx.c b/main/pbx.c index b605a91434..02188e608a 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -5829,6 +5829,24 @@ static int ast_add_hint(struct ast_exten *e) ast_get_context_name(ast_get_extension_context(e))); } + /* if not dynamic */ + if (!(strstr(e->app, "${") && e->exten[0] == '_')) { + struct ast_state_cb *state_cb; + struct ao2_iterator cb_iter; + + /* For general callbacks */ + cb_iter = ao2_iterator_init(statecbs, 0); + for (; (state_cb = ao2_iterator_next(&cb_iter)); ao2_ref(state_cb, -1)) { + execute_state_callback(state_cb->change_cb, + ast_get_context_name(ast_get_extension_context(e)), + ast_get_extension_name(e), + state_cb->data, + AST_HINT_UPDATE_DEVICE, + hint_new, + NULL); + } + ao2_iterator_destroy(&cb_iter); + } ao2_unlock(hints); ao2_ref(hint_new, -1);