[dovecot-cvs] dovecot/src/lib ioloop-kqueue.c,1.4,1.5
cras at dovecot.org
cras at dovecot.org
Thu Jun 8 19:44:58 EEST 2006
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv26182
Modified Files:
ioloop-kqueue.c
Log Message:
Fixed "Unrecognized event" errors that occurred with IO_ERROR. Patch by
Vaclav Haisman
Index: ioloop-kqueue.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ioloop-kqueue.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ioloop-kqueue.c 25 Mar 2006 08:08:03 -0000 1.4
+++ ioloop-kqueue.c 8 Jun 2006 16:44:56 -0000 1.5
@@ -74,7 +74,7 @@
{
struct ioloop_handler_context *ctx = ioloop->handler_context;
const int fd = io->fd;
- struct kevent ev = { fd, 0, EV_ADD | EV_EOF, 0, 0, NULL };
+ struct kevent ev = { fd, 0, EV_ADD, 0, 0, NULL };
enum io_condition condition = io->condition & MASK;
i_assert(io->callback != NULL);
@@ -101,6 +101,8 @@
if (condition & (IO_READ | IO_ERROR)) {
ctx->fds[fd].mode |= condition;
ev.filter = EVFILT_READ;
+ if (!(condition & ~IO_ERROR))
+ ev.flags |= EV_CLEAR;
if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) < 0) {
i_error("kevent(%d) in io_loop_handle_add() failed: %m",
fd);
@@ -109,6 +111,8 @@
if (condition & (IO_WRITE | IO_ERROR)) {
ctx->fds[fd].mode |= condition;
ev.filter = EVFILT_WRITE;
+ if (!(condition & ~IO_ERROR))
+ ev.flags |= EV_CLEAR;
if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) < 0) {
i_error("kevent(%d) in io_loop_handle_add() failed: %m",
fd);
@@ -184,7 +188,7 @@
i_assert(ctx->evbuf[i].ident < ctx->fds_size);
if ((ctx->fds[ctx->evbuf[i].ident].mode & IO_ERROR) &&
- (ctx->evbuf[i].flags & EV_EOF)) {
+ (ctx->evbuf[i].flags & (EV_EOF | EV_ERROR))) {
struct io *errio = ctx->fds[ctx->evbuf[i].ident].errio;
t_id = t_push();
@@ -203,14 +207,22 @@
" in I/O handler %p",
(void *)io->callback);
}
+ } else if (ctx->fds[ctx->evbuf[i].ident].mode & IO_ERROR) {
+ /*
+ NO-OP. If the handle is registered only for
+ IO_ERROR, then we can get readable/writable event
+ but no IO_READ | IO_WRITE set.
+ */
} else
i_panic("Unrecognized event: kevent {.ident = %u,"
" .filter = 0x%04x,"
" .flags = 0x%04x,"
" .fflags = 0x%08x,"
- " .data = 0x%08x}", ctx->evbuf[i].ident,
+ " .data = 0x%08x}\n"
+ "mode: 0x%x04x", ctx->evbuf[i].ident,
ctx->evbuf[i].filter, ctx->evbuf[i].flags,
- ctx->evbuf[i].fflags, ctx->evbuf[i].data);
+ ctx->evbuf[i].fflags, ctx->evbuf[i].data,
+ ctx->fds[ctx->evbuf[i].ident].mode);
}
}
More information about the dovecot-cvs
mailing list