[asterisk-commits] murf: branch 1.6.0 r123173 - in /branches/1.6.0: ./ apps/ include/asterisk/ m...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 16 16:19:24 CDT 2008


Author: murf
Date: Mon Jun 16 16:19:23 2008
New Revision: 123173

URL: http://svn.digium.com/view/asterisk?view=rev&rev=123173
Log:
Merged revisions 123165 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r123165 | murf | 2008-06-16 14:43:46 -0600 (Mon, 16 Jun 2008) | 19 lines

(closes issue #12689)
Reported by: ys

Many thanks to ys for doing the research on this problem.
I didn't think it would be best to unlock the contexts
and then relock them after the remove_extension2() call,
so I added an extra arg to remove_extension2() and set it
appropriately in each call. There were not that many.

I considered forcing the code to lock the contexts before
the call to remove_extension2(), but that would require
a slightly greater degree of changes, especially since
the find_context_locked is local to pbx.c

I did a simple sanity test to make sure the code doesn't
mess things up in general.



........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/apps/app_dial.c
    branches/1.6.0/apps/app_queue.c
    branches/1.6.0/apps/app_stack.c
    branches/1.6.0/include/asterisk/pbx.h
    branches/1.6.0/main/features.c
    branches/1.6.0/main/pbx.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_dial.c?view=diff&rev=123173&r1=123172&r2=123173
==============================================================================
--- branches/1.6.0/apps/app_dial.c (original)
+++ branches/1.6.0/apps/app_dial.c Mon Jun 16 16:19:23 2008
@@ -2070,7 +2070,7 @@
 	res |= ast_unregister_application(rapp);
 
 	if ((con = ast_context_find("app_dial_gosub_virtual_context"))) {
-		ast_context_remove_extension2(con, "s", 1, NULL);
+		ast_context_remove_extension2(con, "s", 1, NULL, 0);
 		ast_context_destroy(con, "app_dial"); /* leave nothing behind */
 	}
 

Modified: branches/1.6.0/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_queue.c?view=diff&rev=123173&r1=123172&r2=123173
==============================================================================
--- branches/1.6.0/apps/app_queue.c (original)
+++ branches/1.6.0/apps/app_queue.c Mon Jun 16 16:19:23 2008
@@ -6217,7 +6217,7 @@
 		ast_event_unsubscribe(device_state_sub);
 
 	if ((con = ast_context_find("app_queue_gosub_virtual_context"))) {
-		ast_context_remove_extension2(con, "s", 1, NULL);
+		ast_context_remove_extension2(con, "s", 1, NULL, 0);
 		ast_context_destroy(con, "app_queue"); /* leave no trace */
 	}
 

Modified: branches/1.6.0/apps/app_stack.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_stack.c?view=diff&rev=123173&r1=123172&r2=123173
==============================================================================
--- branches/1.6.0/apps/app_stack.c (original)
+++ branches/1.6.0/apps/app_stack.c Mon Jun 16 16:19:23 2008
@@ -493,7 +493,7 @@
 		ast_agi_unregister(ast_module_info->self, &gosub_agi_command);
 
 		if ((con = ast_context_find("app_stack_gosub_virtual_context"))) {
-			ast_context_remove_extension2(con, "s", 1, NULL);
+			ast_context_remove_extension2(con, "s", 1, NULL, 0);
 			ast_context_destroy(con, "app_stack"); /* leave nothing behind */
 		}
 	}

