[Libevent-users] EV_PERSIST behavior
Phil Oleson
oz at nixil.net
Tue May 8 16:53:17 EDT 2007
Christopher Layne wrote:
> I understand that EV_PERSIST basically means that one does not have to
> continually reschedule the event upon the event occuring.
>
> Consider the following simple test case and my following question on it...
>
<snip>
> Documentation for that is here:
> The function event_add() schedules the execution of the ev event when
> the event specified in event_set() occurs or in at least the time speci-
> fied in the tv. If tv is NULL, no timeout occurs and the function
> will only be called if a matching event occurs on the file descriptor.
> The event in the ev argument must be already initialized by event_set()
> and may not be used in calls to event_set() until it has timed out or
> implies event_del() --> ^^^^^^^^^^^^^^^^^^^^^
> been removed with event_del(). If the event in the ev argument already
> has a scheduled timeout, the old timeout will be replaced by the new one.
>
> Just took a bit to find it in the manpage. It might want to be more explictly
> stated in the documentation.
Well, I've dealt with this before, so I'll give you the rundown.
libevent uses clock_gettime() and CLOCK_MONOTONIC within it's queues
to keep events happening across time changes on the system.
So.. To fix your implementation you will need to do something like I did.
I reimplemented libevents' gettime() function (because it's not exposed
via event.h) and use it instead of calling time(NULL);
-Phil.
More information about the Libevent-users
mailing list