diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-07-05 14:21:44 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-07-05 14:21:44 +0000 |
commit | 65c550e0f24985527456d6253a77386cebc0e9aa (patch) | |
tree | e190947852de1c0b225adf1f2ff362925fd51d30 /main | |
parent | c4080c36c5faa5a6a329d46e9d89771e3953c811 (diff) |
Merged revisions 73349 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r73349 | file | 2007-07-05 11:19:14 -0300 (Thu, 05 Jul 2007) | 2 lines
Tweak spy locking. (issue #9951 reported by welles)
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@73355 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/channel.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/main/channel.c b/main/channel.c index 6e7b3f5b5..37fd2b45d 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1432,24 +1432,22 @@ static void spy_cleanup(struct ast_channel *chan) /* Detach a spy from it's channel */ static void spy_detach(struct ast_channel_spy *spy, struct ast_channel *chan) { - ast_mutex_lock(&spy->lock); - /* We only need to poke them if they aren't already done */ if (spy->status != CHANSPY_DONE) { + ast_mutex_lock(&spy->lock); /* Indicate to the spy to stop */ spy->status = CHANSPY_STOP; spy->chan = NULL; /* Poke the spy if needed */ if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE) ast_cond_signal(&spy->trigger); + ast_mutex_unlock(&spy->lock); } /* Print it out while we still have a lock so the structure can't go away (if signalled above) */ if (option_debug) ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name); - ast_mutex_unlock(&spy->lock); - return; } @@ -1461,13 +1459,10 @@ void ast_channel_spy_stop_by_type(struct ast_channel *chan, const char *type) return; AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->spies->list, spy, list) { - ast_mutex_lock(&spy->lock); if ((spy->type == type) && (spy->status == CHANSPY_RUNNING)) { - ast_mutex_unlock(&spy->lock); AST_LIST_REMOVE_CURRENT(&chan->spies->list, list); spy_detach(spy, chan); - } else - ast_mutex_unlock(&spy->lock); + } } AST_LIST_TRAVERSE_SAFE_END spy_cleanup(chan); @@ -1580,6 +1575,9 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f, struct ast_channel_spy_queue *queue; struct ast_frame *duped_fr; + if (spy->status != CHANSPY_RUNNING) + continue; + ast_mutex_lock(&spy->lock); queue = (dir == SPY_READ) ? &spy->read_queue : &spy->write_queue; |