]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Ensure that no pending state changes are leaked when the device state change
authorRussell Bryant <russell@russellbryant.com>
Mon, 15 Oct 2007 21:10:02 +0000 (21:10 +0000)
committerRussell Bryant <russell@russellbryant.com>
Mon, 15 Oct 2007 21:10:02 +0000 (21:10 +0000)
thread gets stopped on module unload.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@85720 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_queue.c

index cc4a5fa9188bc08f74a68117384118ee85c2e1bb..fbdab1babbc8f5b08ff8b58750f112ebfa115cd2 100644 (file)
@@ -638,7 +638,7 @@ static struct {
 
 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 @@ static void *device_state_thread(void *data)
 
                /* 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,8 +658,15 @@ static void *device_state_thread(void *data)
                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;
 }