[asterisk-commits] trunk r21851 - /trunk/pbx.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 21 04:30:04 MST 2006


Author: rizzo
Date: Fri Apr 21 06:30:02 2006
New Revision: 21851

URL: http://svn.digium.com/view/asterisk?rev=21851&view=rev
Log:
one more client for find_context_locked()


Modified:
    trunk/pbx.c

Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=21851&r1=21850&r2=21851&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Fri Apr 21 06:30:02 2006
@@ -3903,28 +3903,14 @@
  */
 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;
-	}
-
-	/* 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;
-		}
-	}
-
-	/* we can't find the right context */
-	ast_unlock_contexts();
-	errno = ENOENT;
-	return -1;
+	int ret = -1;
+	struct ast_context *c = find_context_locked(context);
+
+	if (c) { /* found, add switch to this context */
+		ret = ast_context_add_switch2(c, sw, data, eval, registrar);
+		ast_unlock_contexts();
+	}
+	return ret;
 }
 
 /*



More information about the asterisk-commits mailing list