]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/io.c
New configuration option "OperChanPAutoOp"
[ngircd-alex.git] / src / ngircd / io.c
index f061ce057203bbd395af33102dafd3c9fb37c782..cce6ef536557e7376bf93a1a8df9f912218ae0e4 100644 (file)
@@ -41,6 +41,7 @@ typedef struct {
 
 #define INIT_IOEVENT           { NULL, -1, 0, NULL }
 #define IO_ERROR               4
+#define MAX_EVENTS             100
 
 #ifdef HAVE_EPOLL_CREATE
 #  define IO_USE_EPOLL         1
@@ -85,6 +86,20 @@ static int io_masterfd;
 
 static int io_dispatch_kqueue(struct timeval *tv);
 static bool io_event_change_kqueue(int, short, const int action);
+
+#ifndef EV_SET
+/* Taken from /usr/include/sys/event.h of FreeBSD 8.1 and required by all
+ * platforms that have kqueue but lack EV_SET() -- for example FreeBSD 4. */
+#define EV_SET(kevp, a, b, c, d, e, f) do {    \
+       struct kevent *__kevp__ = (kevp);       \
+       __kevp__->ident = (a);                  \
+       __kevp__->filter = (b);                 \
+       __kevp__->flags = (c);                  \
+       __kevp__->fflags = (d);                 \
+       __kevp__->data = (e);                   \
+       __kevp__->udata = (f);                  \
+} while(0)
+#endif
 #endif
 
 #ifdef IO_USE_POLL
@@ -162,13 +177,13 @@ io_dispatch_devpoll(struct timeval *tv)
        time_t sec = tv->tv_sec * 1000;
        int i, ret, timeout = tv->tv_usec + sec;
        short what;
-       struct pollfd p[100];
+       struct pollfd p[MAX_EVENTS];
 
        if (timeout < 0)
                timeout = 1000;
 
        dvp.dp_timeout = timeout;
-       dvp.dp_nfds = 100;
+       dvp.dp_nfds = MAX_EVENTS;
        dvp.dp_fds = p;
        ret = ioctl(io_masterfd, DP_POLL, &dvp);
 
@@ -458,13 +473,13 @@ io_dispatch_epoll(struct timeval *tv)
 {
        time_t sec = tv->tv_sec * 1000;
        int i, ret, timeout = tv->tv_usec + sec;
-       struct epoll_event epoll_ev[100];
+       struct epoll_event epoll_ev[MAX_EVENTS];
        short type;
 
        if (timeout < 0)
                timeout = 1000;
 
-       ret = epoll_wait(io_masterfd, epoll_ev, 100, timeout);
+       ret = epoll_wait(io_masterfd, epoll_ev, MAX_EVENTS, timeout);
 
        for (i = 0; i < ret; i++) {
                type = 0;
@@ -565,7 +580,7 @@ static int
 io_dispatch_kqueue(struct timeval *tv)
 {
        int i, ret;
-       struct kevent kev[100];
+       struct kevent kev[MAX_EVENTS];
        struct kevent *newevents;
        struct timespec ts;
        int newevents_len;
@@ -576,7 +591,7 @@ io_dispatch_kqueue(struct timeval *tv)
        newevents = (newevents_len > 0) ? array_start(&io_evcache) : NULL;
        assert(newevents_len >= 0);
 
-       ret = kevent(io_masterfd, newevents, newevents_len, kev, 100, &ts);
+       ret = kevent(io_masterfd, newevents, newevents_len, kev, MAX_EVENTS, &ts);
        if (newevents && ret != -1)
                array_trunc(&io_evcache);