diff options
author | root <root> | 2007-12-12 05:11:56 +0000 |
---|---|---|
committer | root <root> | 2007-12-12 05:11:56 +0000 |
commit | 1ae67bd246932c3faa0d45fdfd0469a7a46473bd (patch) | |
tree | df3e26074f7c57c97c258969030660ac1bfa15e2 | |
parent | 363b337b90b2575d2cc5253af2ffe6afa0d3eb72 (diff) |
remember wether the fd was new or not
-rw-r--r-- | ev.c | 24 | ||||
-rw-r--r-- | ev.h | 3 |
2 files changed, 15 insertions, 12 deletions
@@ -559,16 +559,17 @@ fd_reify (EV_P) } void inline_size -fd_change (EV_P_ int fd) +fd_change (EV_P_ int fd, int flags) { - if (expect_false (anfds [fd].reify)) - return; - - anfds [fd].reify = 1; + unsigned char reify = anfds [fd].reify; + anfds [fd].reify |= flags | 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 @@ -629,7 +630,7 @@ fd_rearm_all (EV_P) if (anfds [fd].events) { anfds [fd].events = 0; - fd_change (EV_A_ fd); + fd_change (EV_A_ fd, EV_IOFDSET); } } @@ -1601,7 +1602,8 @@ ev_io_start (EV_P_ ev_io *w) array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init); wlist_add (&anfds[fd].head, (WL)w); - fd_change (EV_A_ fd); + fd_change (EV_A_ fd, w->events & EV_IOFDSET); + w->events &= ~ EV_IOFDSET; } void noinline @@ -1616,7 +1618,7 @@ ev_io_stop (EV_P_ ev_io *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, 0); } void noinline @@ -99,6 +99,7 @@ struct ev_loop; #define EV_NONE 0x00L /* no events */ #define EV_READ 0x01L /* ev_io detected read will not block */ #define EV_WRITE 0x02L /* ev_io detected write will not block */ +#define EV_IOFDSET 0x80L /* internal use only */ #define EV_TIMEOUT 0x00000100L /* timer timed out */ #define EV_PERIODIC 0x00000200L /* periodic timer timed out */ #define EV_SIGNAL 0x00000400L /* signal was received */ @@ -432,7 +433,7 @@ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revent ev_set_cb ((ev), cb_); \ } while (0) -#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_); } while (0) +#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_) | EV_IOFDSET; } while (0) #define ev_timer_set(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); } while (0) #define ev_periodic_set(ev,ofs_,ival_,res_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb= (res_); } while (0) #define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0) |