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.
This commit is contained in:
parent
9a8db3c0cb
commit
1d64c8284d
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user