From 668d24d88e9ad734c2bda5e29452b1b4d4e746ce Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Tue, 1 Nov 2016 23:09:14 +0100 Subject: [PATCH] unix: use uv__is_closing everywhere PR-URL: https://github.com/libuv/libuv/pull/1117 Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis --- src/unix/core.c | 2 +- src/unix/poll.c | 4 ++-- src/unix/signal.c | 4 ++-- src/unix/stream.c | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/unix/core.c b/src/unix/core.c index a2c07e6a..6283ed3e 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -98,7 +98,7 @@ uint64_t uv_hrtime(void) { void uv_close(uv_handle_t* handle, uv_close_cb close_cb) { - assert(!(handle->flags & (UV_CLOSING | UV_CLOSED))); + assert(!uv__is_closing(handle)); handle->flags |= UV_CLOSING; handle->close_cb = close_cb; diff --git a/src/unix/poll.c b/src/unix/poll.c index 4c0d478e..370994bd 100644 --- a/src/unix/poll.c +++ b/src/unix/poll.c @@ -92,7 +92,7 @@ static void uv__poll_stop(uv_poll_t* handle) { int uv_poll_stop(uv_poll_t* handle) { - assert(!(handle->flags & (UV_CLOSING | UV_CLOSED))); + assert(!uv__is_closing(handle)); uv__poll_stop(handle); return 0; } @@ -102,7 +102,7 @@ int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) { int events; assert((pevents & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT)) == 0); - assert(!(handle->flags & (UV_CLOSING | UV_CLOSED))); + assert(!uv__is_closing(handle)); uv__poll_stop(handle); diff --git a/src/unix/signal.c b/src/unix/signal.c index ccc1847a..dbd8f864 100644 --- a/src/unix/signal.c +++ b/src/unix/signal.c @@ -290,7 +290,7 @@ int uv_signal_start(uv_signal_t* handle, uv_signal_cb signal_cb, int signum) { sigset_t saved_sigmask; int err; - assert(!(handle->flags & (UV_CLOSING | UV_CLOSED))); + assert(!uv__is_closing(handle)); /* If the user supplies signum == 0, then return an error already. If the * signum is otherwise invalid then uv__signal_register will find out @@ -434,7 +434,7 @@ static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) { int uv_signal_stop(uv_signal_t* handle) { - assert(!(handle->flags & (UV_CLOSING | UV_CLOSED))); + assert(!uv__is_closing(handle)); uv__signal_stop(handle); return 0; } diff --git a/src/unix/stream.c b/src/unix/stream.c index d20d0bcb..86f4eb7a 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -1221,8 +1221,7 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) { if (!(stream->flags & UV_STREAM_WRITABLE) || stream->flags & UV_STREAM_SHUT || stream->flags & UV_STREAM_SHUTTING || - stream->flags & UV_CLOSED || - stream->flags & UV_CLOSING) { + uv__is_closing(stream)) { return -ENOTCONN; }