diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-08-07 20:18:51 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-08-07 20:18:51 +0000 |
commit | 4bedaed2501743032586f8389594ade4c6ff7ecf (patch) | |
tree | eb3ea00624a77affe74cb4cabe039c15ca2a60d0 /apps/app_chanspy.c | |
parent | a1147fcf3ed0dcc7bd26eed8f472f890bb56433f (diff) |
Merged revisions 211113 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r211113 | russell | 2009-08-07 15:12:21 -0500 (Fri, 07 Aug 2009) | 11 lines
Recorded merge of revisions 211112 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r211112 | russell | 2009-08-07 15:11:31 -0500 (Fri, 07 Aug 2009) | 4 lines
Resolve a deadlock involving app_chanspy and masquerades.
(ABE-1936)
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@211122 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_chanspy.c')
-rw-r--r-- | apps/app_chanspy.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c index 0ea0c369b..b280da2d5 100644 --- a/apps/app_chanspy.c +++ b/apps/app_chanspy.c @@ -676,17 +676,20 @@ static const struct ast_datastore_info chanspy_ds_info = { static struct chanspy_ds *chanspy_ds_free(struct chanspy_ds *chanspy_ds) { - if (!chanspy_ds) + struct ast_channel *chan; + + if (!chanspy_ds) { return NULL; + } ast_mutex_lock(&chanspy_ds->lock); - if (chanspy_ds->chan) { + while ((chan = chanspy_ds->chan)) { struct ast_datastore *datastore; - struct ast_channel *chan; - - chan = chanspy_ds->chan; - ast_channel_lock(chan); + if (ast_channel_trylock(chan)) { + DEADLOCK_AVOIDANCE(&chanspy_ds->lock); + continue; + } if ((datastore = ast_channel_datastore_find(chan, &chanspy_ds_info, chanspy_ds->unique_id))) { ast_channel_datastore_remove(chan, datastore); /* chanspy_ds->chan is NULL after this call */ @@ -695,6 +698,7 @@ static struct chanspy_ds *chanspy_ds_free(struct chanspy_ds *chanspy_ds) ast_datastore_free(datastore); } ast_channel_unlock(chan); + break; } ast_mutex_unlock(&chanspy_ds->lock); |