]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 179462 via svnmerge from
authorRussell Bryant <russell@russellbryant.com>
Mon, 2 Mar 2009 23:04:18 +0000 (23:04 +0000)
committerRussell Bryant <russell@russellbryant.com>
Mon, 2 Mar 2009 23:04:18 +0000 (23:04 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

................
r179462 | russell | 2009-03-02 17:00:30 -0600 (Mon, 02 Mar 2009) | 16 lines

Merged revisions 179461 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r179461 | russell | 2009-03-02 16:58:18 -0600 (Mon, 02 Mar 2009) | 8 lines

Ensure that only one thread is calling ast_settimeout() on a channel at a time.

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.6.1@179464 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c

index b17bd6e29d0dbf714dcc8774b619b38a320c6a34..118fc5b447469129237971ae4fca2916035d6c4f 100644 (file)
@@ -2218,7 +2218,10 @@ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const v
        int res;
        unsigned int real_rate = rate, max_rate;
 
+       ast_channel_lock(c);
+
        if (c->timingfd == -1) {
+               ast_channel_unlock(c);
                return -1;
        }
 
@@ -2238,6 +2241,8 @@ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const v
        c->timingfunc = func;
        c->timingdata = data;
 
+       ast_channel_unlock(c);
+
        return res;
 }