summaryrefslogtreecommitdiff
path: root/kqueue.c
diff options
context:
space:
mode:
authorNiels Provos <provos@gmail.com>2003-03-08 16:33:18 +0000
committerNiels Provos <provos@gmail.com>2003-03-08 16:33:18 +0000
commit0036d79ab6d7663618c76ca49ca5173b2ab4424a (patch)
tree2d7805ac00aa57063a309bb1b3d2c818c7dc21df /kqueue.c
parent33b1c6c4745a769c1d14454d1f22e378757fe80f (diff)
downloadlibevent-0036d79ab6d7663618c76ca49ca5173b2ab4424a.tar.gz
fix kqueue problem
svn:r50
Diffstat (limited to 'kqueue.c')
-rw-r--r--kqueue.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/kqueue.c b/kqueue.c
index 9894064f..9e48b704 100644
--- a/kqueue.c
+++ b/kqueue.c
@@ -48,6 +48,9 @@
#include <unistd.h>
#include <errno.h>
#include <err.h>
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
#ifdef USE_LOG
#include "log.h"
@@ -56,6 +59,12 @@
#define log_error warn
#endif
+#ifdef HAVE_INTTYPES_H
+#define INTPTR(x) (intptr_t)x
+#else
+#define INTPTR(x) x
+#endif
+
#include "event.h"
extern struct event_list timequeue;
@@ -234,39 +243,18 @@ kq_dispatch(void *arg, struct timeval *tv)
which |= EV_WRITE;
} else if (events[i].filter == EVFILT_SIGNAL) {
which |= EV_SIGNAL;
- } else
- events[i].filter = 0;
+ }
if (!which)
continue;
+ if (!(ev->ev_events & EV_PERSIST))
+ event_del(ev);
+
event_active(ev, which,
ev->ev_events & EV_SIGNAL ? events[i].data : 1);
}
- for (i = 0; i < res; i++) {
- /* XXX */
- int ncalls, evres;
-
- if (events[i].flags & EV_ERROR || events[i].filter == NULL)
- continue;
-
- ev = (struct event *)events[i].udata;
- if (ev->ev_events & EV_PERSIST)
- continue;
-
- ncalls = 0;
- if (ev->ev_flags & EVLIST_ACTIVE) {
- ncalls = ev->ev_ncalls;
- evres = ev->ev_res;
- }
- ev->ev_flags &= ~EVLIST_X_KQINKERNEL;
- event_del(ev);
-
- if (ncalls)
- event_active(ev, evres, ncalls);
- }
-
return (0);
}
@@ -286,7 +274,7 @@ kq_add(void *arg, struct event *ev)
kev.flags = EV_ADD;
if (!(ev->ev_events & EV_PERSIST))
kev.flags |= EV_ONESHOT;
- kev.udata = ev;
+ kev.udata = INTPTR(ev);
if (kq_insert(kqop, &kev) == -1)
return (-1);
@@ -305,7 +293,7 @@ kq_add(void *arg, struct event *ev)
kev.flags = EV_ADD;
if (!(ev->ev_events & EV_PERSIST))
kev.flags |= EV_ONESHOT;
- kev.udata = ev;
+ kev.udata = INTPTR(ev);
if (kq_insert(kqop, &kev) == -1)
return (-1);
@@ -320,7 +308,7 @@ kq_add(void *arg, struct event *ev)
kev.flags = EV_ADD;
if (!(ev->ev_events & EV_PERSIST))
kev.flags |= EV_ONESHOT;
- kev.udata = ev;
+ kev.udata = INTPTR(ev);
if (kq_insert(kqop, &kev) == -1)
return (-1);