From caa79af2ad6cc46c9ce414f6c213e3978ae6f68f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 10 Aug 2012 01:45:40 +0200 Subject: [PATCH] unix: rework uv_eio_init() init once logic Don't use counters.eio_init to track if libeio has been initialized, it's going to be removed in a follow-up commit. --- include/uv-private/uv-unix.h | 1 + src/unix/internal.h | 7 ++++++- src/unix/uv-eio.c | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/uv-private/uv-unix.h b/include/uv-private/uv-unix.h index bd3e7e36..8744f6e1 100644 --- a/include/uv-private/uv-unix.h +++ b/include/uv-private/uv-unix.h @@ -117,6 +117,7 @@ struct uv__io_s { #endif #define UV_LOOP_PRIVATE_FIELDS \ + unsigned long flags; \ /* Poll result queue */ \ eio_channel uv_eio_channel; \ struct ev_loop* ev; \ diff --git a/src/unix/internal.h b/src/unix/internal.h index fbb5d641..ede6c441 100644 --- a/src/unix/internal.h +++ b/src/unix/internal.h @@ -82,7 +82,7 @@ #define UV__IO_WRITE EV_WRITE #define UV__IO_ERROR EV_ERROR -/* flags */ +/* handle flags */ enum { UV_CLOSING = 0x01, /* uv_close() called but not finished. */ UV_CLOSED = 0x02, /* close(2) finished. */ @@ -97,6 +97,11 @@ enum { UV_TCP_SINGLE_ACCEPT = 0x400 /* Only accept() when idle. */ }; +/* loop flags */ +enum { + UV_LOOP_EIO_INITIALIZED = 1 +}; + inline static void uv__req_init(uv_loop_t* loop, uv_req_t* req, uv_req_type type) { diff --git a/src/unix/uv-eio.c b/src/unix/uv-eio.c index 0d931b88..e5ba2f27 100644 --- a/src/unix/uv-eio.c +++ b/src/unix/uv-eio.c @@ -83,8 +83,8 @@ static void uv__eio_init(void) { void uv_eio_init(uv_loop_t* loop) { - if (loop->counters.eio_init) return; - loop->counters.eio_init = 1; + if (loop->flags & UV_LOOP_EIO_INITIALIZED) return; + loop->flags |= UV_LOOP_EIO_INITIALIZED; uv_idle_init(loop, &loop->uv_eio_poller); uv_idle_start(&loop->uv_eio_poller, uv_eio_do_poll);