Skip to content

Commit d798da4

Browse files
committed
src: add UV_PIPE_NO_TRUNCATE for bind in pipe_wrap.cc
1 parent 4e9ce7c commit d798da4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

doc/api/net.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ sockets on other operating systems.
2929
[`socket.connect()`][] take a `path` parameter to identify IPC endpoints.
3030

3131
On Unix, the local domain is also known as the Unix domain. The path is a
32-
file system pathname. It gets truncated to an OS-dependent length of
33-
`sizeof(sockaddr_un.sun_path) - 1`. Typical values are 107 bytes on Linux and
34-
103 bytes on macOS. If a Node.js API abstraction creates the Unix domain socket,
35-
it will unlink the Unix domain socket as well. For example,
36-
[`net.createServer()`][] may create a Unix domain socket and
32+
file system pathname. It will throw an error when the length of pathname is
33+
greater than the length of `sizeof(sockaddr_un.sun_path)`. Typical values are
34+
107 bytes on Linux and 103 bytes on macOS. If a Node.js API abstraction creates
35+
the Unix domain socket, it will unlink the Unix domain socket as well. For
36+
example, [`net.createServer()`][] may create a Unix domain socket and
3737
[`server.close()`][] will unlink it. But if a user creates the Unix domain
3838
socket outside of these abstractions, the user will need to remove it. The same
3939
applies when a Node.js API creates a Unix domain socket but the program then

src/pipe_wrap.cc

+8-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ void PipeWrap::Bind(const FunctionCallbackInfo<Value>& args) {
162162
PipeWrap* wrap;
163163
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
164164
node::Utf8Value name(args.GetIsolate(), args[0]);
165-
int err = uv_pipe_bind2(&wrap->handle_, *name, name.length(), 0);
165+
int err =
166+
uv_pipe_bind2(&wrap->handle_, *name, name.length(), UV_PIPE_NO_TRUNCATE);
166167
args.GetReturnValue().Set(err);
167168
}
168169

@@ -225,8 +226,12 @@ void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
225226

226227
ConnectWrap* req_wrap =
227228
new ConnectWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPECONNECTWRAP);
228-
int err = req_wrap->Dispatch(
229-
uv_pipe_connect2, &wrap->handle_, *name, name.length(), 0, AfterConnect);
229+
int err = req_wrap->Dispatch(uv_pipe_connect2,
230+
&wrap->handle_,
231+
*name,
232+
name.length(),
233+
UV_PIPE_NO_TRUNCATE,
234+
AfterConnect);
230235
if (err) {
231236
delete req_wrap;
232237
} else {

0 commit comments

Comments
 (0)