[hackers] [quark][PATCH] Return -1 in case of errors in queue event wrapper functions.

From: Rainer Holzner <rholzner_AT_web.de>
Date: Sat, 30 Jan 2021 13:54:58 +0100

Use same data type for nready (number of events) as returned by queue_wait().
---
 main.c  |  3 ++-
 queue.c | 14 +++++++-------
 2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/main.c b/main.c
index e383498..2911bc8 100644
--- a/main.c
+++ b/main.c
_AT_@ -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
_AT_@ -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;
_AT_@ -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
_AT_@ -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;
_AT_@ -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
_AT_@ -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;
_AT_@ -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
_AT_@ -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
--
2.20.1
Received on Sat Jan 30 2021 - 13:54:58 CET

This archive was generated by hypermail 2.3.0 : Sat Jan 30 2021 - 14:00:39 CET