Correctly handle a writable->unwritable transition on a socket in kevent.
authorMichael Poole <mdpoole@troilus.org>
Fri, 11 Jul 2008 12:05:25 +0000 (08:05 -0400)
committerMichael Poole <mdpoole@troilus.org>
Sat, 12 Jul 2008 03:39:02 +0000 (23:39 -0400)
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

index 02a85111d61875ab15a3d52fd0ff08ee459ee928..a88970b059c4155df4fcbc631bb791210e081a7d 100644 (file)
@@ -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));