diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-21 11:30:02 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-21 11:30:02 +0000 |
commit | 78de33e15bb3682f17b108d50d1c658229f94785 (patch) | |
tree | 13ea2c2d88b55a420c3ce447367e89d5970cb7e9 /pbx.c | |
parent | ee681121340af8879819035ececf3e53426f919f (diff) |
one more client for find_context_locked()
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@21851 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx.c')
-rw-r--r-- | pbx.c | 26 |
1 files changed, 6 insertions, 20 deletions
@@ -3903,28 +3903,14 @@ int ast_context_add_include2(struct ast_context *con, const char *value, */ int ast_context_add_switch(const char *context, const char *sw, const char *data, int eval, const char *registrar) { - struct ast_context *c = NULL; - - if (ast_lock_contexts()) { - errno = EBUSY; - return -1; - } + int ret = -1; + struct ast_context *c = find_context_locked(context); - /* walk contexts ... */ - while ( (c = ast_walk_contexts(c)) ) { - /* ... search for the right one ... */ - if (!strcmp(ast_get_context_name(c), context)) { - int ret = ast_context_add_switch2(c, sw, data, eval, registrar); - /* ... unlock contexts list and return */ - ast_unlock_contexts(); - return ret; - } + if (c) { /* found, add switch to this context */ + ret = ast_context_add_switch2(c, sw, data, eval, registrar); + ast_unlock_contexts(); } - - /* we can't find the right context */ - ast_unlock_contexts(); - errno = ENOENT; - return -1; + return ret; } /* |