Fix some timer state corruption.
[asterisk/asterisk.git] / 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);