From a8386b56f6eea13514fb82f9243aa2e065b5da28 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Fri, 11 Jul 2008 08:05:25 -0400 Subject: [PATCH] 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. --- src/ioset-kevent.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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)); -- 2.20.1