Fix some timer state corruption.
authorRussell Bryant <russell@russellbryant.com>
Mon, 11 May 2009 22:04:40 +0000 (22:04 +0000)
committerRussell Bryant <russell@russellbryant.com>
Mon, 11 May 2009 22:04:40 +0000 (22:04 +0000)
In res_timer_timerfd, handle the case that set_rate gets called while a timer
is still in continuous mode.  In this case, we want to remember the configured
rate, but not actually set it until continuous mode has been disabled.

Thanks to dvossel for finding and helping to debug the problem.

(closes issue #15080)
Reported by: dvossel
Tested by: dvossel

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

res/res_timing_timerfd.c

index 9688758..fb35ffb 100644 (file)
@@ -134,7 +134,7 @@ static int timerfd_timer_set_rate(int handle, unsigned int rate)
        struct timerfd_timer *our_timer, find_helper = {
                .handle = handle,
        };
-       int res;
+       int res = 0;
 
        if (!(our_timer = ao2_find(timerfd_timers, &find_helper, OBJ_POINTER))) {
                ast_log(LOG_ERROR, "Couldn't find timer with handle %d\n", handle);
@@ -146,7 +146,9 @@ static int timerfd_timer_set_rate(int handle, unsigned int rate)
        our_timer->saved_timer.it_interval.tv_sec = our_timer->saved_timer.it_value.tv_sec;
        our_timer->saved_timer.it_interval.tv_nsec = our_timer->saved_timer.it_value.tv_nsec;
 
-       res = timerfd_settime(handle, 0, &our_timer->saved_timer, NULL);
+       if (!our_timer->is_continuous) {
+               res = timerfd_settime(handle, 0, &our_timer->saved_timer, NULL);
+       }
 
        ao2_ref(our_timer, -1);