summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2017-11-10 12:15:10 -0500
committercjihrig <cjihrig@gmail.com>2017-11-10 13:32:42 -0500
commit766cd1f59d5adb03953656391e63b4186c9aff10 (patch)
treebbcbb6ac69913e6fa60c971f68d62b090906719f /deps/uv/src/unix
parent6f02da255f803719cda330f69213ad9a11ef4b04 (diff)
downloadandroid-node-v8-766cd1f59d5adb03953656391e63b4186c9aff10.tar.gz
android-node-v8-766cd1f59d5adb03953656391e63b4186c9aff10.tar.bz2
android-node-v8-766cd1f59d5adb03953656391e63b4186c9aff10.zip
deps: upgrade libuv to 1.16.1
PR-URL: https://github.com/nodejs/node/pull/16835 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/uv/src/unix')
-rw-r--r--deps/uv/src/unix/core.c5
-rw-r--r--deps/uv/src/unix/fs.c27
-rw-r--r--deps/uv/src/unix/getaddrinfo.c30
-rw-r--r--deps/uv/src/unix/kqueue.c1
-rw-r--r--deps/uv/src/unix/loop.c2
-rw-r--r--deps/uv/src/unix/os390-syscalls.c31
-rw-r--r--deps/uv/src/unix/pipe.c53
7 files changed, 137 insertions, 12 deletions
diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c
index ef82ee27b8..d64593a313 100644
--- a/deps/uv/src/unix/core.c
+++ b/deps/uv/src/unix/core.c
@@ -1343,3 +1343,8 @@ int uv_os_gethostname(char* buffer, size_t* size) {
uv_os_fd_t uv_get_osfhandle(int fd) {
return fd;
}
+
+
+uv_pid_t uv_os_getppid(void) {
+ return getppid();
+}
diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c
index 2684c814a2..e0969a4c2f 100644
--- a/deps/uv/src/unix/fs.c
+++ b/deps/uv/src/unix/fs.c
@@ -132,26 +132,33 @@
while (0)
-static ssize_t uv__fs_fdatasync(uv_fs_t* req) {
-#if defined(__linux__) || defined(__sun) || defined(__NetBSD__)
- return fdatasync(req->file);
-#elif defined(__APPLE__)
+static ssize_t uv__fs_fsync(uv_fs_t* req) {
+#if defined(__APPLE__)
/* Apple's fdatasync and fsync explicitly do NOT flush the drive write cache
* to the drive platters. This is in contrast to Linux's fdatasync and fsync
* which do, according to recent man pages. F_FULLFSYNC is Apple's equivalent
- * for flushing buffered data to permanent storage.
+ * for flushing buffered data to permanent storage. If F_FULLFSYNC is not
+ * supported by the file system we should fall back to fsync(). This is the
+ * same approach taken by sqlite.
*/
- return fcntl(req->file, F_FULLFSYNC);
+ int r;
+
+ r = fcntl(req->file, F_FULLFSYNC);
+ if (r != 0 && errno == ENOTTY)
+ r = fsync(req->file);
+ return r;
#else
return fsync(req->file);
#endif
}
-static ssize_t uv__fs_fsync(uv_fs_t* req) {
-#if defined(__APPLE__)
- /* See the comment in uv__fs_fdatasync. */
- return fcntl(req->file, F_FULLFSYNC);
+static ssize_t uv__fs_fdatasync(uv_fs_t* req) {
+#if defined(__linux__) || defined(__sun) || defined(__NetBSD__)
+ return fdatasync(req->file);
+#elif defined(__APPLE__)
+ /* See the comment in uv__fs_fsync. */
+ return uv__fs_fsync(req);
#else
return fsync(req->file);
#endif
diff --git a/deps/uv/src/unix/getaddrinfo.c b/deps/uv/src/unix/getaddrinfo.c
index 2049aea2f3..0185971697 100644
--- a/deps/uv/src/unix/getaddrinfo.c
+++ b/deps/uv/src/unix/getaddrinfo.c
@@ -32,6 +32,7 @@
#include <stddef.h> /* NULL */
#include <stdlib.h>
#include <string.h>
+#include <net/if.h> /* if_indextoname() */
/* EAI_* constants. */
#include <netdb.h>
@@ -200,3 +201,32 @@ void uv_freeaddrinfo(struct addrinfo* ai) {
if (ai)
freeaddrinfo(ai);
}
+
+
+int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size) {
+ char ifname_buf[UV_IF_NAMESIZE];
+ size_t len;
+
+ if (buffer == NULL || size == NULL || *size == 0)
+ return UV_EINVAL;
+
+ if (if_indextoname(ifindex, ifname_buf) == NULL)
+ return -errno;
+
+ len = strnlen(ifname_buf, sizeof(ifname_buf));
+
+ if (*size <= len) {
+ *size = len + 1;
+ return UV_ENOBUFS;
+ }
+
+ memcpy(buffer, ifname_buf, len);
+ buffer[len] = '\0';
+ *size = len;
+
+ return 0;
+}
+
+int uv_if_indextoiid(unsigned int ifindex, char* buffer, size_t* size) {
+ return uv_if_indextoname(ifindex, buffer, size);
+}
diff --git a/deps/uv/src/unix/kqueue.c b/deps/uv/src/unix/kqueue.c
index c9adddbdb8..5e89bdced4 100644
--- a/deps/uv/src/unix/kqueue.c
+++ b/deps/uv/src/unix/kqueue.c
@@ -65,7 +65,6 @@ static int uv__has_forked_with_cfrunloop;
int uv__io_fork(uv_loop_t* loop) {
int err;
- uv__close(loop->backend_fd);
loop->backend_fd = -1;
err = uv__kqueue_init(loop);
if (err)
diff --git a/deps/uv/src/unix/loop.c b/deps/uv/src/unix/loop.c
index bcd49242ce..5b5b0e095b 100644
--- a/deps/uv/src/unix/loop.c
+++ b/deps/uv/src/unix/loop.c
@@ -31,7 +31,6 @@ int uv_loop_init(uv_loop_t* loop) {
void* saved_data;
int err;
- uv__signal_global_once_init();
saved_data = loop->data;
memset(loop, 0, sizeof(*loop));
@@ -68,6 +67,7 @@ int uv_loop_init(uv_loop_t* loop) {
if (err)
return err;
+ uv__signal_global_once_init();
err = uv_signal_init(loop, &loop->child_watcher);
if (err)
goto fail_signal_init;
diff --git a/deps/uv/src/unix/os390-syscalls.c b/deps/uv/src/unix/os390-syscalls.c
index ca539c26f7..86c6852b4b 100644
--- a/deps/uv/src/unix/os390-syscalls.c
+++ b/deps/uv/src/unix/os390-syscalls.c
@@ -120,10 +120,41 @@ static void maybe_resize(uv__os390_epoll* lst, unsigned int len) {
}
+static void before_fork(void) {
+ uv_mutex_lock(&global_epoll_lock);
+}
+
+
+static void after_fork(void) {
+ uv_mutex_unlock(&global_epoll_lock);
+}
+
+
+static void child_fork(void) {
+ QUEUE* q;
+ uv_once_t child_once = UV_ONCE_INIT;
+
+ /* reset once */
+ memcpy(&once, &child_once, sizeof(child_once));
+
+ /* reset epoll list */
+ while (!QUEUE_EMPTY(&global_epoll_queue)) {
+ q = QUEUE_HEAD(&global_epoll_queue);
+ QUEUE_REMOVE(q);
+ }
+
+ uv_mutex_unlock(&global_epoll_lock);
+ uv_mutex_destroy(&global_epoll_lock);
+}
+
+
static void epoll_init(void) {
QUEUE_INIT(&global_epoll_queue);
if (uv_mutex_init(&global_epoll_lock))
abort();
+
+ if (pthread_atfork(&before_fork, &after_fork, &child_fork))
+ abort();
}
diff --git a/deps/uv/src/unix/pipe.c b/deps/uv/src/unix/pipe.c
index 4a812955b0..ac7cfb46a9 100644
--- a/deps/uv/src/unix/pipe.c
+++ b/deps/uv/src/unix/pipe.c
@@ -302,3 +302,56 @@ uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) {
else
return uv__handle_type(handle->accepted_fd);
}
+
+
+int uv_pipe_chmod(uv_pipe_t* handle, int mode) {
+ unsigned desired_mode;
+ struct stat pipe_stat;
+ char* name_buffer;
+ size_t name_len;
+ int r;
+
+ if (handle == NULL || uv__stream_fd(handle) == -1)
+ return -EBADF;
+
+ if (mode != UV_READABLE &&
+ mode != UV_WRITABLE &&
+ mode != (UV_WRITABLE | UV_READABLE))
+ return -EINVAL;
+
+ if (fstat(uv__stream_fd(handle), &pipe_stat) == -1)
+ 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)
+ 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);
+ if (r != UV_ENOBUFS)
+ return r;
+
+ name_buffer = uv__malloc(name_len);
+ if (name_buffer == NULL)
+ return UV_ENOMEM;
+
+ r = uv_pipe_getsockname(handle, name_buffer, &name_len);
+ if (r != 0) {
+ uv__free(name_buffer);
+ return r;
+ }
+
+ r = chmod(name_buffer, pipe_stat.st_mode);
+ uv__free(name_buffer);
+
+ return r != -1 ? 0 : -errno;
+}