Fix a logic error that occur when using the timerfd interface
authorMark Michelson <mmichelson@digium.com>
Fri, 16 Jan 2009 19:54:39 +0000 (19:54 +0000)
committerMark Michelson <mmichelson@digium.com>
Fri, 16 Jan 2009 19:54:39 +0000 (19:54 +0000)
commite2f49af37f6a23dc3edca17cf2f1f159f342e2e3
treefec185bbfd4539cb506f8447adb48a01ad4abff5
parent3728c3aa92134f384e7e8f4b50a41661d3cac12c
Fix a logic error that occur when using the timerfd interface

This sequence of events posed a problem

timerfd_timer_open
timerfd_timer_enable_continuous
timerfd_timer_set_rate
timerfd_timer_disable_continuous

The reason was that the timing module was written under the assumption
that timerfd_timer_set_rate would not be called between enabling and
disabling continuous mode. What happened in this situation was that
timerfd_timer_enable_continuous saved off our previously set timer (in this
situation a 0 timer, meaning it never runs out). Then timerfd_timer_disable_continuous
would restore this 0 timer, even though it logically should set the timer to be whatever
was set in timerfd_timer_set_rate.

Now the behavior in timerfd_timer_set_rate is to overwrite the saved timer that may
or may not have been set in timerfd_timer_enable_continuous. Even if
timerfd_timer_enable_continuous has not been previously called, this will not harm the
operation.

Thanks to Terry Wilson for discovering the problem and giving me a really great debug
capture that pointed out the problem clearly

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