--- libev/ev_poll.c 2019/06/20 22:44:59 1.41 +++ libev/ev_poll.c 2019/08/17 05:30:16 1.48 @@ -41,10 +41,12 @@ inline_size void -pollidx_init (int *base, int count) +array_needsize_pollidx (int *base, int offset, int count) { - /* consider using memset (.., -1, ...), which is practically guaranteed - * to work on all systems implementing poll */ + /* using memset (.., -1, ...) is tempting, we we try + * to be ultraportable + */ + base += offset; while (count--) *base++ = -1; } @@ -57,7 +59,7 @@ if (oev == nev) return; - array_needsize (int, pollidxs, pollidxmax, fd + 1, pollidx_init); + array_needsize (int, pollidxs, pollidxmax, fd + 1, array_needsize_pollidx); idx = pollidxs [fd]; @@ -78,7 +80,7 @@ { pollidxs [fd] = -1; - if (expect_true (idx < --pollcnt)) + if (ecb_expect_true (idx < --pollcnt)) { polls [idx] = polls [pollcnt]; pollidxs [polls [idx].fd] = idx; @@ -93,10 +95,10 @@ int res; EV_RELEASE_CB; - res = poll (polls, pollcnt, timeout * 1e3); + res = poll (polls, pollcnt, EV_TS_TO_MSEC (timeout)); EV_ACQUIRE_CB; - if (expect_false (res < 0)) + if (ecb_expect_false (res < 0)) { if (errno == EBADF) fd_ebadf (EV_A); @@ -108,14 +110,17 @@ else for (p = polls; res; ++p) { - assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt)); + assert (("libev: poll returned illegal result, broken BSD kernel?", p < polls + pollcnt)); - if (expect_false (p->revents)) /* this expect is debatable */ + if (ecb_expect_false (p->revents)) /* this expect is debatable */ { --res; - if (expect_false (p->revents & POLLNVAL)) - fd_kill (EV_A_ p->fd); + if (ecb_expect_false (p->revents & POLLNVAL)) + { + assert (("libev: poll found invalid fd in poll set", 0)); + fd_kill (EV_A_ p->fd); + } else fd_event ( EV_A_ @@ -131,7 +136,7 @@ int poll_init (EV_P_ int flags) { - backend_mintime = 1e-3; + backend_mintime = EV_TS_CONST (1e-3); backend_modify = poll_modify; backend_poll = poll_poll;