commit 3729e7222aafc4c4ca30351748a89e05f78e2230
Author:     Rainer Holzner <[email protected]>
AuthorDate: Sat Jan 30 13:54:58 2021 +0100
Commit:     Laslo Hunhold <[email protected]>
CommitDate: Sat Jan 30 15:31:03 2021 +0100

    Return -1 in case of errors in queue event wrapper functions.
    
    Use same data type for nready (number of events) as returned by 
queue_wait().

diff --git a/main.c b/main.c
index e383498..2911bc8 100644
--- a/main.c
+++ b/main.c
@@ -212,7 +212,8 @@ thread_method(void *data)
        queue_event *event = NULL;
        struct connection *connection, *c;
        struct worker_data *d = (struct worker_data *)data;
-       int qfd, nready, fd;
+       int qfd, fd;
+       ssize_t nready;
        size_t i;
 
        /* allocate connections */
diff --git a/queue.c b/queue.c
index fce38e2..53a13f1 100644
--- a/queue.c
+++ b/queue.c
@@ -77,7 +77,7 @@ queue_add_fd(int qfd, int fd, enum queue_event_type t, int 
shared,
                /* register fd in the interest list */
                if (epoll_ctl(qfd, EPOLL_CTL_ADD, fd, &e) < 0) {
                        warn("epoll_ctl:");
-                       return 1;
+                       return -1;
                }
        #else
                struct kevent e;
@@ -99,7 +99,7 @@ queue_add_fd(int qfd, int fd, enum queue_event_type t, int 
shared,
 
                if (kevent(qfd, &e, 1, NULL, 0, NULL) < 0) {
                        warn("kevent:");
-                       return 1;
+                       return -1;
                }
        #endif
 
@@ -136,7 +136,7 @@ queue_mod_fd(int qfd, int fd, enum queue_event_type t, 
const void *data)
                /* register fd in the interest list */
                if (epoll_ctl(qfd, EPOLL_CTL_MOD, fd, &e) < 0) {
                        warn("epoll_ctl:");
-                       return 1;
+                       return -1;
                }
        #else
                struct kevent e;
@@ -157,7 +157,7 @@ queue_mod_fd(int qfd, int fd, enum queue_event_type t, 
const void *data)
 
                if (kevent(qfd, &e, 1, NULL, 0, NULL) < 0) {
                        warn("kevent:");
-                       return 1;
+                       return -1;
                }
        #endif
 
@@ -172,7 +172,7 @@ queue_rem_fd(int qfd, int fd)
 
                if (epoll_ctl(qfd, EPOLL_CTL_DEL, fd, &e) < 0) {
                        warn("epoll_ctl:");
-                       return 1;
+                       return -1;
                }
        #else
                struct kevent e;
@@ -181,7 +181,7 @@ queue_rem_fd(int qfd, int fd)
 
                if (kevent(qfd, &e, 1, NULL, 0, NULL) < 0) {
                        warn("kevent:");
-                       return 1;
+                       return -1;
                }
        #endif
 
@@ -201,7 +201,7 @@ queue_wait(int qfd, queue_event *e, size_t elen)
        #else
                if ((nready = kevent(qfd, NULL, 0, e, elen, NULL)) < 0) {
                        warn("kevent:");
-                       return 1;
+                       return -1;
                }
        #endif
 

Reply via email to