From e24788d06f906ff192855a0a4968373d0f8c6fbd Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 16 Aug 2007 22:32:33 +0000 Subject: [PATCH] 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: https://origsvn.digium.com/svn/asterisk/branches/1.4@79792 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_musiconhold.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index d1aa725c25..08dda0c5f4 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); } -- 2.47.3