From: Luigi Rizzo Date: Fri, 21 Apr 2006 11:30:02 +0000 (+0000) Subject: one more client for find_context_locked() X-Git-Tag: 1.4.0-beta1~1842 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eb6dca850d420cebcaa8b014b327251c501a4ada;p=thirdparty%2Fasterisk.git one more client for find_context_locked() git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@21851 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/pbx.c b/pbx.c index 4a44e3e82e..a20dd5a4a2 100644 --- a/pbx.c +++ b/pbx.c @@ -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; } /*