Skip to content

Commit

Permalink
fix kqueue problem
Browse files Browse the repository at this point in the history
svn:r50
  • Loading branch information
provos committed Mar 8, 2003
1 parent 33b1c6c commit 0036d79
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
AUTOMAKE_OPTIONS = foreign no-dependencies

CFLAGS += -Wall -g -O2
SUBDIRS = . sample test

EXTRA_DIST = acconfig.h evsignal.h \
Expand Down
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
44 changes: 16 additions & 28 deletions kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 0036d79

Please sign in to comment.