aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-16 22:32:33 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-16 22:32:33 +0000
commit0c821fa882c8cb4e56bfd4c52758974fff3a4fdc (patch)
tree51b9c35762b9c956a51ec98bf0f578d4593091ae /res/res_musiconhold.c
parent1e0bf93c56d1d0eef58ca11b67948c0a787c0665 (diff)
Fix a little race condition that could cause a crash if two channels had MOH
stopped at the same time that were using a class that had been marked for deletion when its use count hits zero. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@79792 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index d1aa725c2..08dda0c5f 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -202,8 +202,6 @@ static void moh_files_release(struct ast_channel *chan, void *data)
{
struct moh_files_state *state = chan->music_state;
- ast_atomic_fetchadd_int(&state->class->inuse, -1);
-
if (chan && state) {
if (chan->stream) {
ast_closestream(chan->stream);
@@ -217,7 +215,7 @@ static void moh_files_release(struct ast_channel *chan, void *data)
}
state->save_pos = state->pos;
}
- if (state->class->delete && !state->class->inuse)
+ if (state->class->delete && ast_atomic_dec_and_test(&state->class->inuse))
ast_moh_destroy_one(state->class);
}