[hackers] [quark] Make queue-event-error-detection stricter || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Tue, 2 Feb 2021 22:23:17 +0100 (CET)

commit f45ca668af3d615e9215db49f190ea2833cecc18
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Tue Feb 2 22:20:03 2021 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Tue Feb 2 22:20:03 2021 +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_AT_frign.de>

diff --git a/main.c b/main.c
index 0478993..28bff20 100644
--- a/main.c
+++ b/main.c
_AT_@ -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
index 0a94e68..8f75f92 100644
--- a/queue.c
+++ b/queue.c
_AT_@ -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
index 162ac38..e31f7d2 100644
--- a/queue.h
+++ b/queue.h
_AT_@ -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 */
Received on Tue Feb 02 2021 - 22:23:17 CET

This archive was generated by hypermail 2.3.0 : Tue Feb 02 2021 - 22:24:39 CET