From: Michael Poole Date: Fri, 11 Jul 2008 12:05:25 +0000 (-0400) Subject: Correctly handle a writable->unwritable transition on a socket in kevent. X-Git-Tag: v1.4.0-rc3~1 X-Git-Url: http://git.pk910.de/?p=srvx.git;a=commitdiff_plain;h=a8386b56f6eea13514fb82f9243aa2e065b5da28 Correctly handle a writable->unwritable transition on a socket in kevent. src/ioset-kevent.c (ioset_kevent_add): If the socket is not writable, we should EV_DELETE the write notification rather than leaving it. --- diff --git a/src/ioset-kevent.c b/src/ioset-kevent.c index 02a8511..a88970b 100644 --- a/src/ioset-kevent.c +++ b/src/ioset-kevent.c @@ -46,9 +46,7 @@ ioset_kevent_add(struct io_fd *fd) int res; EV_SET(&changes[nchanges++], fd->fd, EVFILT_READ, EV_ADD, 0, 0, fd); - if (fd_wants_writes(fd)) { - EV_SET(&changes[nchanges++], fd->fd, EVFILT_WRITE, EV_ADD, 0, 0, fd); - } + EV_SET(&changes[nchanges++], fd->fd, EVFILT_WRITE, fd_wants_writes(fd) ? EV_ADD : EV_DELETE, 0, 0, fd); res = kevent(kq_fd, changes, nchanges, NULL, 0, NULL); if (res < 0) { log_module(MAIN_LOG, LOG_ERROR, "kevent() add failed: %s", strerror(errno));