aboutsummaryrefslogtreecommitdiff
path: root/src/unix/stream.c
diff options
context:
space:
mode:
authortwosee <twose@qq.com>2021-05-28 22:57:59 +0800
committerGitHub <noreply@github.com>2021-05-28 10:57:59 -0400
commitbcc4f8fdde45471f30e168fe27be347076ebdf2c (patch)
treeea8f96a82ff45403f6150d095931b568f47e7629 /src/unix/stream.c
parent6085bcef8dea1eaa21a92e2b6e6f03a0476b6c54 (diff)
downloadlibuv-bcc4f8fdde45471f30e168fe27be347076ebdf2c.tar.gz
libuv-bcc4f8fdde45471f30e168fe27be347076ebdf2c.zip
stream: introduce uv_try_write2 function
`uv_try_write2(stream, bufs, nbufs, send_handle)` acts like `uv_try_write()` and extended write function for sending handles over a pipe like `uv_write2`. It always returns `UV_EAGAIN` instead of `UV_ENOSYS` on Windows so we can easily write cross-platform code without special treatment. PR-URL: https://github.com/libuv/libuv/pull/3183 Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Diffstat (limited to 'src/unix/stream.c')
-rw-r--r--src/unix/stream.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/unix/stream.c b/src/unix/stream.c
index dd1f5538..f64c01cf 100644
--- a/src/unix/stream.c
+++ b/src/unix/stream.c
@@ -1525,6 +1525,14 @@ int uv_write(uv_write_t* req,
int uv_try_write(uv_stream_t* stream,
const uv_buf_t bufs[],
unsigned int nbufs) {
+ return uv_try_write2(stream, bufs, nbufs, NULL);
+}
+
+
+int uv_try_write2(uv_stream_t* stream,
+ const uv_buf_t bufs[],
+ unsigned int nbufs,
+ uv_stream_t* send_handle) {
int err;
/* Connecting or already writing some data */
@@ -1535,7 +1543,7 @@ int uv_try_write(uv_stream_t* stream,
if (err < 0)
return err;
- return uv__try_write(stream, bufs, nbufs, NULL);
+ return uv__try_write(stream, bufs, nbufs, send_handle);
}