Avoid a deadlock in chanspy, just in case the spyee is masqueraded and chanspy_ds_chan_fixup() is called with the channel locked.

(closes issue #15965)
Reported by: atis
Patches:
      chanspy-deadlock-fix1.diff uploaded by mnicholson (license 96)
Tested by: atis


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@220940 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Matthew Nicholson
2009-09-29 20:25:43 +00:00
parent 71b9410fbf
commit dfcc688a9c

View File

@@ -271,9 +271,10 @@ static int channel_spy(struct ast_channel *chan, struct chanspy_ds *spyee_chansp
ast_channel_unlock(chan); ast_channel_unlock(chan);
ast_mutex_lock(&spyee_chanspy_ds->lock); ast_mutex_lock(&spyee_chanspy_ds->lock);
if (spyee_chanspy_ds->chan) { while ((spyee = spyee_chanspy_ds->chan) && ast_channel_trylock(spyee)) {
spyee = spyee_chanspy_ds->chan; /* avoid a deadlock here, just in case spyee is masqueraded and
ast_channel_lock(spyee); * chanspy_ds_chan_fixup() is called with the channel locked */
DEADLOCK_AVOIDANCE(&spyee_chanspy_ds->lock);
} }
ast_mutex_unlock(&spyee_chanspy_ds->lock); ast_mutex_unlock(&spyee_chanspy_ds->lock);