summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2012-10-25 18:14:25 +0000
committerEric Faurot <eric@cvs.openbsd.org>2012-10-25 18:14:25 +0000
commit8e5220ef9086bc55563880bf47f1fa7dfc9d7458 (patch)
treef810c286257e03eeed279d1e68280b9b0be7b7f7
parent91df0ee4e58b469eebf69a2bf3796e56b0ad93a3 (diff)
Handle the case where writev() fails with EAGAIN. In theory it cannot
happen, but it seems that kqueue triggers the event sometimes, even if the socket is not immediatly writeable. Temporary workaround it while the real issue is being investigated. ok gilles@ chl@
-rw-r--r--usr.sbin/smtpd/ioev.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/smtpd/ioev.c b/usr.sbin/smtpd/ioev.c
index 69e9c93ce8e..3f66fc6667b 100644
--- a/usr.sbin/smtpd/ioev.c
+++ b/usr.sbin/smtpd/ioev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioev.c,v 1.6 2012/10/10 19:38:04 eric Exp $ */
+/* $OpenBSD: ioev.c,v 1.7 2012/10/25 18:14:24 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -542,8 +542,10 @@ io_dispatch(int fd, short ev, void *humppa)
if (ev & EV_WRITE && (w = io_queued(io))) {
if ((n = iobuf_write(io->iobuf, io->sock)) < 0) {
- if (n == IO_ERROR)
+ if (n == IOBUF_ERROR || n == IOBUF_WANT_WRITE)
log_warn("io_dispatch: iobuf_write");
+ if (n == IOBUF_WANT_WRITE) /* kqueue bug? */
+ goto read;
io_callback(io, n == IOBUF_CLOSED ?
IO_DISCONNECTED : IO_ERROR);
goto leave;
@@ -551,6 +553,7 @@ io_dispatch(int fd, short ev, void *humppa)
if (w > io->lowat && w - n <= io->lowat)
io_callback(io, IO_LOWAT);
}
+ read:
if (ev & EV_READ) {
if ((n = iobuf_read(io->iobuf, io->sock)) < 0) {