[asterisk-commits] mmichelson: trunk r103121 - in /trunk: ./ apps/app_queue.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 8 12:54:54 CST 2008


Author: mmichelson
Date: Fri Feb  8 12:54:53 2008
New Revision: 103121

URL: http://svn.digium.com/view/asterisk?view=rev&rev=103121
Log:
Merged revisions 103120 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r103120 | mmichelson | 2008-02-08 12:48:17 -0600 (Fri, 08 Feb 2008) | 10 lines

Prevent a potential three-thread deadlock. Also added a comment block
to explicitly state the locking order necessary inside app_queue.

(closes issue #11862)
Reported by: flujan
Patches:
      11862.patch uploaded by putnopvut (license 60)
	  Tested by: flujan


........

Modified:
    trunk/   (props changed)
    trunk/apps/app_queue.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?view=diff&rev=103121&r1=103120&r2=103121
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Fri Feb  8 12:54:53 2008
@@ -92,6 +92,20 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/strings.h"
 #include "asterisk/global_datastores.h"
+
+/* Please read before modifying this file.
+ * There are three locks which are regularly used
+ * throughout this file, the queue list lock, the lock
+ * for each individual queue, and the interface list lock.
+ * Please be extra careful to always lock in the following order
+ * 1) queue list lock
+ * 2) individual queue lock
+ * 3) interface list lock
+ * This order has sort of "evolved" over the lifetime of this
+ * application, but it is now in place this way, so please adhere
+ * to this order!
+ */
+
 
 enum {
 	QUEUE_STRATEGY_RINGALL = 0,
@@ -1007,14 +1021,15 @@
 {
 	struct member_interface *curint;
 
+	if (interface_exists_global(interface))
+		return 0;
+
 	AST_LIST_LOCK(&interfaces);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) {
 		if (!strcasecmp(curint->interface, interface)) {
-			if (!interface_exists_global(interface)) {
-				ast_debug(1, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
-				AST_LIST_REMOVE_CURRENT(list);
-				ast_free(curint);
-			} 
+			ast_debug(1, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
+			AST_LIST_REMOVE_CURRENT(&interfaces, list);
+			ast_free(curint);
 			break;
 		}
 	}




More information about the asterisk-commits mailing list