uev.c: Stop I/O watcher immediately on EPOLLERR or EPOLLHUP

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>
This commit is contained in:
Joachim Nilsson
2017-11-14 12:56:39 +01:00
parent 7d97b9f04a
commit e35c065d77
+2 -10
View File
@@ -52,12 +52,6 @@ static int _init(uev_ctx_t *ctx, int close_old)
return 0;
}
/* Simple check if a descriptor is still valid in the kernel */
static int is_valid_fd(int fd)
{
return fcntl(fd, F_GETFL) != -1 || errno != EBADF;
}
/* Used by file i/o workaround when epoll => EPERM */
static int has_data(int fd)
{
@@ -332,10 +326,8 @@ int uev_run(uev_ctx_t *ctx, int flags)
switch (w->type) {
case UEV_IO_TYPE:
if (events & (EPOLLHUP | EPOLLERR)) {
if (!is_valid_fd(w->fd))
uev_io_stop(w);
}
if (events & (EPOLLHUP | EPOLLERR))
uev_io_stop(w);
break;
case UEV_SIGNAL_TYPE: