Fix lock ordering in devicestate
authorMark Spencer <markster@digium.com>
Sun, 10 Jul 2005 12:09:40 +0000 (12:09 +0000)
committerMark Spencer <markster@digium.com>
Sun, 10 Jul 2005 12:09:40 +0000 (12:09 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6069 65c4cc65-6c06-0410-ace0-fbb531ad65f3

devicestate.c

index 4641f95..621e8f1 100755 (executable)
@@ -184,12 +184,14 @@ int ast_device_state_changed(const char *fmt, ...)
                AST_LIST_LOCK(&state_changes);
                AST_LIST_INSERT_TAIL(&state_changes, change, list);
                if (AST_LIST_FIRST(&state_changes) == change) {
+                       AST_LIST_UNLOCK(&state_changes);
                        /* the list was empty, signal the thread */
                        ast_mutex_lock(&change_pending_lock);
                        pthread_cond_signal(&change_pending);
                        ast_mutex_unlock(&change_pending_lock);
+               } else {
+                       AST_LIST_UNLOCK(&state_changes);
                }
-               AST_LIST_UNLOCK(&state_changes);
        }
 
        return 1;