Browse code

io_wait: fix kqueue io_wait_add & POLLIN

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.

Andrei Pelinescu-Onciul authored on 18/06/2010 22:35:47
Showing 1 changed files
... ...
@@ -499,7 +499,7 @@ again2:
499 499
 		case POLL_KQUEUE:
500 500
 			if (likely( events & POLLIN)){
501 501
 				if (unlikely(kq_ev_change(h, fd, EVFILT_READ, EV_ADD, e)==-1))
502
-				goto error;
502
+					goto error;
503 503
 			}
504 504
 			if (unlikely( events & POLLOUT)){
505 505
 				if (unlikely(kq_ev_change(h, fd, EVFILT_WRITE, EV_ADD, e)==-1))
... ...
@@ -507,8 +507,8 @@ again2:
507 507
 					if (likely(events & POLLIN)){
508 508
 						kq_ev_change(h, fd, EVFILT_READ, EV_DELETE, 0);
509 509
 					}
510
+					goto error;
510 511
 				}
511
-				goto error;
512 512
 			}
513 513
 			break;
514 514
 #endif