Modified: branches/1.6.0/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/include/asterisk/pbx.h?view=diff&rev=123173&r1=123172&r2=123173
==============================================================================
--- branches/1.6.0/include/asterisk/pbx.h (original)
+++ branches/1.6.0/include/asterisk/pbx.h Mon Jun 16 16:19:23 2008
@@ -607,7 +607,7 @@
 	const char *registrar);
 
 int ast_context_remove_extension2(struct ast_context *con, const char *extension,
-	int priority, const char *registrar);
+	int priority, const char *registrar, int already_locked);
 
 /*! 
  * \brief Add an ignorepat

Modified: branches/1.6.0/main/features.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/features.c?view=diff&rev=123173&r1=123172&r2=123173
==============================================================================
--- branches/1.6.0/main/features.c (original)
+++ branches/1.6.0/main/features.c Mon Jun 16 16:19:23 2008
@@ -2312,7 +2312,7 @@
 				AST_LIST_REMOVE_CURRENT(list);
 				con = ast_context_find(parking_con);
 				if (con) {
-					if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
+					if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL, 0))
 						ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
 					else
 						notify_metermaids(pu->parkingexten, parking_con, AST_DEVICE_NOT_INUSE);
@@ -2346,7 +2346,7 @@
 						AST_LIST_REMOVE_CURRENT(list);
 						con = ast_context_find(parking_con);
 						if (con) {
-							if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
+							if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL, 0))
 								ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
 							else
 								notify_metermaids(pu->parkingexten, parking_con, AST_DEVICE_NOT_INUSE);
@@ -2465,7 +2465,7 @@
 		peer = pu->chan;
 		con = ast_context_find(parking_con);
 		if (con) {
-			if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
+			if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL, 0))
 				ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
 			else
 				notify_metermaids(pu->parkingexten, parking_con, AST_DEVICE_NOT_INUSE);
@@ -2850,7 +2850,7 @@
 
 	/* Remove the old parking extension */
 	if (!ast_strlen_zero(old_parking_con) && (con = ast_context_find(old_parking_con)))	{
-		if(ast_context_remove_extension2(con, old_parking_ext, 1, registrar))
+		if(ast_context_remove_extension2(con, old_parking_ext, 1, registrar, 0))
 				notify_metermaids(old_parking_ext, old_parking_con, AST_DEVICE_NOT_INUSE);
 		ast_debug(1, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
 	}

Modified: branches/1.6.0/main/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/pbx.c?view=diff&rev=123173&r1=123172&r2=123173
==============================================================================
--- branches/1.6.0/main/pbx.c (original)
+++ branches/1.6.0/main/pbx.c Mon Jun 16 16:19:23 2008
@@ -3979,7 +3979,7 @@
 	struct ast_context *c = find_context_locked(context);
 
 	if (c) { /* ... remove extension ... */
-		ret = ast_context_remove_extension2(c, extension, priority, registrar);
+		ret = ast_context_remove_extension2(c, extension, priority, registrar, 1);
 		ast_unlock_contexts();
 	}
 	return ret;
@@ -3995,14 +3995,15 @@
  * it.
  *
  */
-int ast_context_remove_extension2(struct ast_context *con, const char *extension, int priority, const char *registrar)
+int ast_context_remove_extension2(struct ast_context *con, const char *extension, int priority, const char *registrar, int already_locked)
 {
 	struct ast_exten *exten, *prev_exten = NULL;
 	struct ast_exten *peer;
 	struct ast_exten ex, *exten2, *exten3;
 	char dummy_name[1024];
 
-	ast_wrlock_context(con);
+	if (!already_locked)
+		ast_wrlock_context(con);
 
 	/* Handle this is in the new world */
 
@@ -4085,7 +4086,8 @@
 	}
 	if (!exten) {
 		/* we can't find right extension */
-		ast_unlock_context(con);
+		if (!already_locked)
+			ast_unlock_context(con);
 		return -1;
 	}
 
@@ -4112,7 +4114,8 @@
 				break; /* found our priority */
 		}
 		if (!peer) { /* not found */
-			ast_unlock_context(con);
+			if (!already_locked)
+				ast_unlock_context(con);
 			return -1;
 		}
 		/* we are first priority extension? */
@@ -4145,7 +4148,8 @@
 		destroy_exten(peer);
 		/* XXX should we return -1 ? */
 	}
-	ast_unlock_context(con);
+	if (!already_locked)
+		ast_unlock_context(con);
 	return 0;
 }
 




More information about the asterisk-commits mailing list