]> Pileus Git - ~andy/lamechat/commitdiff
Add poll debugging.
authorAndy Spencer <andy753421@gmail.com>
Tue, 20 Feb 2018 03:54:00 +0000 (03:54 +0000)
committerAndy Spencer <andy753421@gmail.com>
Tue, 20 Feb 2018 03:54:00 +0000 (03:54 +0000)
util.c
util.h

diff --git a/util.c b/util.c
index 803efbff6dd5dab141b1ff8dd40628013b10dab0..e5f708acc4ddeb5c94388bed3803d19835efb1e1 100644 (file)
--- a/util.c
+++ b/util.c
@@ -315,7 +315,7 @@ err:
 }
 
 /* Polling functions */
-int poll_add(poll_t *poll, int fd, cb_t cb, void *data)
+void poll_add(poll_t *poll, int fd, cb_t cb, void *data)
 {
        struct epoll_event ctl = {
                .events = EPOLLET | EPOLLIN | EPOLLOUT | EPOLLERR,
@@ -324,10 +324,11 @@ int poll_add(poll_t *poll, int fd, cb_t cb, void *data)
        poll->fd   = fd;
        poll->cb   = cb;
        poll->data = data;
-       return epoll_ctl(epoll, EPOLL_CTL_ADD, fd, &ctl);
+       if (epoll_ctl(epoll, EPOLL_CTL_ADD, fd, &ctl) < 0)
+               error("adding poll");
 }
 
-int poll_ctl(poll_t *poll, int in, int out, int err)
+void poll_ctl(poll_t *poll, int in, int out, int err)
 {
        struct epoll_event ctl = {
                .events = EPOLLET
@@ -336,12 +337,14 @@ int poll_ctl(poll_t *poll, int in, int out, int err)
                        | (err ? EPOLLERR : 0),
                .data.ptr = poll,
        };
-       return epoll_ctl(epoll, EPOLL_CTL_MOD, poll->fd, &ctl);
+       if (epoll_ctl(epoll, EPOLL_CTL_MOD, poll->fd, &ctl) < 0)
+               error("modifying poll");
 }
 
-int poll_del(poll_t *poll)
+void poll_del(poll_t *poll)
 {
-       return epoll_ctl(epoll, EPOLL_CTL_DEL, poll->fd, NULL);
+       if (epoll_ctl(epoll, EPOLL_CTL_DEL, poll->fd, NULL) < 0)
+               error("deleting poll");
 }
 
 int poll_run(int timeout)
diff --git a/util.h b/util.h
index 6310a90580e79e86b8ea73021fc4c7b19b601036..f3840c5ee4adad40d5d6236064d566f8d9caef90 100644 (file)
--- a/util.h
+++ b/util.h
@@ -71,9 +71,9 @@ int base64(const void *in, int ilen, void *out, int olen);
 char *read_file(const char *path, int *len);
 
 /* Polling functions */
-int poll_add(poll_t *poll, int fd, cb_t cb, void *data);
-int poll_ctl(poll_t *poll, int in, int out, int err);
-int poll_del(poll_t *poll);
+void poll_add(poll_t *poll, int fd, cb_t cb, void *data);
+void poll_ctl(poll_t *poll, int in, int out, int err);
+void poll_del(poll_t *poll);
 int poll_run(int timeout);
 void poll_quit(void);