]> git.ipfire.org Git - thirdparty/asterisk.git/commit
chan_sip: Fix early call pickup caused deadlock. 71/771/2
authorWalter Doekes <walter+asterisk@wjd.nu>
Thu, 2 Jul 2015 11:25:36 +0000 (13:25 +0200)
committerWalter Doekes <walter+asterisk@wjd.nu>
Thu, 2 Jul 2015 12:29:55 +0000 (07:29 -0500)
commit0e6d3f5ee5a617853d03621726c8207bde63a82d
tree9ed9b3845444820f1b28fc95879731241c1d40fa
parent9b74dcb687f4e05da012d80ee54d04df82210520
chan_sip: Fix early call pickup caused deadlock.

If non-magic pickup (no "pickup-" in callid) is used, chan_sip locks the
channel it wants to pick up, and a bit further down, it locks the
channel list when allocating a new channel.

That causes a deadlock when another part of the code traverses over the
channel list, locking all the channels one by one.

This changeset fixes it by releasing the locks before calling sip_new
and reacquiring them afterwards.  Unfortunately this involves doing the
checks we already did again (because the channel may have changed).

While trying to avoid duplicate code, I did some refactoring for
readability:
- if refer_locked == 1, we guarantee there is a locked channel
- magic_callid holds a cached version of !ast_strlen_zero(pickup.exten)

This is for branch 11 only. It appears that the changed code in 13 does
not lock the components like it does in 11 and below. Reproducing the
deadlock on 13 has thusfar failed.

ASTERISK-25213 #close

Change-Id: Ie1d15bec7d634035f48892e1ed6227411d7de2c1
channels/chan_sip.c