aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authormnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-09-29 20:14:29 +0000
committermnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-09-29 20:14:29 +0000
commitec161909b6471d89ba0301ba2a67cac094eee718 (patch)
tree0b274f2d84f1ed183b97f8b551ab3fb41b65d594 /apps
parent1b9a8db07ee7c4d4c95ba68ae1c09b04ff8c258e (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.4@220907 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_chanspy.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 45a90ff6d..14ff92be5 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -250,9 +250,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);