]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
According to comments in main/pbx.c, it is essential that if we are going to lock
authorMark Michelson <mmichelson@digium.com>
Tue, 20 Nov 2007 17:50:31 +0000 (17:50 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 20 Nov 2007 17:50:31 +0000 (17:50 +0000)
the conlock as well as the hints lock, it must be locked in that respective order.
In order to prevent a potential deadlock, we need to lock the conlock prior to
locking the hints lock in ast_hint_state_changed (see the call stack example on
issue #11323 for how this can happen).

(closes issue #11323, reported  by eelcob, suggestion for patch by eelcob, patch by me)

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

main/pbx.c

index d50a0ddcf5befa382dba67909773be286f2d031b..4df500921b393e8cb2f10b9f0ead902929d7f7f5 100644 (file)
@@ -2002,6 +2002,7 @@ void ast_hint_state_changed(const char *device)
 {
        struct ast_hint *hint;
 
+       ast_mutex_lock(&conlock);
        AST_LIST_LOCK(&hints);
 
        AST_LIST_TRAVERSE(&hints, hint, list) {
@@ -2039,6 +2040,7 @@ void ast_hint_state_changed(const char *device)
        }
 
        AST_LIST_UNLOCK(&hints);
+       ast_mutex_unlock(&conlock);
 }
 
 /*! \brief  ast_extension_state_add: Add watcher for extension states */