Skip to content

Commit

Permalink
src: handle errors from uv_pipe_connect2()
Browse files Browse the repository at this point in the history
We need to handle errors from uv_pipe_connect2()
because return type is `int`.

Fixes: nodejs#50652
Refs: nodejs#49667
Refs: libuv/libuv#4030
  • Loading branch information
deokjinkim committed Nov 10, 2023
1 parent b4850f2 commit 76acb04
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/pipe_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,19 @@ void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {

ConnectWrap* req_wrap =
new ConnectWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPECONNECTWRAP);
req_wrap->Dispatch(
int err = req_wrap->Dispatch(
uv_pipe_connect2, &wrap->handle_, *name, name.length(), 0, AfterConnect);
if (err) {
delete req_wrap;
} else {
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE2(net, native),
"connect",
req_wrap,
"pipe_path",
TRACE_STR_COPY(*name));
}

TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE2(net, native),
"connect",
req_wrap,
"pipe_path",
TRACE_STR_COPY(*name));

args.GetReturnValue().Set(0); // uv_pipe_connect() doesn't return errors.
args.GetReturnValue().Set(err);
}

} // namespace node
Expand Down

0 comments on commit 76acb04

Please sign in to comment.