[Asterisk-code-review] pbx: deadlock when outgoing dialed channel hangs up too quickly (...asterisk[16])

Kevin Harwell asteriskteam at digium.com
Wed Oct 9 16:06:30 CDT 2019


Kevin Harwell has uploaded a new patch set (#2). ( https://gerrit.asterisk.org/c/asterisk/+/13031 )

Change subject: pbx: deadlock when outgoing dialed channel hangs up too quickly
......................................................................

pbx: deadlock when outgoing dialed channel hangs up too quickly

Here's the basic scenario that occurred when executing an AMI fast originate
while at the same time something else locks the channels container, and also
wants a lock on the dialed channel:

1. pbx_outgoing_attempt obtains a lock on a dialed channel
2. concurrently another thread obtains a lock on the channels container, and
   subsequently requests a lock on the dialed channel. It waits on #1. For
   instance, "core show channel <dialed channel"
3. the outgoing call does not fail, but ends before the pbx_outgoing_attempt
   function exits
4. pbx_outgoing_attempt function exits, the outgoing structure destructs, and
   attempts to hang up the dialed channel
5. hang up tries to obtain the channels container lock, but can't due to #2.
6. Asterisk is deadlocked.

The solution was to allow the pbx_outgoing_exec function to "steal" ownership
of the dialed channel, and handle hanging it up. The channel now is either hung
up prior to it being potentially locked by the initiating thread, or if locked
the hang up takes place in a different thread, thus alleviating the deadlock.

ASTERISK-28561
patches:
  iliketrains.diff submitted by Joshua Colp (license 5000)

Change-Id: I51b42b92dde8f2215b69bb509e28667ee3a3853a
---
M main/pbx.c
1 file changed, 14 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/31/13031/2
-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13031
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I51b42b92dde8f2215b69bb509e28667ee3a3853a
Gerrit-Change-Number: 13031
Gerrit-PatchSet: 2
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-CC: Friendly Automation
Gerrit-MessageType: newpatchset
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191009/7382b274/attachment.html>


More information about the asterisk-code-review mailing list