From b055538d09f54d43bf0d26a478bc5085cd52e143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 26 Feb 2014 00:03:30 +0100 Subject: [PATCH] unix, windows: clarify what uv_stream_set_blocking does Also replace the assert with an error on unix. --- include/uv.h | 6 +----- src/unix/stream.c | 4 +--- src/win/stream.c | 3 +++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/include/uv.h b/include/uv.h index 607f5c88..49c2a43e 100644 --- a/include/uv.h +++ b/include/uv.h @@ -749,11 +749,7 @@ UV_EXTERN int uv_is_writable(const uv_stream_t* handle); * Relying too much on this API is not recommended. It is likely to change * significantly in the future. * - * On windows this currently works only for uv_pipe_t instances. On unix it - * works for tcp, pipe and tty instances. Be aware that changing the blocking - * mode on unix sets or clears the O_NONBLOCK bit. If you are sharing a handle - * with another process, the other process is affected by the change too, - * which can lead to unexpected results. + * Currently this only works on Windows and only for uv_pipe_t handles. * * Also libuv currently makes no ordering guarantee when the blocking mode * is changed after write requests have already been submitted. Therefore it is diff --git a/src/unix/stream.c b/src/unix/stream.c index 4ed99189..ad6856b4 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -1511,7 +1511,5 @@ void uv__stream_close(uv_stream_t* handle) { int uv_stream_set_blocking(uv_stream_t* handle, int blocking) { - assert(0 && "implement me"); - abort(); - return 0; + return UV_ENOSYS; } diff --git a/src/win/stream.c b/src/win/stream.c index 2eaa74e7..893a44e8 100644 --- a/src/win/stream.c +++ b/src/win/stream.c @@ -244,6 +244,9 @@ int uv_is_writable(const uv_stream_t* handle) { int uv_stream_set_blocking(uv_stream_t* handle, int blocking) { + if (stream->type != UV_NAMED_PIPE) + return UV_EINVAL; + if (blocking != 0) handle->flags |= UV_HANDLE_BLOCKING_WRITES; else