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>
uev_timer_init() crashes when called without a watcher:
uev_timer_init(ctx, NULL, cb, NULL, 100, 0);
The cleanup after a failed setup resets the descriptor in the watcher
without checking that there is one.
Check the arguments first, like the other watcher types do.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
uev_init() leaves the context descriptor at 0 when epoll_create1()
fails. A following uev_exit() then closes stdin.
Set it to -1 before creating the epoll descriptor.
uev_event_init() leaks its eventfd, and leaves it in the watcher, when
the watcher cannot be added to the event loop.
Close it and reset the descriptor in the watcher.