Does it make sense to change boost::asio::deadline_timer to steady_timer?

Heyi Guo guoheyi at linux.alibaba.com
Thu Mar 10 22:51:59 AEDT 2022


在 2022/3/10 上午12:22, Ed Tanous 写道:
> On Wed, Mar 9, 2022 at 6:16 AM Heyi Guo <guoheyi at linux.alibaba.com> wrote:
>> 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?
> 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.

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


>
>> Thanks,
>>
>> Heyi
>>


More information about the openbmc mailing list