Lock while installign generator
authorMark Spencer <markster@digium.com>
Wed, 2 Jun 2004 20:18:18 +0000 (20:18 +0000)
committerMark Spencer <markster@digium.com>
Wed, 2 Jun 2004 20:18:18 +0000 (20:18 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3133 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channel.c

index 298f0e9..f31c012 100755 (executable)
--- 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)