[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] a dead looping bug when changing system time backward




On Apr 10, 2012, at 6:15 PM, Nick Mathewson wrote:

And there's a third way for libevent to see a big jump forward in
time: if the program calls event_base_loop() sporadically, it is free
to wait as long as it wants between invocations.

So, what's the right behavior for periodic events in these cases?  If
there is an event that's supposed to run every 5 seconds, and time has
jumped forward by 16 seconds, it seems reasonable to run the event 1
time, or maybe even 3 times... but if time has jumped forward by one
day, it seems unlikely that the programmer really wants us to run the
event 17280 times.

Perhaps this argues for a cap on how far into the past we should be
willing to reschedule a periodic event, or how many "missed firings"
we'll compensate for before we drop some on the floor?

Forward jumps should simply skip events in the past. It is just like events skipped because the event loop was blocked.

If you should run every 5 seconds, but woke up 21 seconds late, you cannot fix the past - you just missed the events at +5, +10, +15 and +20. Run the next event at +25 according to the plan.

Other event loops like Cocoa NSRunloop and GNUStep NSRunloop use this logic.


***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.