]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
The channel needs to stay locked while running timer callbacks, as they access
authorRussell Bryant <russell@russellbryant.com>
Thu, 18 Oct 2007 18:03:10 +0000 (18:03 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 18 Oct 2007 18:03:10 +0000 (18:03 +0000)
and modify channel data that may change elsewhere.  I went through every timer
callback in the source tree to make sure that none of them did any additional
locking that could introduce deadlocks, and all is well.

(closes issue #10765)
Reported by: Ivan
Patches:
      ast_1_4_11_svn_patch_channel_rc.diff uploaded by Ivan (license 229)

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

include/asterisk/channel.h
main/channel.c

index 8f23fea11fc3ea71fded2cd5e85c045fffd5e054..5a704199e338aff3bfe8bea5199c678f8e055240 100644 (file)
@@ -141,6 +141,7 @@ typedef unsigned long long ast_group_t;
 struct ast_generator {
        void *(*alloc)(struct ast_channel *chan, void *params);
        void (*release)(struct ast_channel *chan, void *data);
+       /*! This function gets called with the channel locked */
        int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
 };
 
index 81fec223cb43c7fc228ae8c275070664932d6a2c..d21310c795351a9b06b676ae8ee4e12a5f32e728 100644 (file)
@@ -2270,17 +2270,13 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                } else if (blah == ZT_EVENT_TIMER_EXPIRED) {
                        ioctl(chan->timingfd, ZT_TIMERACK, &blah);
                        if (chan->timingfunc) {
-                               /* save a copy of func/data before unlocking the channel */
-                               int (*func)(const void *) = chan->timingfunc;
-                               void *data = chan->timingdata;
-                               ast_channel_unlock(chan);
-                               func(data);
+                               chan->timingfunc(chan->timingdata);
                        } else {
                                blah = 0;
                                ioctl(chan->timingfd, ZT_TIMERCONFIG, &blah);
                                chan->timingdata = NULL;
-                               ast_channel_unlock(chan);
                        }
+                       ast_channel_unlock(chan);
                        /* cannot 'goto done' because the channel is already unlocked */
                        return &ast_null_frame;
                } else