- for (i = 0; i < eventcnt; ++i)
- event (events [i], type);
+ for (i = 0; i < fdchangecnt; ++i)
+ {
+ int fd = fdchanges [i];
+ ANFD *anfd = anfds + fd;
+ struct ev_io *w;
+
+ int events = 0;
+
+ for (w = anfd->head; w; w = w->next)
+ events |= w->events;
+
+ anfd->reify = 0;
+
+ if (anfd->events != events)
+ {
+ method_modify (fd, anfd->events, events);
+ anfd->events = events;
+ }
+ }
+
+ fdchangecnt = 0;
+}
+
+static void
+fd_change (int fd)
+{
+ if (anfds [fd].reify || fdchangecnt < 0)
+ return;
+
+ anfds [fd].reify = 1;
+
+ ++fdchangecnt;
+ array_needsize (fdchanges, fdchangemax, fdchangecnt, );
+ fdchanges [fdchangecnt - 1] = fd;
+}
+
+/* called on EBADF to verify fds */
+static void
+fd_recheck (void)
+{
+ int fd;
+
+ for (fd = 0; fd < anfdmax; ++fd)
+ if (anfds [fd].events)
+ if (fcntl (fd, F_GETFD) == -1 && errno == EBADF)
+ while (anfds [fd].head)
+ {
+ ev_io_stop (anfds [fd].head);
+ event ((W)anfds [fd].head, EV_ERROR | EV_READ | EV_WRITE);
+ }