[asterisk-commits] murf: branch murf/bug6002 r105004 - in /team/murf/bug6002: main/ pbx/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 28 12:43:09 CST 2008


Author: murf
Date: Thu Feb 28 12:43:08 2008
New Revision: 105004

URL: http://svn.digium.com/view/asterisk?view=rev&rev=105004
Log:
There, got the context_destroy routine to comply with the new set of rules. Looks like both ael and pbx_config follow the rules...

Modified:
    team/murf/bug6002/main/pbx.c
    team/murf/bug6002/pbx/pbx_ael.c

Modified: team/murf/bug6002/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug6002/main/pbx.c?view=diff&rev=105004&r1=105003&r2=105004
==============================================================================
--- team/murf/bug6002/main/pbx.c (original)
+++ team/murf/bug6002/main/pbx.c Thu Feb 28 12:43:08 2008
@@ -6795,31 +6795,67 @@
 void __ast_context_destroy(struct ast_context *con, const char *registrar)
 {
 	struct ast_context *tmp, *tmpl=NULL;
+	struct ast_exten *exten_item, *prio_item;
+
 
 	for (tmp = contexts; tmp; ) {
 		struct ast_context *next;	/* next starting point */
 		for (; tmp; tmpl = tmp, tmp = tmp->next) {
 			ast_debug(1, "check ctx %s %s\n", tmp->name, tmp->registrar);
-			if ( (!registrar || !strcasecmp(registrar, tmp->registrar)) &&
-			     (!con || !strcasecmp(tmp->name, con->name)) )
+			if ( registrar || (con && strcasecmp(tmp->name, con->name)) )
 				break;	/* found it */
 		}
 		if (!tmp)	/* not found, we are done */
 			break;
 		ast_wrlock_context(tmp);
-		ast_debug(1, "delete ctx %s %s\n", tmp->name, tmp->registrar);
-		ast_hashtab_remove_this_object(contexts_table, tmp);
-		
-		next = tmp->next;
-		if (tmpl)
-			tmpl->next = next;
-		else
-			contexts = next;
-		/* Okay, now we're safe to let it go -- in a sense, we were
-		   ready to let it go as soon as we locked it. */
-		ast_unlock_context(tmp);
-
-		__ast_internal_context_destroy(tmp);
+
+		if (registrar) {
+			/* then search thru and remove any extens that match registrar. */
+			struct ast_hashtab_iter *exten_iter;
+			struct ast_hashtab_iter *prio_iter;
+
+			exten_iter = ast_hashtab_start_traversal(tmp->root_table);
+			while ((exten_item=ast_hashtab_next(exten_iter))) {
+				prio_iter = ast_hashtab_start_traversal(exten_item->peer_table);
+				while ((prio_item=ast_hashtab_next(prio_iter))) {
+					if (strcmp(prio_item->registrar,registrar) != 0) {
+						continue;
+					}
+					ast_context_remove_extension2(tmp, prio_item->exten, prio_item->priority, registrar);
+				}
+				ast_hashtab_end_traversal(prio_iter);
+			}
+			ast_hashtab_end_traversal(exten_iter);
+	
+			/* delete the context if it's registrar matches, is empty, has refcount of 1, */
+			if (strcmp(tmp->registrar, registrar) == 0 && tmp->refcount < 2 && !tmp->root) {
+				ast_debug(1, "delete ctx %s %s\n", tmp->name, tmp->registrar);
+				ast_hashtab_remove_this_object(contexts_table, tmp);
+				
+				next = tmp->next;
+				if (tmpl)
+					tmpl->next = next;
+				else
+					contexts = next;
+				/* Okay, now we're safe to let it go -- in a sense, we were
+				   ready to let it go as soon as we locked it. */
+				ast_unlock_context(tmp);
+				__ast_internal_context_destroy(tmp);
+			}
+		} else if (con) {
+			ast_debug(1, "delete ctx %s %s\n", tmp->name, tmp->registrar);
+			ast_hashtab_remove_this_object(contexts_table, tmp);
+			
+			next = tmp->next;
+			if (tmpl)
+				tmpl->next = next;
+			else
+				contexts = next;
+			/* Okay, now we're safe to let it go -- in a sense, we were
+			   ready to let it go as soon as we locked it. */
+			ast_unlock_context(tmp);
+			__ast_internal_context_destroy(tmp);
+		}
 
 		/* if we have a specific match, we are done, otherwise continue */
 		tmp = con ? NULL : next;

Modified: team/murf/bug6002/pbx/pbx_ael.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug6002/pbx/pbx_ael.c?view=diff&rev=105004&r1=105003&r2=105004
==============================================================================
--- team/murf/bug6002/pbx/pbx_ael.c (original)
+++ team/murf/bug6002/pbx/pbx_ael.c Thu Feb 28 12:43:08 2008
@@ -135,6 +135,7 @@
 		ast_log(LOG_NOTICE, "AEL load process: compiled config file name '%s'.\n", rfilename);
 		
 		ast_merge_contexts_and_delete(&local_contexts, local_table, registrar);
+		local_table = NULL; /* it's the dialplan global now */
 		ast_log(LOG_NOTICE, "AEL load process: merged config file name '%s'.\n", rfilename);
 		for (con = ast_walk_contexts(NULL); con; con = ast_walk_contexts(con))
 			ast_context_verify_includes(con);




More information about the asterisk-commits mailing list