src: pipe init ex for unix

This commit is contained in:
reito 2025-02-04 16:03:11 +08:00
parent f7c8cd1438
commit b6aa56af10
2 changed files with 8 additions and 0 deletions

View File

@ -870,6 +870,7 @@ enum uv_pipe_init_flags {
/*
* Use Unix Domain Socket instead of NamedPipe on Windows. Will validate
* the `name` as a file path when calling bind / connect if this flag is set.
* On non-Windows platform this flag is ignored.
*/
UV_PIPE_INIT_WIN_UDS = 1u << 1,
};

View File

@ -44,6 +44,13 @@ static int includes_nul(const char *s, size_t n) {
int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
return uv_pipe_init_ex(loop, handle, ipc ? UV_PIPE_INIT_IPC : 0);
}
int uv_pipe_init_ex(uv_loop_t* loop, uv_pipe_t* handle, unsigned int flags) {
int ipc = (flags & UV_PIPE_INIT_IPC) != 0;
uv__stream_init(loop, (uv_stream_t*)handle, UV_NAMED_PIPE);
handle->shutdown_req = NULL;
handle->connect_req = NULL;