A watcher callback may be a timeout callback, or similar, that deletes
itself and the watcher. So we should not dereference anything in the
watcher after the callback.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
No need to check fd with fcntl(). On EPOLLERR the descriptor has an
error condition that must bed ACK'ed by the callback. On EPOLLHUP
we got a hang-up on the remote end, usually a stream or pipe, either
way the callback must ACK this too, regardless.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The `examples/` directory was never built. The documentation however
indicated the existence of an `--enable-examples` option, which didn't
really exist. This patch adds that option.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
If an I/O watcher callback fails to read(), returning zero, we check
events for UEV_HUP to detect EOF or socket remote end shutdown().
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch adds UEV_ERROR handling to the test I/O watcher, restarting
the watcher properly. Also, additional error handling to read(), which
was unchecked and failed when fuzzing the libc read() function.
We also take the opportunity to document the reasons for when using the
w->fd (watcher descriptor) and when *not* to in the test. Even to the
author this was confusing and looked suspicious.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Many users look at both examples *and* unit tests to learn how to use a
library. We should pride ourselves in that we have not just working but
also correct and readable tests.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Both cron and regular timers were closed twice on uev_exit(), first
when iterating over all watchers, next after each cb() has run in
uev_run(). This patch adds a check if a watcher is active before
attempting to stop it (again).
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch is a follow-up to 2f9cce9, and a complete refactor of
fe8f3f1 which first introduced the EPOLLERR and EPOLLHUP handling.
Then mainly for managing errors and hangups on stream sockets.
Now, instead of trying to reopen the epoll() fd, and breaking out
hard from the event loop on catastrophic error, we now delegate
I/O watcher EPOLLERR and EPOLLHUP to the watcher callback, just
like other watchers.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
In 2f9cce9 the invalidate_watcher() function was introduced to stop
invalid timer/cron and signal watchers. This patch refactors that
change to instead call the stop method for cron/timer and attempt to
restart failing signal watchers.
The cron/timer and signal watchers are quite different from regular
I/O watchers in that their internal "fd" is hidden from and not under
the control of the user, so we should try to handle them better. For
the former two we cannot do much other than stop and call the user's
registered callback with UEV_ERROR, but for the latter we can at least
try to restart it.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
With distcheck we not only build the distribution files, but also runs
test suite and verifies that the resulting dist file(s) can be built.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>