mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-20 10:59:31 +00:00
Massively improve error handling, check for EPOLLHUP & EPOLLERR etc.
- Make sure to listen for EPOLLRDHUP in watchers so users can be notified when a peer closes a connection. - Handle EPOLLHUP and EPOLLERR gracefully. Even handle spurious EPOLLHUP by means of an error counter. If we receive too many errors we now restart the epoll fd and re-add all watchers. - Return error from `epoll_ctl()` in `uev_watcher_stop()` - Ignore any error from `uev_watcher_stop()` in `uev_watcher_set()` - Move LIST_REMOVE() et al from io.c to core uev.c, should be done for timer and signal callbacks as well, of course. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
71208b7e21
commit
fe8f3f19da
3 files changed
+88
-29
No files matched your search
@@ -62,11 +62,8 @@ int uev_io_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int fd, int e
|
||||
*/
|
||||
int uev_io_set(uev_t *w, int fd, int events)
|
||||
{
|
||||
if (uev_io_stop(w))
|
||||
return -1;
|
||||
|
||||
/* Remove from internal list */
|
||||
LIST_REMOVE(w, link);
|
||||
/* Ignore any errors, only to clean up anything lingering ... */
|
||||
uev_io_stop(w);
|
||||
|
||||
return uev_io_init(w->ctx, w, (uev_cb_t *)w->cb, w->arg, fd, events);
|
||||
}
|
||||
@@ -90,9 +87,7 @@ int uev_io_start(uev_t *w)
|
||||
*/
|
||||
int uev_io_stop(uev_t *w)
|
||||
{
|
||||
int status = uev_watcher_stop(w);
|
||||
|
||||
return status;
|
||||
return uev_watcher_stop(w);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user