]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix POTS flash hook to orignate a second call deadlock.
authorRichard Mudgett <rmudgett@digium.com>
Wed, 6 Jun 2012 21:27:33 +0000 (21:27 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 6 Jun 2012 21:27:33 +0000 (21:27 +0000)
A deadlock can occur when a POTS phone tries to flash hook to originate a
second call for 3-way or transfer.  If another process is scanning the
channels container when the POTS line flash hooks then a deadlock will
occur.

* Release the channel and private locks when creating a new channel as a
result of a flash hook.

(closes issue ASTERISK-19842)
Reported by: rmudgett
Tested by: rmudgett

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

channels/chan_dahdi.c
channels/sig_analog.c

index f3a293397ed800dfc59e396cab439d88fa5b7cb1..45ae9cdf91ad94e30b43af63b8f1ebf566865d85 100644 (file)
@@ -8518,8 +8518,18 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                                ast_log(LOG_WARNING, "Unable to allocate three-way subchannel\n");
                                                goto winkflashdone;
                                        }
-                                       /* Make new channel */
+
+                                       /*
+                                        * Make new channel
+                                        *
+                                        * We cannot hold the p or ast locks while creating a new
+                                        * channel.
+                                        */
+                                       ast_mutex_unlock(&p->lock);
+                                       ast_channel_unlock(ast);
                                        chan = dahdi_new(p, AST_STATE_RESERVED, 0, SUB_THREEWAY, 0, NULL);
+                                       ast_channel_lock(ast);
+                                       ast_mutex_lock(&p->lock);
                                        if (p->dahditrcallerid) {
                                                if (!p->origcid_num)
                                                        p->origcid_num = ast_strdup(p->cid_num);
index 72c5d238596fcfce869d35763484784827367255..56a9b2c19eebbaae08804b3931564c58e0404865 100644 (file)
@@ -535,23 +535,19 @@ static void analog_all_subchannels_hungup(struct analog_pvt *p)
        }
 }
 
-#if 0
 static void analog_unlock_private(struct analog_pvt *p)
 {
        if (p->calls->unlock_private) {
                p->calls->unlock_private(p->chan_pvt);
        }
 }
-#endif
 
-#if 0
 static void analog_lock_private(struct analog_pvt *p)
 {
        if (p->calls->lock_private) {
                p->calls->lock_private(p->chan_pvt);
        }
 }
-#endif
 
 /*!
  * \internal
@@ -3203,8 +3199,18 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                                ast_log(LOG_WARNING, "Unable to allocate three-way subchannel\n");
                                                goto winkflashdone;
                                        }
-                                       /* Make new channel */
+
+                                       /*
+                                        * Make new channel
+                                        *
+                                        * We cannot hold the p or ast locks while creating a new
+                                        * channel.
+                                        */
+                                       analog_unlock_private(p);
+                                       ast_channel_unlock(ast);
                                        chan = analog_new_ast_channel(p, AST_STATE_RESERVED, 0, ANALOG_SUB_THREEWAY, NULL);
+                                       ast_channel_lock(ast);
+                                       analog_lock_private(p);
                                        if (!chan) {
                                                ast_log(LOG_WARNING,
                                                        "Cannot allocate new call structure on channel %d\n",