ANFD *anfd = anfds + fd;
ev_io *w;
- int events = 0;
+ unsigned char events = 0;
for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
- events |= w->events;
+ events |= (unsigned char)w->events;
#if EV_SELECT_IS_WINSOCKET
if (events)
}
#endif
- anfd->reify = 0;
+ {
+ unsigned char o_events = anfd->events;
+ unsigned char o_reify = anfd->reify;
+
+ anfd->reify = 0;
+ anfd->events = events;
- backend_modify (EV_A_ fd, anfd->events, events);
- anfd->events = events;
+ if (o_events != events || o_reify & EV_IOFDSET)
+ backend_modify (EV_A_ fd, o_events, events);
+ }
}
fdchangecnt = 0;
}
void inline_size
-fd_change (EV_P_ int fd)
+fd_change (EV_P_ int fd, int flags)
{
- if (expect_false (anfds [fd].reify))
- return;
+ unsigned char reify = anfds [fd].reify;
+ anfds [fd].reify |= flags;
- anfds [fd].reify = 1;
-
- ++fdchangecnt;
- array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2);
- fdchanges [fdchangecnt - 1] = fd;
+ if (expect_true (!reify))
+ {
+ ++fdchangecnt;
+ array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2);
+ fdchanges [fdchangecnt - 1] = fd;
+ }
}
void inline_speed
if (anfds [fd].events)
{
anfds [fd].events = 0;
- fd_change (EV_A_ fd);
+ fd_change (EV_A_ fd, EV_IOFDSET | 1);
}
}
/*****************************************************************************/
-static ev_child *childs [EV_PID_HASHSIZE];
+static WL childs [EV_PID_HASHSIZE];
#ifndef _WIN32
ev_start (EV_A_ (W)w, 1);
array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init);
- wlist_add ((WL *)&anfds[fd].head, (WL)w);
+ wlist_add (&anfds[fd].head, (WL)w);
- fd_change (EV_A_ fd);
+ fd_change (EV_A_ fd, w->events & EV_IOFDSET | 1);
+ w->events &= ~EV_IOFDSET;
}
void noinline
assert (("ev_io_start called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
- wlist_del ((WL *)&anfds[w->fd].head, (WL)w);
+ wlist_del (&anfds[w->fd].head, (WL)w);
ev_stop (EV_A_ (W)w);
- fd_change (EV_A_ w->fd);
+ fd_change (EV_A_ w->fd, 1);
}
void noinline
}
ev_start (EV_A_ (W)w, 1);
- wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w);
+ wlist_add (&signals [w->signum - 1].head, (WL)w);
if (!((WL)w)->next)
{
if (expect_false (!ev_is_active (w)))
return;
- wlist_del ((WL *)&signals [w->signum - 1].head, (WL)w);
+ wlist_del (&signals [w->signum - 1].head, (WL)w);
ev_stop (EV_A_ (W)w);
if (!signals [w->signum - 1].head)
return;
ev_start (EV_A_ (W)w, 1);
- wlist_add ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
+ wlist_add (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
}
void
if (expect_false (!ev_is_active (w)))
return;
- wlist_del ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
+ wlist_del (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
ev_stop (EV_A_ (W)w);
}