From 63d991b7cf229a713d0d72b51dcb7b52691d7d65 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 22 Apr 2018 14:07:50 -0400 Subject: deps: upgrade to libuv 1.20.2 PR-URL: https://github.com/nodejs/node/pull/20129 Fixes: https://github.com/nodejs/node/issues/20112 Fixes: https://github.com/nodejs/node/issues/19903 Reviewed-By: Myles Borins Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau --- deps/uv/src/unix/pipe.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'deps/uv/src/unix/pipe.c') diff --git a/deps/uv/src/unix/pipe.c b/deps/uv/src/unix/pipe.c index e640bf29fc..2c578dcb35 100644 --- a/deps/uv/src/unix/pipe.c +++ b/deps/uv/src/unix/pipe.c @@ -319,21 +319,6 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) { mode != (UV_WRITABLE | UV_READABLE)) return UV_EINVAL; - if (fstat(uv__stream_fd(handle), &pipe_stat) == -1) - return UV__ERR(errno); - - desired_mode = 0; - if (mode & UV_READABLE) - desired_mode |= S_IRUSR | S_IRGRP | S_IROTH; - if (mode & UV_WRITABLE) - desired_mode |= S_IWUSR | S_IWGRP | S_IWOTH; - - /* Exit early if pipe already has desired mode. */ - if ((pipe_stat.st_mode & desired_mode) == desired_mode) - return 0; - - pipe_stat.st_mode |= desired_mode; - /* Unfortunately fchmod does not work on all platforms, we will use chmod. */ name_len = 0; r = uv_pipe_getsockname(handle, NULL, &name_len); @@ -350,6 +335,26 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) { return r; } + /* stat must be used as fstat has a bug on Darwin */ + if (stat(name_buffer, &pipe_stat) == -1) { + uv__free(name_buffer); + return -errno; + } + + desired_mode = 0; + if (mode & UV_READABLE) + desired_mode |= S_IRUSR | S_IRGRP | S_IROTH; + if (mode & UV_WRITABLE) + desired_mode |= S_IWUSR | S_IWGRP | S_IWOTH; + + /* Exit early if pipe already has desired mode. */ + if ((pipe_stat.st_mode & desired_mode) == desired_mode) { + uv__free(name_buffer); + return 0; + } + + pipe_stat.st_mode |= desired_mode; + r = chmod(name_buffer, pipe_stat.st_mode); uv__free(name_buffer); -- cgit v1.2.3