From 1d64c8284d373da9dc8652d71cd9a3f904915739 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 21 Feb 2013 10:29:16 +0100 Subject: [PATCH] unix: use uv__set_artificial_error in uv_write2 * Use uv__set_artificial_error(), slightly more efficient than uv__set_sys_error(). * Return UV_EINVAL instead of UV_EOPNOTSUPP. * Fix up style. --- src/unix/stream.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/unix/stream.c b/src/unix/stream.c index 4ce324074..ff420db23 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -1188,19 +1188,20 @@ int uv_write2(uv_write_t* req, int empty_queue; assert(bufcnt > 0); - - assert((stream->type == UV_TCP || stream->type == UV_NAMED_PIPE || - stream->type == UV_TTY) && - "uv_write (unix) does not yet support other types of streams"); + assert((stream->type == UV_TCP || + stream->type == UV_NAMED_PIPE || + stream->type == UV_TTY) && + "uv_write (unix) does not yet support other types of streams"); if (uv__stream_fd(stream) < 0) - return uv__set_sys_error(stream->loop, EBADF); + return uv__set_artificial_error(stream->loop, UV_EBADF); if (send_handle) { if (stream->type != UV_NAMED_PIPE || !((uv_pipe_t*)stream)->ipc) - return uv__set_sys_error(stream->loop, EOPNOTSUPP); + return uv__set_artificial_error(stream->loop, UV_EINVAL); + if (uv__stream_fd(send_handle) < 0) - return uv__set_sys_error(stream->loop, EBADF); + return uv__set_artificial_error(stream->loop, UV_EBADF); } empty_queue = (stream->write_queue_size == 0);