Fix some timer state corruption.

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
This commit is contained in:
Russell Bryant 2009-05-11 22:04:40 +00:00
parent 52541f5aeb
commit 174697b7d1
1 changed files with 4 additions and 2 deletions

View 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);