[asterisk-commits] mmichelson: branch 1.4 r81158 - /branches/1.4/apps/app_queue.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 27 17:40:20 CDT 2007


Author: mmichelson
Date: Mon Aug 27 17:40:19 2007
New Revision: 81158

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81158
Log:
Resolve a potential deadlock. In this case, a single queue is locked, then the queue list. In changethread(), the queue list is
locked, and then each individual queue is locked. Under the right circumstances, this could deadlock. As such, I have unlocked
the individual queue before locking the queue list, and then locked the queue back after the queue list is unlocked.


Modified:
    branches/1.4/apps/app_queue.c

Modified: branches/1.4/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_queue.c?view=diff&rev=81158&r1=81157&r2=81158
==============================================================================
--- branches/1.4/apps/app_queue.c (original)
+++ branches/1.4/apps/app_queue.c Mon Aug 27 17:40:19 2007
@@ -1106,7 +1106,9 @@
 			} else {
 				q->members = next_m;
 			}
+			ast_mutex_unlock(&q->lock);
 			remove_from_interfaces(m->interface);
+			ast_mutex_lock(&q->lock);
 			q->membercount--;
 			free(m);
 		} else {
@@ -1160,7 +1162,9 @@
 			} else {
 				q->members = next_m;
 			}
+			ast_mutex_unlock(&q->lock);
 			remove_from_interfaces(m->interface);
+			ast_mutex_lock(&q->lock);
 			q->membercount--;
 			free(m);
 		} else {




More information about the asterisk-commits mailing list