diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-02 15:46:49 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-02 15:46:49 +0000 |
commit | 597a4c356a13203e414d28ab3fd4c6a0fbee83b7 (patch) | |
tree | ce6c880e9440afc42ab8dbcb90ffdc01f218c78a /channels/chan_local.c | |
parent | d072cb63676d904ea68650c63346c806fb488186 (diff) |
Update the device state functionality of chan_local such that it will return
NOT_INUSE or INUSE when Local channels are in use as opposed to just UNKNOWN.
It will still return INVALID if the extension doesn't exist at all.
(issue #8048, patch from tim_ringenbach)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@62673 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_local.c')
-rw-r--r-- | channels/chan_local.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c index 15a38a693..4b3484b4b 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -129,6 +129,7 @@ static int local_devicestate(void *data) char *exten = ast_strdupa(data); char *context = NULL, *opts = NULL; int res; + struct local_pvt *lp; if (!(context = strchr(exten, '@'))) { ast_log(LOG_WARNING, "Someone used Local/%s somewhere without a @context. This is bad.\n", exten); @@ -143,11 +144,22 @@ static int local_devicestate(void *data) if (option_debug > 2) ast_log(LOG_DEBUG, "Checking if extension %s@%s exists (devicestate)\n", exten, context); + res = ast_exists_extension(NULL, context, exten, 1, NULL); if (!res) return AST_DEVICE_INVALID; - else - return AST_DEVICE_UNKNOWN; + + res = AST_DEVICE_NOT_INUSE; + AST_LIST_LOCK(&locals); + AST_LIST_TRAVERSE(&locals, lp, list) { + if (!strcmp(exten, lp->exten) && !strcmp(context, lp->context) && lp->owner) { + res = AST_DEVICE_INUSE; + break; + } + } + AST_LIST_UNLOCK(&locals); + + return res; } static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us) |