]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Ensure that only one thread is calling ast_settimeout() on a channel at a time.
authorRussell Bryant <russell@russellbryant.com>
Mon, 2 Mar 2009 22:58:18 +0000 (22:58 +0000)
committerRussell Bryant <russell@russellbryant.com>
Mon, 2 Mar 2009 22:58:18 +0000 (22:58 +0000)
For example, with an IAX2 channel, you can have both the channel thread and the
chan_iax2 processing threads calling this function, and doing so twice at the
same time is a bad thing.

(Found in a debugging session with dvossel and mmichelson)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@179461 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c

index 25d45ec0d9907fc1ddaeca81692b2f86b12ac59a..33f7558f78e145996f12d6e57d7b1b7b7415b988 100644 (file)
@@ -1839,6 +1839,7 @@ int ast_settimeout(struct ast_channel *c, int samples, int (*func)(const void *d
 {
        int res = -1;
 #ifdef HAVE_DAHDI
+       ast_channel_lock(c);
        if (c->timingfd > -1) {
                if (!func) {
                        samples = 0;
@@ -1850,6 +1851,7 @@ int ast_settimeout(struct ast_channel *c, int samples, int (*func)(const void *d
                c->timingfunc = func;
                c->timingdata = data;
        }
+       ast_channel_unlock(c);
 #endif 
        return res;
 }