#include "portab.h"
-static char UNUSED id[] = "$Id: io.c,v 1.7 2005/08/27 20:27:07 fw Exp $";
+static char UNUSED id[] = "$Id: io.c,v 1.11 2005/09/04 13:38:59 fw Exp $";
#include <assert.h>
#include <stdlib.h>
{
struct kevent kev;
short filter = 0;
- unsigned int len = array_length(&io_evcache, sizeof kev);
+ size_t len = array_length(&io_evcache, sizeof kev);
if (what & IO_WANTREAD)
filter = EVFILT_READ;
filter |= EVFILT_WRITE;
if (len >= 100) {
- (void)array_trunc(&io_evcache);
+ (void)io_event_kqueue_commit_cache();
}
EV_SET(&kev, fd, filter, EV_ADD | EV_ENABLE, 0, 0, NULL);
if (array_length(&io_evcache, sizeof (struct kevent))) /* pending data in cache? */
io_event_kqueue_commit_cache();
#endif
- return close(fd) == 0; /* both epoll an kqueue will remove fd from all sets automatically */
+#ifdef IO_USE_EPOLL
+ epoll_ctl(io_masterfd, EPOLL_CTL_DEL, fd, NULL);
+#endif
+ return close(fd) == 0; /* kqueue will remove fd from all sets automatically */
}
{
int i, total = 0, ret;
struct kevent kev[100];
- const struct kevent *newevents;
+ struct kevent *newevents;
struct timespec ts;
int newevents_len;
short type;
ts.tv_nsec = tv->tv_usec * 1000;
do {
- newevents_len = array_length(&io_evcache, sizeof (struct kevent));
+ newevents_len = (int) array_length(&io_evcache, sizeof (struct kevent));
newevents = (newevents_len > 0) ? array_start(&io_evcache) : NULL;
assert(newevents_len >= 0);
if (newevents_len < 0)