io_wait: fix kqueue io_wait_add & POLLIN
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 18 Jun 2010 22:35:47 +0000 (00:35 +0200)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 18 Jun 2010 23:02:45 +0000 (01:02 +0200)
A "goto error" was placed outside the error handling "if",
resulting in any io_watch_add(), that tried to enable write
watching on a new FD, returning failure (fortunately this kind
of io_watch_add() usage doesn't happen very often, usually write
watch is enabled via io_watch_chg() on FDs already
io_watch_add()'ed for reading).

Only POLL_KQUEUE was affected by this bug, meaning the default on
all *bsd and darwin.

io_wait.h

index 01df1e6..b110b6b 100644 (file)
--- a/io_wait.h
+++ b/io_wait.h
@@ -499,7 +499,7 @@ again2:
                case POLL_KQUEUE:
                        if (likely( events & POLLIN)){
                                if (unlikely(kq_ev_change(h, fd, EVFILT_READ, EV_ADD, e)==-1))
-                               goto error;
+                                       goto error;
                        }
                        if (unlikely( events & POLLOUT)){
                                if (unlikely(kq_ev_change(h, fd, EVFILT_WRITE, EV_ADD, e)==-1))
@@ -507,8 +507,8 @@ again2:
                                        if (likely(events & POLLIN)){
                                                kq_ev_change(h, fd, EVFILT_READ, EV_DELETE, 0);
                                        }
+                                       goto error;
                                }
-                               goto error;
                        }
                        break;
 #endif