X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/228b0b302ab0857b23efad5a8b2429de2c0ccc00..d5b686568688adf526735190000d81a260db6c36:/ev_select.c diff --git a/ev_select.c b/ev_select.c index 05dc30a..9f81e55 100644 --- a/ev_select.c +++ b/ev_select.c @@ -48,6 +48,9 @@ select_modify (EV_P_ int fd, int oev, int nev) int offs = fd >> 3; int mask = 1 << (fd & 7); + if (oev == nev) + return; + if (vec_max < (fd >> 5) + 1) { int new_max = (fd >> 5) + 1; @@ -107,7 +110,7 @@ select_poll (EV_P_ ev_tstamp timeout) events |= byte_w & (1 << bit) ? EV_WRITE : 0; if (events) - fd_event (idx * 8 + bit, events); + fd_event (EV_A_ idx * 8 + bit, events); } } } @@ -115,9 +118,9 @@ select_poll (EV_P_ ev_tstamp timeout) else if (res < 0) { if (errno == EBADF) - fd_ebadf (); + fd_ebadf (EV_A); else if (errno == ENOMEM) - fd_enomem (); + fd_enomem (EV_A); } } @@ -128,6 +131,22 @@ select_init (EV_P_ int flags) method_modify = select_modify; method_poll = select_poll; + vec_max = 0; + vec_ri = 0; + vec_ri = 0; + vec_wo = 0; + vec_wo = 0; + return EVMETHOD_SELECT; } +static void +select_destroy (EV_P) +{ + free (vec_ri); + free (vec_ro); + free (vec_wi); + free (vec_wo); +} + +