Timers expire prior to expiry time

Aviv Heller (avheller) avheller at cisco.com
Thu Aug 21 15:33:49 CEST 2014


I have encountered a problem, on version 4.11 of the library, where a timer started expired prior to its intended expiry time.

This happened because time_update() is not called by ev_timer_start() prior to calculating the expiry timestamp, which in cases where a timer is started after a long processing time during a loop iteration, results in ev_timer_start() using an old time instead of the current one.

In cases where the system is under heavy load (a prevalent case in embedded systems), this problem can manifest even if the iteration processing time prior to setting the timer is in theory short.

The fix I propose is to have ev_timer_start() call time_update() before calculating the expiry timestamp (patch attached).

I would be glad to know what are your thoughts on this issue, and whether this fix is needed and makes sense.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20140821/1e36c44e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libev-time-update-on-timer-start.patch
Type: application/octet-stream
Size: 544 bytes
Desc: libev-time-update-on-timer-start.patch
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20140821/1e36c44e/attachment.obj>

More information about the libev mailing list