[asterisk-commits] russell: branch 1.4 r85720 - /branches/1.4/apps/app_queue.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 15 16:10:03 CDT 2007


Author: russell
Date: Mon Oct 15 16:10:02 2007
New Revision: 85720

URL: http://svn.digium.com/view/asterisk?view=rev&rev=85720
Log:
Ensure that no pending state changes are leaked when the device state change
thread gets stopped on module unload.

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=85720&r1=85719&r2=85720
==============================================================================
--- branches/1.4/apps/app_queue.c (original)
+++ branches/1.4/apps/app_queue.c Mon Oct 15 16:10:02 2007
@@ -638,7 +638,7 @@
 
 static void *device_state_thread(void *data)
 {
-	struct statechange *sc;
+	struct statechange *sc = NULL;
 
 	while (!device_state.stop) {
 		ast_mutex_lock(&device_state.lock);
@@ -650,7 +650,7 @@
 
 		/* Check to see if we were woken up to see the request to stop */
 		if (device_state.stop)
-			return NULL;
+			break;
 
 		if (!sc)
 			continue;
@@ -658,7 +658,14 @@
 		handle_statechange(sc);
 
 		free(sc);
-	}
+		sc = NULL;
+	}
+
+	if (sc)
+		free(sc);
+
+	while ((sc = AST_LIST_REMOVE_HEAD(&device_state.state_change_q, entry)))
+		free(sc);
 
 	return NULL;
 }




More information about the asterisk-commits mailing list