From 87641bf1fe486e9d01ed9ddfc64ce9f35c8e5385 Mon Sep 17 00:00:00 2001 From: markster Date: Wed, 2 Jun 2004 20:18:18 +0000 Subject: Lock while installign generator git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3133 f38db490-d61c-443f-a65b-d21fe96a405b --- channel.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'channel.c') diff --git a/channel.c b/channel.c index 298f0e961..f31c01229 100755 --- a/channel.c +++ b/channel.c @@ -786,6 +786,8 @@ void ast_deactivate_generator(struct ast_channel *chan) int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params) { + int res = 0; + ast_mutex_lock(&chan->lock); if (chan->generatordata) { if (chan->generator && chan->generator->release) chan->generator->release(chan, chan->generatordata); @@ -795,9 +797,10 @@ int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, if ((chan->generatordata = gen->alloc(chan, params))) { chan->generator = gen; } else { - return -1; + res = -1; } - return 0; + ast_mutex_unlock(&chan->lock); + return res; } int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception) -- cgit v1.2.3