From 77bdfc96ae5abb60f78babcc3c244a5136d84f93 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 2 Oct 2017 19:44:44 -0400 Subject: [PATCH] deps: upgrade libuv to 1.15.0 PR-URL: https://github.com/nodejs/node/pull/15745 Refs: https://github.com/nodejs/node/pull/15380 Refs: https://github.com/nodejs/node/issues/15683 Fixes: https://github.com/nodejs/node/issues/15394 Fixes: https://github.com/nodejs/node/issues/15770 Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- deps/uv/.mailmap | 1 + deps/uv/AUTHORS | 7 ++ deps/uv/ChangeLog | 67 +++++++++++ deps/uv/appveyor.yml | 2 +- deps/uv/common.gypi | 11 +- deps/uv/configure.ac | 2 +- deps/uv/docs/src/threading.rst | 1 + deps/uv/include/uv-version.h | 4 +- deps/uv/include/uv.h | 1 + deps/uv/src/unix/android-ifaddrs.c | 8 +- deps/uv/src/unix/bsd-ifaddrs.c | 6 +- deps/uv/src/unix/core.c | 14 ++- deps/uv/src/unix/fs.c | 13 ++- deps/uv/src/unix/fsevents.c | 28 ++++- deps/uv/src/unix/internal.h | 3 +- deps/uv/src/unix/kqueue.c | 2 + deps/uv/src/unix/netbsd.c | 24 ++-- deps/uv/src/unix/os390-syscalls.c | 93 ++++++++++++++-- deps/uv/src/unix/os390-syscalls.h | 1 + deps/uv/src/unix/os390.c | 3 +- deps/uv/src/unix/stream.c | 2 +- deps/uv/src/unix/sunos.c | 1 - deps/uv/src/unix/thread.c | 75 +++++++++---- deps/uv/src/unix/tty.c | 36 ++++++ deps/uv/src/unix/udp.c | 8 +- deps/uv/src/win/error.c | 2 +- deps/uv/src/win/process.c | 7 +- deps/uv/src/win/signal.c | 2 +- deps/uv/src/win/thread.c | 5 + deps/uv/src/win/timer.c | 2 +- deps/uv/src/win/tty.c | 117 +++++++++++++------- deps/uv/src/win/util.c | 4 +- deps/uv/test/runner.c | 19 ++-- deps/uv/test/test-fs-copyfile.c | 20 +++- deps/uv/test/test-list.h | 2 + deps/uv/test/test-mutexes.c | 20 ++++ deps/uv/test/test-poll.c | 3 +- deps/uv/test/test-signal-multiple-loops.c | 1 + deps/uv/test/test-thread.c | 22 ++-- deps/uv/test/test-udp-ipv6.c | 8 +- deps/uv/test/test-udp-multicast-join6.c | 3 +- deps/uv/tools/vswhere_usability_wrapper.cmd | 10 +- deps/uv/uv.gyp | 29 ++--- deps/uv/vcbuild.bat | 2 + 44 files changed, 532 insertions(+), 159 deletions(-) diff --git a/deps/uv/.mailmap b/deps/uv/.mailmap index 896d4065bc486e..500c2b5185c5e8 100644 --- a/deps/uv/.mailmap +++ b/deps/uv/.mailmap @@ -31,6 +31,7 @@ Rasmus Christian Pedersen Robert Mustacchi Ryan Dahl Ryan Emery +Sakthipriyan Vairamani Sam Roberts San-Tai Hsu Santiago Gimeno diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 3562bb81698b66..4747c06b30600f 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -308,3 +308,10 @@ Jacob Segal Maciej Szeptuch (Neverous) Joel Winarske Gergely Nagy +Kamil Rytarowski +tux.uudiin <77389867@qq.com> +Nick Logan +darobs +Zheng, Lei +Carlo Marcelo Arenas Belón +Scott Parker diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index d0b55750172152..64b18695e16847 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,3 +1,70 @@ +2017.10.03, Version 1.15.0 (Stable), 8b69ce1419d2958011d415a636810705c36c2cc2 + +Changes since version 1.14.1: + +* unix: limit uv__has_forked_with_cfrunloop to macOS (Kamil Rytarowski) + +* win: fix buffer size in uv__getpwuid_r() (tux.uudiin) + +* win,tty: improve SIGWINCH support (Bartosz Sosnowski) + +* unix: use fchmod() in uv_fs_copyfile() (cjihrig) + +* unix: support copying empty files (cjihrig) + +* unix: truncate destination in uv_fs_copyfile() (Nick Logan) + +* win,build: keep cwd when setting build environment (darobs) + +* test: add NetBSD support to test-udp-ipv6.c (Kamil Rytarowski) + +* unix: add NetBSD support in core.c (Kamil Rytarowski) + +* linux: increase thread stack size with musl libc (Ben Noordhuis) + +* netbsd: correct uv_exepath() on NetBSD (Kamil Rytarowski) + +* test: clean up semaphore after use (jBarz) + +* win,build: bump vswhere_usability_wrapper to 2.0.0 (Refael Ackermann) + +* win: let UV_PROCESS_WINDOWS_HIDE hide consoles (cjihrig) + +* zos: lock protect global epoll list in epoll_ctl (jBarz) + +* zos: change platform name to match python (jBarz) + +* android: fix getifaddrs() (Zheng, Lei) + +* netbsd: implement uv__tty_is_slave() (Kamil Rytarowski) + +* zos: fix readlink for mounts with system variables (jBarz) + +* test: sort the tests alphabetically (Sakthipriyan Vairamani) + +* windows: fix compilation warnings (Carlo Marcelo Arenas Belón) + +* build: avoid -fstrict-aliasing compile option (jBarz) + +* win: remove unused variables (Carlo Marcelo Arenas Belón) + +* unix: remove unused variables (Sakthipriyan Vairamani) + +* netbsd: disable poll_bad_fdtype on NetBSD (Kamil Rytarowski) + +* netbsd: use uv__cloexec and uv__nonblock (Kamil Rytarowski) + +* test: fix udp_multicast_join6 on NetBSD (Kamil Rytarowski) + +* unix,win: add uv_mutex_init_recursive() (Scott Parker) + +* netbsd: do not exclude IPv6 functionality (Kamil Rytarowski) + +* fsevents: watch files with fsevents on macos 10.7+ (Ben Noordhuis) + +* unix: retry on ENOBUFS in sendmsg(2) (Kamil Rytarowski) + + 2017.09.07, Version 1.14.1 (Stable), b0f9fb2a07a5e638b1580fe9a42a356c3ab35f37 Changes since version 1.14.0: diff --git a/deps/uv/appveyor.yml b/deps/uv/appveyor.yml index 986c0d44030e5b..f519bc099b6220 100644 --- a/deps/uv/appveyor.yml +++ b/deps/uv/appveyor.yml @@ -1,4 +1,4 @@ -version: v1.14.1.build{build} +version: v1.15.0.build{build} init: - git config --global core.autocrlf true diff --git a/deps/uv/common.gypi b/deps/uv/common.gypi index ec482340c27b47..816847bfc70690 100644 --- a/deps/uv/common.gypi +++ b/deps/uv/common.gypi @@ -32,10 +32,9 @@ }, 'xcode_settings': { 'GCC_OPTIMIZATION_LEVEL': '0', - 'OTHER_CFLAGS': [ '-Wno-strict-aliasing' ], }, 'conditions': [ - ['OS != "os390"', { + ['OS != "zos"', { 'cflags': [ '-O0', '-fwrapv' ] }], ['OS == "android"', { @@ -48,7 +47,6 @@ 'defines': [ 'NDEBUG' ], 'cflags': [ '-O3', - '-fstrict-aliasing', ], 'msvs_settings': { 'VCCLCompilerTool': { @@ -80,7 +78,7 @@ }, }, 'conditions': [ - ['OS != "os390"', { + ['OS != "zos"', { 'cflags': [ '-fomit-frame-pointer', '-fdata-sections', @@ -160,7 +158,7 @@ 'cflags': [ '-pthreads' ], 'ldflags': [ '-pthreads' ], }], - [ 'OS not in "solaris android os390"', { + [ 'OS not in "solaris android zos"', { 'cflags': [ '-pthread' ], 'ldflags': [ '-pthread' ], }], @@ -178,9 +176,6 @@ 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics 'PREBINDING': 'NO', # No -Wl,-prebind 'USE_HEADERMAP': 'NO', - 'OTHER_CFLAGS': [ - '-fstrict-aliasing', - ], 'WARNING_CFLAGS': [ '-Wall', '-Wendif-labels', diff --git a/deps/uv/configure.ac b/deps/uv/configure.ac index 41349a092c85e6..ebf5bc3d8ef9e5 100644 --- a/deps/uv/configure.ac +++ b/deps/uv/configure.ac @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_PREREQ(2.57) -AC_INIT([libuv], [1.14.1], [https://github.com/libuv/libuv/issues]) +AC_INIT([libuv], [1.15.0], [https://github.com/libuv/libuv/issues]) AC_CONFIG_MACRO_DIR([m4]) m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/as_case.m4]) diff --git a/deps/uv/docs/src/threading.rst b/deps/uv/docs/src/threading.rst index e876dde1256d1a..bca8ba1d0636f4 100644 --- a/deps/uv/docs/src/threading.rst +++ b/deps/uv/docs/src/threading.rst @@ -91,6 +91,7 @@ Functions return 0 on success or an error code < 0 (unless the return type is void, of course). .. c:function:: int uv_mutex_init(uv_mutex_t* handle) +.. c:function:: int uv_mutex_init_recursive(uv_mutex_t* handle) .. c:function:: void uv_mutex_destroy(uv_mutex_t* handle) .. c:function:: void uv_mutex_lock(uv_mutex_t* handle) .. c:function:: int uv_mutex_trylock(uv_mutex_t* handle) diff --git a/deps/uv/include/uv-version.h b/deps/uv/include/uv-version.h index 9b891499eb5f4a..55d7c91055c3ea 100644 --- a/deps/uv/include/uv-version.h +++ b/deps/uv/include/uv-version.h @@ -31,8 +31,8 @@ */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 14 -#define UV_VERSION_PATCH 1 +#define UV_VERSION_MINOR 15 +#define UV_VERSION_PATCH 0 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index eac63dde445829..0e4151d1389582 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -1424,6 +1424,7 @@ UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); +UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle); UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); diff --git a/deps/uv/src/unix/android-ifaddrs.c b/deps/uv/src/unix/android-ifaddrs.c index 1a842ced48f9b5..bf30b14179509d 100644 --- a/deps/uv/src/unix/android-ifaddrs.c +++ b/deps/uv/src/unix/android-ifaddrs.c @@ -457,7 +457,7 @@ static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList, char *l_name; char *l_addr; - for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) + for(l_rta = IFA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) { size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); if(l_info->ifa_family == AF_PACKET) @@ -479,7 +479,7 @@ static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList, l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); break; case IFA_LABEL: - l_nameSize += NLMSG_ALIGN(l_rtaSize + 1); + l_nameSize += NLMSG_ALIGN(l_rtaDataSize + 1); break; default: break; @@ -504,7 +504,7 @@ static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList, } l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg)); - for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) + for(l_rta = IFA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) { void *l_rtaData = RTA_DATA(l_rta); size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); @@ -567,7 +567,7 @@ static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList, { unsigned l_maxPrefix = (l_entry->ifa_addr->sa_family == AF_INET ? 32 : 128); unsigned l_prefix = (l_info->ifa_prefixlen > l_maxPrefix ? l_maxPrefix : l_info->ifa_prefixlen); - char l_mask[16] = {0}; + unsigned char l_mask[16] = {0}; unsigned i; for(i=0; i<(l_prefix/8); ++i) { diff --git a/deps/uv/src/unix/bsd-ifaddrs.c b/deps/uv/src/unix/bsd-ifaddrs.c index ffcf156440d559..2593b9ff330e84 100644 --- a/deps/uv/src/unix/bsd-ifaddrs.c +++ b/deps/uv/src/unix/bsd-ifaddrs.c @@ -50,7 +50,11 @@ static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type) { */ if (ent->ifa_addr->sa_family == AF_LINK) return 1; -#elif defined(__NetBSD__) || defined(__OpenBSD__) +#elif defined(__NetBSD__) + if (ent->ifa_addr->sa_family != PF_INET && + ent->ifa_addr->sa_family != PF_INET6) + return 1; +#elif defined(__OpenBSD__) if (ent->ifa_addr->sa_family != PF_INET) return 1; #endif diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index bee641cb440410..ef82ee27b8568f 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -58,13 +58,19 @@ #if defined(__DragonFly__) || \ defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) + defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) # include # include # include # define UV__O_CLOEXEC O_CLOEXEC # if defined(__FreeBSD__) && __FreeBSD__ >= 10 # define uv__accept4 accept4 +# endif +# if defined(__NetBSD__) +# define uv__accept4(a, b, c, d) paccept((a), (b), (c), NULL, (d)) +# endif +# if (defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__NetBSD__) # define UV__SOCK_NONBLOCK SOCK_NONBLOCK # define UV__SOCK_CLOEXEC SOCK_CLOEXEC # endif @@ -462,7 +468,9 @@ int uv__accept(int sockfd) { assert(sockfd >= 0); while (1) { -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10) +#if defined(__linux__) || \ + (defined(__FreeBSD__) && __FreeBSD__ >= 10) || \ + defined(__NetBSD__) static int no_accept4; if (no_accept4) @@ -988,7 +996,7 @@ int uv__open_cloexec(const char* path, int flags) { int uv__dup2_cloexec(int oldfd, int newfd) { int r; -#if defined(__FreeBSD__) && __FreeBSD__ >= 10 +#if (defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__NetBSD__) r = dup3(oldfd, newfd, O_CLOEXEC); if (r == -1) return -errno; diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index 5a172cc7805171..2684c814a2b1d8 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -438,7 +438,12 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) { return -1; } +#if defined(__MVS__) + len = os390_readlink(req->path, buf, len); +#else len = readlink(req->path, buf, len); +#endif + if (len == -1) { uv__free(buf); @@ -795,6 +800,7 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) { int64_t in_offset; dstfd = -1; + err = 0; /* Open the source file. */ srcfd = uv_fs_open(NULL, &fs_req, req->path, O_RDONLY, 0, NULL); @@ -809,7 +815,7 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) { goto out; } - dst_flags = O_WRONLY | O_CREAT; + dst_flags = O_WRONLY | O_CREAT | O_TRUNC; if (req->flags & UV_FS_COPYFILE_EXCL) dst_flags |= O_EXCL; @@ -828,6 +834,11 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) { goto out; } + if (fchmod(dstfd, statsbuf.st_mode) == -1) { + err = -errno; + goto out; + } + bytes_to_send = statsbuf.st_size; in_offset = 0; while (bytes_to_send != 0) { diff --git a/deps/uv/src/unix/fsevents.c b/deps/uv/src/unix/fsevents.c index 643e233cfe9e94..38837406a66f68 100644 --- a/deps/uv/src/unix/fsevents.c +++ b/deps/uv/src/unix/fsevents.c @@ -230,6 +230,7 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, uv_loop_t* loop; uv__cf_loop_state_t* state; uv__fsevents_event_t* event; + FSEventStreamEventFlags flags; QUEUE head; loop = info; @@ -245,8 +246,10 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, /* Process and filter out events */ for (i = 0; i < numEvents; i++) { + flags = eventFlags[i]; + /* Ignore system events */ - if (eventFlags[i] & kFSEventsSystem) + if (flags & kFSEventsSystem) continue; path = paths[i]; @@ -271,6 +274,9 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, /* Ignore events with path equal to directory itself */ if (len == 0) continue; +#else + if (len == 0 && (flags & kFSEventStreamEventFlagItemIsDir)) + continue; #endif /* MAC_OS_X_VERSION_10_7 */ /* Do not emit events from subdirectories (without option set) */ @@ -291,12 +297,24 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, memset(event, 0, sizeof(*event)); memcpy(event->path, path, len + 1); + event->events = UV_RENAME; - if ((eventFlags[i] & kFSEventsModified) != 0 && - (eventFlags[i] & kFSEventsRenamed) == 0) +#ifdef MAC_OS_X_VERSION_10_7 + if (0 != (flags & kFSEventsModified) && + 0 == (flags & kFSEventsRenamed)) { + event->events = UV_CHANGE; + } +#else + if (0 != (flags & kFSEventsModified) && + 0 != (flags & kFSEventStreamEventFlagItemIsDir) && + 0 == (flags & kFSEventStreamEventFlagItemRenamed)) { event->events = UV_CHANGE; - else - event->events = UV_RENAME; + } + if (0 == (flags & kFSEventStreamEventFlagItemIsDir) && + 0 == (flags & kFSEventStreamEventFlagItemRenamed)) { + event->events = UV_CHANGE; + } +#endif /* MAC_OS_X_VERSION_10_7 */ QUEUE_INSERT_TAIL(&head, &event->member); } diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index c0898d982e9815..3df5c4c3eb8619 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -175,7 +175,8 @@ struct uv__stream_queued_fds_s { defined(__FreeBSD__) || \ defined(__FreeBSD_kernel__) || \ defined(__linux__) || \ - defined(__OpenBSD__) + defined(__OpenBSD__) || \ + defined(__NetBSD__) #define uv__cloexec uv__cloexec_ioctl #define uv__nonblock uv__nonblock_ioctl #else diff --git a/deps/uv/src/unix/kqueue.c b/deps/uv/src/unix/kqueue.c index 300bac07c3322f..c9adddbdb8722a 100644 --- a/deps/uv/src/unix/kqueue.c +++ b/deps/uv/src/unix/kqueue.c @@ -59,7 +59,9 @@ int uv__kqueue_init(uv_loop_t* loop) { } +#if defined(__APPLE__) static int uv__has_forked_with_cfrunloop; +#endif int uv__io_fork(uv_loop_t* loop) { int err; diff --git a/deps/uv/src/unix/netbsd.c b/deps/uv/src/unix/netbsd.c index c54c04df28c201..d9066349c1d623 100644 --- a/deps/uv/src/unix/netbsd.c +++ b/deps/uv/src/unix/netbsd.c @@ -66,22 +66,32 @@ void uv_loadavg(double avg[3]) { int uv_exepath(char* buffer, size_t* size) { + /* Intermediate buffer, retrieving partial path name does not work + * As of NetBSD-8(beta), vnode->path translator does not handle files + * with longer names than 31 characters. + */ + char int_buf[PATH_MAX]; + size_t int_size; int mib[4]; - size_t cb; - pid_t mypid; if (buffer == NULL || size == NULL || *size == 0) return -EINVAL; - mypid = getpid(); mib[0] = CTL_KERN; mib[1] = KERN_PROC_ARGS; - mib[2] = mypid; - mib[3] = KERN_PROC_ARGV; + mib[2] = -1; + mib[3] = KERN_PROC_PATHNAME; + int_size = ARRAY_SIZE(int_buf); - cb = *size; - if (sysctl(mib, 4, buffer, &cb, NULL, 0)) + if (sysctl(mib, 4, int_buf, &int_size, NULL, 0)) return -errno; + + /* Copy string from the intermediate buffer to outer one with appropriate + * length. + */ + strlcpy(buffer, int_buf, *size); + + /* Set new size. */ *size = strlen(buffer); return 0; diff --git a/deps/uv/src/unix/os390-syscalls.c b/deps/uv/src/unix/os390-syscalls.c index 08623f4eafa137..ca539c26f7b447 100644 --- a/deps/uv/src/unix/os390-syscalls.c +++ b/deps/uv/src/unix/os390-syscalls.c @@ -130,17 +130,17 @@ static void epoll_init(void) { uv__os390_epoll* epoll_create1(int flags) { uv__os390_epoll* lst; - uv_once(&once, epoll_init); - uv_mutex_lock(&global_epoll_lock); lst = uv__malloc(sizeof(*lst)); - if (lst == -1) - return NULL; - QUEUE_INSERT_TAIL(&global_epoll_queue, &lst->member); - uv_mutex_unlock(&global_epoll_lock); + if (lst != NULL) { + /* initialize list */ + lst->size = 0; + lst->items = NULL; + uv_once(&once, epoll_init); + uv_mutex_lock(&global_epoll_lock); + QUEUE_INSERT_TAIL(&global_epoll_queue, &lst->member); + uv_mutex_unlock(&global_epoll_lock); + } - /* initialize list */ - lst->size = 0; - lst->items = NULL; return lst; } @@ -149,8 +149,11 @@ int epoll_ctl(uv__os390_epoll* lst, int op, int fd, struct epoll_event *event) { + uv_mutex_lock(&global_epoll_lock); + if(op == EPOLL_CTL_DEL) { if (fd >= lst->size || lst->items[fd].fd == -1) { + uv_mutex_unlock(&global_epoll_lock); errno = ENOENT; return -1; } @@ -158,6 +161,7 @@ int epoll_ctl(uv__os390_epoll* lst, } else if(op == EPOLL_CTL_ADD) { maybe_resize(lst, fd + 1); if (lst->items[fd].fd != -1) { + uv_mutex_unlock(&global_epoll_lock); errno = EEXIST; return -1; } @@ -165,6 +169,7 @@ int epoll_ctl(uv__os390_epoll* lst, lst->items[fd].events = event->events; } else if(op == EPOLL_CTL_MOD) { if (fd >= lst->size || lst->items[fd].fd == -1) { + uv_mutex_unlock(&global_epoll_lock); errno = ENOENT; return -1; } @@ -172,6 +177,7 @@ int epoll_ctl(uv__os390_epoll* lst, } else abort(); + uv_mutex_unlock(&global_epoll_lock); return 0; } @@ -321,3 +327,72 @@ char* mkdtemp(char* path) { return path; } + + +ssize_t os390_readlink(const char* path, char* buf, size_t len) { + ssize_t rlen; + ssize_t vlen; + ssize_t plen; + char* delimiter; + char old_delim; + char* tmpbuf; + char realpathstr[PATH_MAX + 1]; + + tmpbuf = uv__malloc(len + 1); + if (tmpbuf == NULL) { + errno = ENOMEM; + return -1; + } + + rlen = readlink(path, tmpbuf, len); + if (rlen < 0) { + uv__free(tmpbuf); + return rlen; + } + + if (rlen < 3 || strncmp("/$", tmpbuf, 2) != 0) { + /* Straightforward readlink. */ + memcpy(buf, tmpbuf, rlen); + uv__free(tmpbuf); + return rlen; + } + + /* + * There is a parmlib variable at the beginning + * which needs interpretation. + */ + tmpbuf[rlen] = '\0'; + delimiter = strchr(tmpbuf + 2, '/'); + if (delimiter == NULL) + /* No slash at the end */ + delimiter = strchr(tmpbuf + 2, '\0'); + + /* Read real path of the variable. */ + old_delim = *delimiter; + *delimiter = '\0'; + if (realpath(tmpbuf, realpathstr) == NULL) { + uv__free(tmpbuf); + return -1; + } + + /* realpathstr is not guaranteed to end with null byte.*/ + realpathstr[PATH_MAX] = '\0'; + + /* Reset the delimiter and fill up the buffer. */ + *delimiter = old_delim; + plen = strlen(delimiter); + vlen = strlen(realpathstr); + rlen = plen + vlen; + if (rlen > len) { + uv__free(tmpbuf); + errno = ENAMETOOLONG; + return -1; + } + memcpy(buf, realpathstr, vlen); + memcpy(buf + vlen, delimiter, plen); + + /* Done using temporary buffer. */ + uv__free(tmpbuf); + + return rlen; +} diff --git a/deps/uv/src/unix/os390-syscalls.h b/deps/uv/src/unix/os390-syscalls.h index 61a7cee8396587..7aba3d27da7f9b 100644 --- a/deps/uv/src/unix/os390-syscalls.h +++ b/deps/uv/src/unix/os390-syscalls.h @@ -65,5 +65,6 @@ int scandir(const char* maindir, struct dirent*** namelist, int (*compar)(const struct dirent **, const struct dirent **)); char *mkdtemp(char* path); +ssize_t os390_readlink(const char* path, char* buf, size_t len); #endif /* UV_OS390_SYSCALL_H_ */ diff --git a/deps/uv/src/unix/os390.c b/deps/uv/src/unix/os390.c index 559970de2c3d59..127656db8789e6 100644 --- a/deps/uv/src/unix/os390.c +++ b/deps/uv/src/unix/os390.c @@ -117,7 +117,7 @@ void uv_loadavg(double avg[3]) { int uv__platform_loop_init(uv_loop_t* loop) { uv__os390_epoll* ep; - ep = epoll_create1(UV__EPOLL_CLOEXEC); + ep = epoll_create1(0); loop->ep = ep; if (ep == NULL) return -errno; @@ -386,7 +386,6 @@ int uv_uptime(double* uptime) { int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { uv_cpu_info_t* cpu_info; - int result; int idx; siv1v2 info; data_area_ptr cvt = {0}; diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index c502098dcf1b38..672a7e2d6c65f6 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -859,7 +859,7 @@ static void uv__write(uv_stream_t* stream) { } if (n < 0) { - if (errno != EAGAIN && errno != EWOULDBLOCK) { + if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENOBUFS) { err = -errno; goto error; } else if (stream->flags & UV_STREAM_BLOCKING) { diff --git a/deps/uv/src/unix/sunos.c b/deps/uv/src/unix/sunos.c index 49de5a7fcd5b1f..a72c26a01f0a65 100644 --- a/deps/uv/src/unix/sunos.c +++ b/deps/uv/src/unix/sunos.c @@ -757,7 +757,6 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { uv_interface_address_t* address; struct ifaddrs* addrs; struct ifaddrs* ent; - int i; if (getifaddrs(&addrs)) return -errno; diff --git a/deps/uv/src/unix/thread.c b/deps/uv/src/unix/thread.c index f8846225910a80..abaca295d247c3 100644 --- a/deps/uv/src/unix/thread.c +++ b/deps/uv/src/unix/thread.c @@ -145,36 +145,55 @@ int pthread_barrier_destroy(pthread_barrier_t* barrier) { #endif -int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { - int err; - pthread_attr_t* attr; -#if defined(__APPLE__) - pthread_attr_t attr_storage; +/* On MacOS, threads other than the main thread are created with a reduced + * stack size by default. Adjust to RLIMIT_STACK aligned to the page size. + * + * On Linux, threads created by musl have a much smaller stack than threads + * created by glibc (80 vs. 2048 or 4096 kB.) Follow glibc for consistency. + */ +static size_t thread_stack_size(void) { +#if defined(__APPLE__) || defined(__linux__) struct rlimit lim; -#endif - /* On OSX threads other than the main thread are created with a reduced stack - * size by default, adjust it to RLIMIT_STACK. - */ -#if defined(__APPLE__) if (getrlimit(RLIMIT_STACK, &lim)) abort(); - attr = &attr_storage; - if (pthread_attr_init(attr)) - abort(); - if (lim.rlim_cur != RLIM_INFINITY) { /* pthread_attr_setstacksize() expects page-aligned values. */ lim.rlim_cur -= lim.rlim_cur % (rlim_t) getpagesize(); - if (lim.rlim_cur >= PTHREAD_STACK_MIN) - if (pthread_attr_setstacksize(attr, lim.rlim_cur)) - abort(); + return lim.rlim_cur; } +#endif + +#if !defined(__linux__) + return 0; +#elif defined(__PPC__) || defined(__ppc__) || defined(__powerpc__) + return 4 << 20; /* glibc default. */ #else - attr = NULL; + return 2 << 20; /* glibc default. */ #endif +} + + +int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { + int err; + size_t stack_size; + pthread_attr_t* attr; + pthread_attr_t attr_storage; + + attr = NULL; + stack_size = thread_stack_size(); + + if (stack_size > 0) { + attr = &attr_storage; + + if (pthread_attr_init(attr)) + abort(); + + if (pthread_attr_setstacksize(attr, stack_size)) + abort(); + } err = pthread_create(tid, attr, (void*(*)(void*)) entry, arg); @@ -222,6 +241,25 @@ int uv_mutex_init(uv_mutex_t* mutex) { } +int uv_mutex_init_recursive(uv_mutex_t* mutex) { + pthread_mutexattr_t attr; + int err; + + if (pthread_mutexattr_init(&attr)) + abort(); + + if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) + abort(); + + err = pthread_mutex_init(mutex, &attr); + + if (pthread_mutexattr_destroy(&attr)) + abort(); + + return -err; +} + + void uv_mutex_destroy(uv_mutex_t* mutex) { if (pthread_mutex_destroy(mutex)) abort(); @@ -385,7 +423,6 @@ int uv_sem_trywait(uv_sem_t* sem) { int uv_sem_init(uv_sem_t* sem, unsigned int value) { uv_sem_t semid; - struct sembuf buf; int err; union { int val; diff --git a/deps/uv/src/unix/tty.c b/deps/uv/src/unix/tty.c index b2d37f4c2c1e5b..357f9748f65bf1 100644 --- a/deps/uv/src/unix/tty.c +++ b/deps/uv/src/unix/tty.c @@ -48,6 +48,42 @@ static int uv__tty_is_slave(const int fd) { char dummy[256]; result = ioctl(fd, TIOCPTYGNAME, &dummy) != 0; +#elif defined(__NetBSD__) + /* + * NetBSD as an extension returns with ptsname(3) and ptsname_r(3) the slave + * device name for both descriptors, the master one and slave one. + * + * Implement function to compare major device number with pts devices. + * + * The major numbers are machine-dependent, on NetBSD/amd64 they are + * respectively: + * - master tty: ptc - major 6 + * - slave tty: pts - major 5 + */ + + struct stat sb; + /* Lookup device's major for the pts driver and cache it. */ + static devmajor_t pts = NODEVMAJOR; + + if (pts == NODEVMAJOR) { + pts = getdevmajor("pts", S_IFCHR); + if (pts == NODEVMAJOR) + abort(); + } + + /* Lookup stat structure behind the file descriptor. */ + if (fstat(fd, &sb) != 0) + abort(); + + /* Assert character device. */ + if (!S_ISCHR(sb.st_mode)) + abort(); + + /* Assert valid major. */ + if (major(sb.st_rdev) == NODEVMAJOR) + abort(); + + result = (pts == major(sb.st_rdev)); #else /* Fallback to ptsname */ diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index c556325de018b3..a475bf5741634d 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -237,8 +237,10 @@ static void uv__udp_sendmsg(uv_udp_t* handle) { size = sendmsg(handle->io_watcher.fd, &h, 0); } while (size == -1 && errno == EINTR); - if (size == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) - break; + if (size == -1) { + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) + break; + } req->status = (size == -1 ? -errno : size); @@ -472,7 +474,7 @@ int uv__udp_try_send(uv_udp_t* handle, } while (size == -1 && errno == EINTR); if (size == -1) { - if (errno == EAGAIN || errno == EWOULDBLOCK) + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) return -EAGAIN; else return -errno; diff --git a/deps/uv/src/win/error.c b/deps/uv/src/win/error.c index 642d1112e11928..9b03bfef6b5d71 100644 --- a/deps/uv/src/win/error.c +++ b/deps/uv/src/win/error.c @@ -58,7 +58,7 @@ void uv_fatal_error(const int errorno, const char* syscall) { LocalFree(buf); } - *((char*)NULL) = 0xff; /* Force debug break */ + DebugBreak(); abort(); } diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c index 97b67ca529582e..764250e138c48d 100644 --- a/deps/uv/src/win/process.c +++ b/deps/uv/src/win/process.c @@ -1058,15 +1058,18 @@ int uv_spawn(uv_loop_t* loop, startup.hStdOutput = uv__stdio_handle(process->child_stdio_buffer, 1); startup.hStdError = uv__stdio_handle(process->child_stdio_buffer, 2); + process_flags = CREATE_UNICODE_ENVIRONMENT; + if (options->flags & UV_PROCESS_WINDOWS_HIDE) { /* Use SW_HIDE to avoid any potential process window. */ startup.wShowWindow = SW_HIDE; + + /* Hide console windows. */ + process_flags |= CREATE_NO_WINDOW; } else { startup.wShowWindow = SW_SHOWDEFAULT; } - process_flags = CREATE_UNICODE_ENVIRONMENT; - if (options->flags & UV_PROCESS_DETACHED) { /* Note that we're not setting the CREATE_BREAKAWAY_FROM_JOB flag. That * means that libuv might not let you create a fully daemonized process diff --git a/deps/uv/src/win/signal.c b/deps/uv/src/win/signal.c index 7b42dd99280a00..a174da1f760d62 100644 --- a/deps/uv/src/win/signal.c +++ b/deps/uv/src/win/signal.c @@ -64,7 +64,7 @@ static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) { } -RB_GENERATE_STATIC(uv_signal_tree_s, uv_signal_s, tree_entry, uv__signal_compare); +RB_GENERATE_STATIC(uv_signal_tree_s, uv_signal_s, tree_entry, uv__signal_compare) /* diff --git a/deps/uv/src/win/thread.c b/deps/uv/src/win/thread.c index 91684e93875541..30b2d7793cf906 100644 --- a/deps/uv/src/win/thread.c +++ b/deps/uv/src/win/thread.c @@ -198,6 +198,11 @@ int uv_mutex_init(uv_mutex_t* mutex) { } +int uv_mutex_init_recursive(uv_mutex_t* mutex) { + return uv_mutex_init(mutex); +} + + void uv_mutex_destroy(uv_mutex_t* mutex) { DeleteCriticalSection(mutex); } diff --git a/deps/uv/src/win/timer.c b/deps/uv/src/win/timer.c index 27ca7716af6d8a..7e006fedfaf3ee 100644 --- a/deps/uv/src/win/timer.c +++ b/deps/uv/src/win/timer.c @@ -56,7 +56,7 @@ static int uv_timer_compare(uv_timer_t* a, uv_timer_t* b) { } -RB_GENERATE_STATIC(uv_timer_tree_s, uv_timer_s, tree_entry, uv_timer_compare); +RB_GENERATE_STATIC(uv_timer_tree_s, uv_timer_s, tree_entry, uv_timer_compare) int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) { diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c index c4f99bdc7961b8..4cd1c72129ceb9 100644 --- a/deps/uv/src/win/tty.c +++ b/deps/uv/src/win/tty.c @@ -112,14 +112,30 @@ static int uv_tty_virtual_offset = -1; static int uv_tty_virtual_height = -1; static int uv_tty_virtual_width = -1; +/* The console window size + * We keep this separate from uv_tty_virtual_*. We use those values to only + * handle signalling SIGWINCH + */ + +static HANDLE uv__tty_console_handle = INVALID_HANDLE_VALUE; +static int uv__tty_console_height = -1; +static int uv__tty_console_width = -1; + +static DWORD WINAPI uv__tty_console_resize_message_loop_thread(void* param); +static void CALLBACK uv__tty_console_resize_event(HWINEVENTHOOK hWinEventHook, + DWORD event, + HWND hwnd, + LONG idObject, + LONG idChild, + DWORD dwEventThread, + DWORD dwmsEventTime); + /* We use a semaphore rather than a mutex or critical section because in some cases (uv__cancel_read_console) we need take the lock in the main thread and release it in another thread. Using a semaphore ensures that in such scenario the main thread will still block when trying to acquire the lock. */ static uv_sem_t uv_tty_output_lock; -static HANDLE uv_tty_output_handle = INVALID_HANDLE_VALUE; - static WORD uv_tty_default_text_attributes = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; @@ -141,6 +157,18 @@ static void uv__determine_vterm_state(HANDLE handle); void uv_console_init(void) { if (uv_sem_init(&uv_tty_output_lock, 1)) abort(); + uv__tty_console_handle = CreateFileW(L"CONOUT$", + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_WRITE, + 0, + OPEN_EXISTING, + 0, + 0); + if (uv__tty_console_handle != NULL) { + QueueUserWorkItem(uv__tty_console_resize_message_loop_thread, + NULL, + WT_EXECUTELONGFUNCTION); + } } @@ -184,11 +212,6 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { if (uv__vterm_state == UV_UNCHECKED) uv__determine_vterm_state(handle); - /* Store the global tty output handle. This handle is used by TTY read */ - /* streams to update the virtual window when a CONSOLE_BUFFER_SIZE_EVENT */ - /* is received. */ - uv_tty_output_handle = handle; - /* Remember the original console text attributes. */ uv_tty_capture_initial_style(&screen_buffer_info); @@ -705,25 +728,7 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, } records_left--; - /* If the window was resized, recompute the virtual window size. This */ - /* will trigger a SIGWINCH signal if the window size changed in an */ - /* way that matters to libuv. */ - if (handle->tty.rd.last_input_record.EventType == WINDOW_BUFFER_SIZE_EVENT) { - CONSOLE_SCREEN_BUFFER_INFO info; - - uv_sem_wait(&uv_tty_output_lock); - - if (uv_tty_output_handle != INVALID_HANDLE_VALUE && - GetConsoleScreenBufferInfo(uv_tty_output_handle, &info)) { - uv_tty_update_virtual_window(&info); - } - - uv_sem_post(&uv_tty_output_lock); - - continue; - } - - /* Ignore other events that are not key or resize events. */ + /* Ignore other events that are not key events. */ if (handle->tty.rd.last_input_record.EventType != KEY_EVENT) { continue; } @@ -1103,9 +1108,6 @@ static int uv__cancel_read_console(uv_tty_t* handle) { static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info) { - int old_virtual_width = uv_tty_virtual_width; - int old_virtual_height = uv_tty_virtual_height; - uv_tty_virtual_width = info->dwSize.X; uv_tty_virtual_height = info->srWindow.Bottom - info->srWindow.Top + 1; @@ -1125,14 +1127,6 @@ static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info) { if (uv_tty_virtual_offset < 0) { uv_tty_virtual_offset = 0; } - - /* If the virtual window size changed, emit a SIGWINCH signal. Don't emit */ - /* if this was the first time the virtual window size was computed. */ - if (old_virtual_width != -1 && old_virtual_height != -1 && - (uv_tty_virtual_width != old_virtual_width || - uv_tty_virtual_height != old_virtual_height)) { - uv__signal_dispatch(SIGWINCH); - } } @@ -2280,3 +2274,52 @@ static void uv__determine_vterm_state(HANDLE handle) { uv__vterm_state = UV_SUPPORTED; } + +static DWORD WINAPI uv__tty_console_resize_message_loop_thread(void* param) { + CONSOLE_SCREEN_BUFFER_INFO sb_info; + MSG msg; + + if (!GetConsoleScreenBufferInfo(uv__tty_console_handle, &sb_info)) + return 0; + + uv__tty_console_width = sb_info.dwSize.X; + uv__tty_console_height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1; + + if (!SetWinEventHook(EVENT_CONSOLE_LAYOUT, + EVENT_CONSOLE_LAYOUT, + NULL, + uv__tty_console_resize_event, + 0, + 0, + WINEVENT_OUTOFCONTEXT)) + return 0; + + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + return 0; +} + +static void CALLBACK uv__tty_console_resize_event(HWINEVENTHOOK hWinEventHook, + DWORD event, + HWND hwnd, + LONG idObject, + LONG idChild, + DWORD dwEventThread, + DWORD dwmsEventTime) { + CONSOLE_SCREEN_BUFFER_INFO sb_info; + int width, height; + + if (!GetConsoleScreenBufferInfo(uv__tty_console_handle, &sb_info)) + return; + + width = sb_info.dwSize.X; + height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1; + + if (width != uv__tty_console_width || height != uv__tty_console_height) { + uv__tty_console_width = width; + uv__tty_console_height = height; + uv__signal_dispatch(SIGWINCH); + } +} diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c index d2e7f772ce2977..a2acda1152f663 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -1388,7 +1388,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) { if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token) == 0) return uv_translate_sys_error(GetLastError()); - bufsize = sizeof(path); + bufsize = ARRAY_SIZE(path); if (!GetUserProfileDirectoryW(token, path, &bufsize)) { r = GetLastError(); CloseHandle(token); @@ -1403,7 +1403,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) { CloseHandle(token); /* Get the username using GetUserNameW() */ - bufsize = sizeof(username); + bufsize = ARRAY_SIZE(username); if (!GetUserNameW(username, &bufsize)) { r = GetLastError(); diff --git a/deps/uv/test/runner.c b/deps/uv/test/runner.c index 4f54f85e2305f1..5e44118775edbc 100644 --- a/deps/uv/test/runner.c +++ b/deps/uv/test/runner.c @@ -29,6 +29,13 @@ char executable_path[sizeof(executable_path)]; +static int compare_task(const void* va, const void* vb) { + const task_entry_t* a = va; + const task_entry_t* b = vb; + return strcmp(a->task_name, b->task_name); +} + + const char* fmt(double d) { static char buf[1024]; static char* p; @@ -67,6 +74,7 @@ const char* fmt(double d) { int run_tests(int benchmark_output) { + int actual; int total; int passed; int failed; @@ -76,13 +84,16 @@ int run_tests(int benchmark_output) { task_entry_t* task; /* Count the number of tests. */ + actual = 0; total = 0; - for (task = TASKS; task->main; task++) { + for (task = TASKS; task->main; task++, actual++) { if (!task->is_helper) { total++; } } + qsort(TASKS, actual, sizeof(TASKS[0]), compare_task); + fprintf(stderr, "1..%d\n", total); fflush(stderr); @@ -352,12 +363,6 @@ int run_test_part(const char* test, const char* part) { } -static int compare_task(const void* va, const void* vb) { - const task_entry_t* a = va; - const task_entry_t* b = vb; - return strcmp(a->task_name, b->task_name); -} - static int find_helpers(const task_entry_t* task, const task_entry_t** helpers) { diff --git a/deps/uv/test/test-fs-copyfile.c b/deps/uv/test/test-fs-copyfile.c index 2d1f9079a5f915..460c1dc6ae0b9f 100644 --- a/deps/uv/test/test-fs-copyfile.c +++ b/deps/uv/test/test-fs-copyfile.c @@ -68,7 +68,8 @@ static void touch_file(const char* name, unsigned int size) { int r; unsigned int i; - r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); + r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT | O_TRUNC, + S_IWUSR | S_IRUSR, NULL); uv_fs_req_cleanup(&req); ASSERT(r >= 0); file = r; @@ -119,6 +120,13 @@ TEST_IMPL(fs_copyfile) { ASSERT(r == 0); handle_result(&req); + /* Copies a file of size zero. */ + unlink(dst); + touch_file(src, 0); + r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL); + ASSERT(r == 0); + handle_result(&req); + /* Copies file synchronously. Overwrites existing file. */ r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL); ASSERT(r == 0); @@ -129,6 +137,12 @@ TEST_IMPL(fs_copyfile) { ASSERT(r == UV_EEXIST); uv_fs_req_cleanup(&req); + /* Truncates when an existing destination is larger than the source file. */ + touch_file(src, 1); + r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL); + ASSERT(r == 0); + handle_result(&req); + /* Copies a larger file. */ unlink(dst); touch_file(src, 4096 * 2); @@ -141,9 +155,9 @@ TEST_IMPL(fs_copyfile) { unlink(dst); r = uv_fs_copyfile(loop, &req, fixture, dst, 0, handle_result); ASSERT(r == 0); - ASSERT(result_check_count == 3); + ASSERT(result_check_count == 5); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(result_check_count == 4); + ASSERT(result_check_count == 6); unlink(dst); /* Cleanup */ return 0; diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 6e84653e8b4f83..0dde57c2ed22ab 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -328,6 +328,7 @@ TEST_DECLARE (threadpool_cancel_single) TEST_DECLARE (thread_local_storage) TEST_DECLARE (thread_stack_size) TEST_DECLARE (thread_mutex) +TEST_DECLARE (thread_mutex_recursive) TEST_DECLARE (thread_rwlock) TEST_DECLARE (thread_rwlock_trylock) TEST_DECLARE (thread_create) @@ -840,6 +841,7 @@ TASK_LIST_START TEST_ENTRY (thread_local_storage) TEST_ENTRY (thread_stack_size) TEST_ENTRY (thread_mutex) + TEST_ENTRY (thread_mutex_recursive) TEST_ENTRY (thread_rwlock) TEST_ENTRY (thread_rwlock_trylock) TEST_ENTRY (thread_create) diff --git a/deps/uv/test/test-mutexes.c b/deps/uv/test/test-mutexes.c index af5e4e88a22f30..975222ca1229d7 100644 --- a/deps/uv/test/test-mutexes.c +++ b/deps/uv/test/test-mutexes.c @@ -50,6 +50,26 @@ TEST_IMPL(thread_mutex) { } +TEST_IMPL(thread_mutex_recursive) { + uv_mutex_t mutex; + int r; + + r = uv_mutex_init_recursive(&mutex); + ASSERT(r == 0); + + uv_mutex_lock(&mutex); + uv_mutex_lock(&mutex); + ASSERT(0 == uv_mutex_trylock(&mutex)); + + uv_mutex_unlock(&mutex); + uv_mutex_unlock(&mutex); + uv_mutex_unlock(&mutex); + uv_mutex_destroy(&mutex); + + return 0; +} + + TEST_IMPL(thread_rwlock) { uv_rwlock_t rwlock; int r; diff --git a/deps/uv/test/test-poll.c b/deps/uv/test/test-poll.c index 7cfc159a2b3d03..e828addbb48225 100644 --- a/deps/uv/test/test-poll.c +++ b/deps/uv/test/test-poll.c @@ -601,7 +601,8 @@ TEST_IMPL(poll_unidirectional) { TEST_IMPL(poll_bad_fdtype) { #if !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__sun) && \ !defined(_AIX) && !defined(__MVS__) && !defined(__FreeBSD_kernel__) && \ - !defined(__OpenBSD__) && !defined(__CYGWIN__) && !defined(__MSYS__) + !defined(__OpenBSD__) && !defined(__CYGWIN__) && !defined(__MSYS__) && \ + !defined(__NetBSD__) uv_poll_t poll_handle; int fd; diff --git a/deps/uv/test/test-signal-multiple-loops.c b/deps/uv/test/test-signal-multiple-loops.c index 11193dcf50b227..1272d4576fd968 100644 --- a/deps/uv/test/test-signal-multiple-loops.c +++ b/deps/uv/test/test-signal-multiple-loops.c @@ -275,6 +275,7 @@ TEST_IMPL(signal_multiple_loops) { ASSERT(r == 0); } + uv_sem_destroy(&sem); printf("signal1_cb calls: %d\n", signal1_cb_counter); printf("signal2_cb calls: %d\n", signal2_cb_counter); printf("loops created and destroyed: %d\n", loop_creation_counter); diff --git a/deps/uv/test/test-thread.c b/deps/uv/test/test-thread.c index 10bec3fe6c6587..b0e87e208155ea 100644 --- a/deps/uv/test/test-thread.c +++ b/deps/uv/test/test-thread.c @@ -211,22 +211,28 @@ TEST_IMPL(thread_local_storage) { } -#if defined(__APPLE__) static void thread_check_stack(void* arg) { - /* 512KB is the default stack size of threads other than the main thread - * on OSX. */ +#if defined(__APPLE__) + /* 512 kB is the default stack size of threads other than the main thread + * on MacOS. */ ASSERT(pthread_get_stacksize_np(pthread_self()) > 512*1024); -} +#elif defined(__linux__) && defined(__GLIBC__) + struct rlimit lim; + size_t stack_size; + pthread_attr_t attr; + ASSERT(0 == getrlimit(RLIMIT_STACK, &lim)); + if (lim.rlim_cur == RLIM_INFINITY) + lim.rlim_cur = 2 << 20; /* glibc default. */ + ASSERT(0 == pthread_getattr_np(pthread_self(), &attr)); + ASSERT(0 == pthread_attr_getstacksize(&attr, &stack_size)); + ASSERT(stack_size >= lim.rlim_cur); #endif +} TEST_IMPL(thread_stack_size) { -#if defined(__APPLE__) uv_thread_t thread; ASSERT(0 == uv_thread_create(&thread, thread_check_stack, NULL)); ASSERT(0 == uv_thread_join(&thread)); return 0; -#else - RETURN_SKIP("OSX only test"); -#endif } diff --git a/deps/uv/test/test-udp-ipv6.c b/deps/uv/test/test-udp-ipv6.c index 54b364da9ebc75..000079185557a4 100644 --- a/deps/uv/test/test-udp-ipv6.c +++ b/deps/uv/test/test-udp-ipv6.c @@ -26,7 +26,7 @@ #include #include -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) #include #endif @@ -47,8 +47,8 @@ static int send_cb_called; static int recv_cb_called; static int close_cb_called; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -static int can_ipv6_ipv4_dual() { +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) +static int can_ipv6_ipv4_dual(void) { int v6only; size_t size = sizeof(int); @@ -171,7 +171,7 @@ TEST_IMPL(udp_dual_stack) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) if (!can_ipv6_ipv4_dual()) RETURN_SKIP("IPv6-IPv4 dual stack not supported"); #endif diff --git a/deps/uv/test/test-udp-multicast-join6.c b/deps/uv/test/test-udp-multicast-join6.c index 2eb9e920e7f2f5..8814b5ad13c6ff 100644 --- a/deps/uv/test/test-udp-multicast-join6.c +++ b/deps/uv/test/test-udp-multicast-join6.c @@ -122,7 +122,8 @@ TEST_IMPL(udp_multicast_join6) { #if defined(__APPLE__) || \ defined(_AIX) || \ defined(__MVS__) || \ - defined(__FreeBSD_kernel__) + defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) r = uv_udp_set_membership(&client, "ff02::1", "::1%lo0", UV_JOIN_GROUP); #else r = uv_udp_set_membership(&client, "ff02::1", NULL, UV_JOIN_GROUP); diff --git a/deps/uv/tools/vswhere_usability_wrapper.cmd b/deps/uv/tools/vswhere_usability_wrapper.cmd index e4acf03e1ee952..ee0549c8034ff7 100644 --- a/deps/uv/tools/vswhere_usability_wrapper.cmd +++ b/deps/uv/tools/vswhere_usability_wrapper.cmd @@ -2,23 +2,23 @@ :: Distributed under MIT style license or the libuv license :: See accompanying file LICENSE at https://github.com/node4good/windows-autoconf :: or libuv LICENSE file at https://github.com/libuv/libuv -:: version: 1.15.3 +:: version: 2.0.0 @if not defined DEBUG_HELPER @ECHO OFF setlocal +if "%~1"=="prerelease" set VSWHERE_WITH_PRERELEASE=1 set "InstallerPath=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer" if not exist "%InstallerPath%" set "InstallerPath=%ProgramFiles%\Microsoft Visual Studio\Installer" -if not exist "%InstallerPath%" exit goto :no-vswhere +if not exist "%InstallerPath%" goto :no-vswhere :: Manipulate %Path% for easier " handeling -set Path=%Path%;%InstallerPath% +set "Path=%Path%;%InstallerPath%" where vswhere 2> nul > nul if errorlevel 1 goto :no-vswhere set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 set VSWHERE_PRP=-property installationPath set VSWHERE_LMT=-version "[15.0,16.0)" vswhere -prerelease > nul -if "%~1"=="prerelase" set VSWHERE_WITH_PRERELASE=1 -if not errorlevel 1 if "%VSWHERE_WITH_PRERELASE%"=="1" set "VSWHERE_LMT=%VSWHERE_LMT% -prerelease" +if not errorlevel 1 if "%VSWHERE_WITH_PRERELEASE%"=="1" set "VSWHERE_LMT=%VSWHERE_LMT% -prerelease" SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT% for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( endlocal diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index cac6da819b2196..38765eefd129b2 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -10,10 +10,10 @@ ['OS=="solaris"', { 'cflags': [ '-pthreads' ], }], - ['OS not in "solaris android os390"', { + ['OS not in "solaris android zos"', { 'cflags': [ '-pthread' ], }], - ['OS in "os390"', { + ['OS in "zos"', { 'defines': [ '_UNIX03_THREADS', '_UNIX03_SOURCE', @@ -172,10 +172,10 @@ ['OS=="solaris"', { 'ldflags': [ '-pthreads' ], }], - [ 'OS=="os390" and uv_library=="shared_library"', { + [ 'OS=="zos" and uv_library=="shared_library"', { 'ldflags': [ '-Wl,DLL' ], }], - ['OS != "solaris" and OS != "android" and OS != "os390"', { + ['OS != "solaris" and OS != "android" and OS != "zos"', { 'ldflags': [ '-pthread' ], }], ], @@ -183,14 +183,14 @@ 'conditions': [ ['uv_library=="shared_library"', { 'conditions': [ - ['OS=="os390"', { + ['OS=="zos"', { 'cflags': [ '-qexportall' ], }, { 'cflags': [ '-fPIC' ], }], ], }], - ['uv_library=="shared_library" and OS!="mac" and OS!="os390"', { + ['uv_library=="shared_library" and OS!="mac" and OS!="zos"', { # This will cause gyp to set soname # Must correspond with UV_VERSION_MAJOR # in include/uv-version.h @@ -198,10 +198,10 @@ }], ], }], - [ 'OS in "linux mac ios android os390"', { + [ 'OS in "linux mac ios android zos"', { 'sources': [ 'src/unix/proctitle.c' ], }], - [ 'OS != "os390"', { + [ 'OS != "zos"', { 'cflags': [ '-fvisibility=hidden', '-g', @@ -224,11 +224,6 @@ '_DARWIN_UNLIMITED_SELECT=1', ] }], - [ 'OS!="mac" and OS!="os390"', { - # Enable on all platforms except OS X. The antique gcc/clang that - # ships with Xcode emits waaaay too many false positives. - 'cflags': [ '-Wstrict-aliasing' ], - }], [ 'OS=="linux"', { 'defines': [ '_GNU_SOURCE' ], 'sources': [ @@ -317,7 +312,7 @@ ['uv_library=="shared_library"', { 'defines': [ 'BUILDING_UV_SHARED=1' ] }], - ['OS=="os390"', { + ['OS=="zos"', { 'sources': [ 'src/unix/pthread-fixes.c', 'src/unix/no-fsevents.c', @@ -489,7 +484,7 @@ 'test/runner-unix.h', ], 'conditions': [ - [ 'OS != "os390"', { + [ 'OS != "zos"', { 'defines': [ '_GNU_SOURCE' ], 'cflags': [ '-Wno-long-long' ], 'xcode_settings': { @@ -518,7 +513,7 @@ ['uv_library=="shared_library"', { 'defines': [ 'USING_UV_SHARED=1' ], 'conditions': [ - [ 'OS == "os390"', { + [ 'OS == "zos"', { 'cflags': [ '-Wc,DLL' ], }], ], @@ -579,7 +574,7 @@ ['uv_library=="shared_library"', { 'defines': [ 'USING_UV_SHARED=1' ], 'conditions': [ - [ 'OS == "os390"', { + [ 'OS == "zos"', { 'cflags': [ '-Wc,DLL' ], }], ], diff --git a/deps/uv/vcbuild.bat b/deps/uv/vcbuild.bat index 698044df490c02..46b3476107757a 100644 --- a/deps/uv/vcbuild.bat +++ b/deps/uv/vcbuild.bat @@ -55,6 +55,8 @@ set "VSINSTALLDIR=" call tools\vswhere_usability_wrapper.cmd if "_%VCINSTALLDIR%_" == "__" goto vs-set-2015 @rem Need to clear VSINSTALLDIR for vcvarsall to work as expected. +@rem Keep current working directory after call to vcvarsall +set "VSCMD_START_DIR=%CD%" set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vs_toolset% echo calling: %vcvars_call% call %vcvars_call%