From e37a2a0d53b40c753ad8f040c40f72ff6f7a291f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 11 Dec 2014 09:30:18 +0100 Subject: [PATCH] unix, windows: don't treat uv_run_mode as a bitmask The modes are not meant to be combined, and doing so may hide problems in the future. PR-URL: https://github.com/libuv/libuv/pull/58 Reviewed-By: Bert Belder Reviewed-By: Ben Noordhuis --- src/unix/core.c | 5 ++--- src/win/core.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/unix/core.c b/src/unix/core.c index 44995b22..10f6f70b 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -317,7 +317,7 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) { uv__run_prepare(loop); timeout = 0; - if ((mode & UV_RUN_NOWAIT) == 0) + if (mode != UV_RUN_NOWAIT) timeout = uv_backend_timeout(loop); uv__io_poll(loop, timeout); @@ -338,8 +338,7 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) { } r = uv__loop_alive(loop); - - if (mode & (UV_RUN_ONCE | UV_RUN_NOWAIT)) + if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT) break; } diff --git a/src/win/core.c b/src/win/core.c index 48897cf2..23d6561c 100644 --- a/src/win/core.c +++ b/src/win/core.c @@ -407,7 +407,7 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) { uv_prepare_invoke(loop); timeout = 0; - if ((mode & UV_RUN_NOWAIT) == 0) + if (mode != UV_RUN_NOWAIT) timeout = uv_backend_timeout(loop); (*poll)(loop, timeout); @@ -428,7 +428,7 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) { } r = uv__loop_alive(loop); - if (mode & (UV_RUN_ONCE | UV_RUN_NOWAIT)) + if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT) break; }