diff options
author | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-09-29 20:24:33 +0000 |
---|---|---|
committer | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-09-29 20:24:33 +0000 |
commit | 8b4a5ec87eb47d19f46b540ba0a462afc4e84d55 (patch) | |
tree | 077a530c4ce7e52534baa7940f2b94034c740b70 /apps | |
parent | af9648f3418eb0c071858b066654faaa15aef4d7 (diff) |
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: http://svn.digium.com/svn/asterisk/branches/1.6.2@220934 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_chanspy.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c index 8ede9c83b..09f9fdd4b 100644 --- a/apps/app_chanspy.c +++ b/apps/app_chanspy.c @@ -454,9 +454,10 @@ static int channel_spy(struct ast_channel *chan, struct chanspy_ds *spyee_chansp ast_channel_unlock(chan); ast_mutex_lock(&spyee_chanspy_ds->lock); - if (spyee_chanspy_ds->chan) { - spyee = spyee_chanspy_ds->chan; - ast_channel_lock(spyee); + while ((spyee = spyee_chanspy_ds->chan) && ast_channel_trylock(spyee)) { + /* avoid a deadlock here, just in case spyee is masqueraded and + * chanspy_ds_chan_fixup() is called with the channel locked */ + DEADLOCK_AVOIDANCE(&spyee_chanspy_ds->lock); } ast_mutex_unlock(&spyee_chanspy_ds->lock); |