ioloop-notify-kqueue.c revision 4307c886579381dbb1897ea1388ae6978c96f560
/*
* BSD kqueue() based ioloop notify handler.
*
* Copyright (c) 2005 Vaclav Haisman <v.haisman@sh.cvut.cz>
*/
#define _GNU_SOURCE
#include "lib.h"
#ifdef IOLOOP_NOTIFY_KQUEUE
#include "ioloop-private.h"
#include "fd-close-on-exec.h"
#include <unistd.h>
#include <fcntl.h>
/* kevent.udata's type just has to be different in NetBSD than in
FreeBSD and OpenBSD.. */
#ifdef __NetBSD__
# define MY_EV_SET(a, b, c, d, e, f, g) \
#else
# define MY_EV_SET(a, b, c, d, e, f, g) \
EV_SET(a, b, c, d, e, f, g)
#endif
struct io_notify {
int refcount;
int fd;
};
struct ioloop_notify_handler_context {
int kq;
};
{
int i, ret;
if (ret <= 0) {
return;
i_fatal("kevent(notify) failed: %m");
}
i_fatal("gettimeofday() failed: %m");
for (i = 0; i < ret; i++) {
}
for (i = 0; i < ret; i++) {
/* there can be multiple events for a single io.
call the callback only once if that happens. */
}
}
static struct ioloop_notify_handler_context *io_loop_notify_handler_init(void)
{
struct ioloop_notify_handler_context *ctx;
i_fatal("kqueue(notify) failed: %m");
return ctx;
}
{
struct ioloop_notify_handler_context *ctx =
i_error("close(kqueue notify) failed: %m");
}
{
struct ioloop_notify_handler_context *ctx =
int fd;
if (fd == -1) {
/* ESTALE could happen with NFS. Don't bother giving an error
message then. */
return IO_NOTIFY_NOTFOUND;
}
/* EV_CLEAR flag is needed because the EVFILT_VNODE filter reports
event state transitions and not the current state. With this flag,
the same event is only returned once. */
i_close_fd(&fd);
return IO_NOTIFY_NOSUPPORT;
}
}
return IO_NOTIFY_ADDED;
}
{
struct ioloop_notify_handler_context *ctx =
}
#endif