When uev_cron_init() or uev_signal_init() fails to add the watcher to
the event loop, the watcher is left with a descriptor that is closed.
A later set or start on it then operates on that descriptor, which by
then may belong to something else.
Reset it to -1, as the timer and event watchers do.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
A cron watcher with start time zero, documented to mean 'now', never
runs:
uev_cron_init(ctx, w, cb, NULL, 0, 3600);
Zero is passed as is to the timerfd, where it disarms the timer.
Replace it with the current time when the event loop is running. This
also goes for uev_cron_set(), where zero no longer disarms the watcher,
use uev_cron_stop() for that.
The event loop used a start time of zero to mark an at job as done.
Stop the watcher there instead and keep its time, so restarting an at
job that was interrupted by a clock change does not run it at once.
Closes#30
uev_cron_start() on a stopped cron watcher brings it back as a regular
timer, with a timeout made up of parts of the cron schedule. It calls
uev_timer_start(), which reads the timer fields of the watcher and
creates a monotonic timer.
Restart with uev_cron_set() and the cron schedule instead.
This patch replaces the BSD doubly linked list implementation with a
simplified homegrown version. This not only reduces the dependency on
an external "library", but also greatly simplifies licensing and gives
us a clean name space that does not intrude on users who want to use
their own version of queue.h in their application that also includes
the libuEv header file.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>