aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authormnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-09-29 20:25:14 +0000
committermnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-09-29 20:25:14 +0000
commitd495b9a3109274dab4724433998acbe9d88d8df8 (patch)
treeebbfe9fd5bee206c9acf0d585d83ea9b30e63447 /apps
parent8fa541517f11b9497ee4559de8c24dd1ca7a7d63 (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.1@220938 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 7317e3578..0932a842d 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -337,9 +337,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);