aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-08-07 20:11:31 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-08-07 20:11:31 +0000
commit55edcb1cba5372c881cd8c17de3e7f8b7f550b0d (patch)
treecb96d260a819e3a0f5b93b9d4d2df908e9c9b104 /apps
parent0a9056ed19f6149addca7325e2d5d23caed1ae53 (diff)
Resolve a deadlock involving app_chanspy and masquerades.
(ABE-1936) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@211112 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_chanspy.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 8ccfd1a0e..91b28137f 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -422,17 +422,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 */
@@ -441,6 +444,7 @@ static struct chanspy_ds *chanspy_ds_free(struct chanspy_ds *chanspy_ds)
ast_channel_datastore_free(datastore);
}
ast_channel_unlock(chan);
+ break;
}
ast_mutex_unlock(&chanspy_ds->lock);