Does it make sense to change boost::asio::deadline_timer to steady_timer?
Hi all,
We can see lots of using boost::asio::deadline_timer in the code, like dbus-sensors. However, this timer is based on UTC clock and might be affected by system time. I tested and found the timer didn't trigger in time if I changed system time to some early time after starting the timer (calling expire_from_now()). And I think this situation might happen if system time of BMC is synchronized with host or NTP.
At the other hand, steady_timer is a chrono timer and should not be affected by system time.
Is there any reason to use deadline_timer for relative timer trigger? Shall we switch to steady_timer to avoid being affected by system time change?
Thanks,
Heyi
Quoted 10 lines · Heyi Guo
Hi all,
We can see lots of using
boost::asio::deadline_timerin the code, like dbus-sensors. However, this timer is based on UTC clock and might be affected by system time. I tested and found the timer didn't trigger in time if I changed system time to some early time after starting the timer (callingexpire_from_now()). And I think this situation might happen if system time of BMC is synchronized with host or NTP.
Quoted 6 lines
At the other hand,
steady_timeris a chrono timer and should not be affected by system time.Is there any reason to use
deadline_timerfor relative timer trigger? Shall we switch tosteady_timerto avoid being affected by system time change?
Yes, these should be steady_timer. For some reason I thought we fixed this a long time ago in dbus-sensors, but apparently not. Please send the other maintainers and I a patch in gerrit (should be just a sed replace of all deadline_timer instances) and I'll review it.
Quoted 5 lines
Thanks,
Heyi
Quoted 13 lines · Ed Tanous
Quoted 12 lines · Heyi Guo
Hi all,
We can see lots of using
boost::asio::deadline_timerin the code, like dbus-sensors. However, this timer is based on UTC clock and might be affected by system time. I tested and found the timer didn't trigger in time if I changed system time to some early time after starting the timer (callingexpire_from_now()). And I think this situation might happen if system time of BMC is synchronized with host or NTP.At the other hand,
steady_timeris a chrono timer and should not be affected by system time.
Quoted 7 lines
Quoted 3 lines
Is there any reason to use
deadline_timerfor relative timer trigger? Shall we switch tosteady_timerto avoid being affected by system time change?Yes, these should be
steady_timer. For some reason I thought we fixed this a long time ago in dbus-sensors, but apparently not. Please send the other maintainers and I a patch in gerrit (should be just a sed replace of alldeadline_timerinstances) and I'll review it.
For steady_timer.expire_from_now is deprecated, we need to replace below 3 pieces, isn't it?
deadline_timer -> steady_timer
expires_from_now -> expires_after
boost::posix_time -> std::chrono
Thanks,
Heyi
Quoted 5 lines
Quoted 5 lines
Thanks,
Heyi