quark

quark web server
git clone git://git.suckless.org/quark
Log | Files | Refs | LICENSE

commit f45ca668af3d615e9215db49f190ea2833cecc18
parent 35e3b69d60f337724163e9543b5728b907ce34dd
Author: Laslo Hunhold <dev@frign.de>
Date:   Tue,  2 Feb 2021 22:20:03 +0100

Make queue-event-error-detection stricter

Everything which is not a pollin or pollout is now considered an error.
This is due to the fact how variable epoll(7) is in regard to possible
events, often depending on your kernel configuration (see for instance
EPOLLPRI and possible future additions).

In this context, we also rename the function to better reflect its
purpose.

Signed-off-by: Laslo Hunhold <dev@frign.de>

Diffstat:
Mmain.c | 2+-
Mqueue.c | 4++--
Mqueue.h | 2+-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/main.c b/main.c @@ -246,7 +246,7 @@ thread_method(void *data) for (i = 0; i < (size_t)nready; i++) { c = queue_event_get_data(&event[i]); - if (queue_event_is_dropped(&event[i])) { + if (queue_event_is_error(&event[i])) { if (c != NULL) { queue_rem_fd(qfd, c->fd); close_connection(c); diff --git a/queue.c b/queue.c @@ -207,10 +207,10 @@ queue_event_get_data(const queue_event *e) } int -queue_event_is_dropped(const queue_event *e) +queue_event_is_error(const queue_event *e) { #ifdef __linux__ - return (e->events & (EPOLLERR | EPOLLHUP)) ? 1 : 0; + return (e->events & ~(EPOLLIN | EPOLLOUT)) ? 1 : 0; #else return (e->flags & EV_EOF) ? 1 : 0; #endif diff --git a/queue.h b/queue.h @@ -28,6 +28,6 @@ ssize_t queue_wait(int, queue_event *, size_t); void *queue_event_get_data(const queue_event *); -int queue_event_is_dropped(const queue_event *e); +int queue_event_is_error(const queue_event *e); #endif /* QUEUE_H */