Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: rework uv_eio_init() init once logic
Browse files Browse the repository at this point in the history
Don't use counters.eio_init to track if libeio has been initialized, it's going
to be removed in a follow-up commit.
  • Loading branch information
bnoordhuis committed Aug 10, 2012
1 parent 75ba681 commit caa79af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/uv-private/uv-unix.h
Expand Up @@ -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; \
Expand Down
7 changes: 6 additions & 1 deletion src/unix/internal.h
Expand Up @@ -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. */
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/unix/uv-eio.c
Expand Up @@ -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);
Expand Down

0 comments on commit caa79af

Please sign in to comment.