]> granicus.if.org Git - libevent/commitdiff
fix kqueue problem
authorNiels Provos <provos@gmail.com>
Sat, 8 Mar 2003 16:33:18 +0000 (16:33 +0000)
committerNiels Provos <provos@gmail.com>
Sat, 8 Mar 2003 16:33:18 +0000 (16:33 +0000)
svn:r50

Makefile.am
configure.in
kqueue.c

index 98bbc7befdb59751fd78e2c4162605ede7072d50..fe756916207d7e65ab9426f22e09c6cb1e53d959 100644 (file)
@@ -1,5 +1,6 @@
 AUTOMAKE_OPTIONS = foreign no-dependencies
 
+CFLAGS += -Wall -g -O2
 SUBDIRS = . sample test
 
 EXTRA_DIST = acconfig.h evsignal.h \
index 775d298cfe7500a2ca04d2a175cfd38b50376b07..f085ae3b33cc58bc24b7b9f05d2715c4ea2e3b4f 100644 (file)
@@ -21,7 +21,7 @@ AC_CHECK_LIB(socket, socket)
 
 dnl Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS(poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h)
+AC_CHECK_HEADERS(inttypes.h stdint.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h)
 if test "x$ac_cv_header_sys_queue_h" = "xyes"; then
        AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h)
        AC_EGREP_CPP(yes,
index 9894064f31d6f57f0a367d1f6adb1ca92ceddb41..9e48b7040100bdff5f58e07e7851e45b1ed69dfd 100644 (file)
--- 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"
 #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);