deps: upgrade libuv to 1.13.1

PR-URL: https://github.com/nodejs/node/pull/14117
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
cjihrig authored and Myles Borins committed 2017-10-25 04:09:43 -04:00
1 parent 3ac769091c
commit a38755d0a4
31 files changed
+616 -137

No files matched your search

+1
View File
@@ -41,3 +41,4 @@ Yasuhiro Matsumoto <mattn.jp@gmail.com>
Yazhong Liu <yorkiefixer@gmail.com>
Yuki Okumura <mjt@cltn.org>
jBarz <jBarz@users.noreply.github.com> <jbarboza@ca.ibm.com>
jBarz <jBarz@users.noreply.github.com> <jbarz@users.noreply.github.com>
+7
View File
@@ -292,3 +292,10 @@ Keane <erich.keane@intel.com>
James McCoy <jamessan@jamessan.com>
Bernardo Ramos <berna.gensis@gmail.com>
Juan Cruz Viotti <jviotti@openmailbox.org>
Gemini Wen <geminiwen@aliyun.com>
Sebastian Wiedenroth <wiedi@frubar.net>
Sai Ke WANG <swang304@bloomberg.net>
Barnabas Gema <gema.barnabas@gmail.com>
Romain Caire <romain@blade-group.com>
Robert Ayrapetyan <robert.ayrapetyan@gmail.com>
Refael Ackermann <refack@gmail.com>
+56
View File
@@ -1,3 +1,59 @@
2017.07.07, Version 1.13.1 (Stable), 2bb4b68758f07cd8617838e68c44c125bc567ba6
Changes since version 1.13.0:
* Now working on version 1.13.1 (cjihrig)
* build: workaround AppVeyor quirk (Refael Ackermann)
2017.07.06, Version 1.13.0 (Stable), 8342fcaab815f33b988c1910ea988f28dfe27edb
Changes since version 1.12.0:
* Now working on version 1.12.1 (cjihrig)
* unix: avoid segfault in uv_get_process_title (Michele Caini)
* build: add a comma to uv.gyp (Gemini Wen)
* win: restore file pos after positional read/write (Bartosz Sosnowski)
* unix,stream: return error on closed handle passing (Santiago Gimeno)
* unix,benchmark: use fd instead of FILE* after fork (jBarz)
* zos: avoid compiler warnings (jBarz)
* win,pipe: race condition canceling readfile thread (Jameson Nash)
* sunos: filter out non-IPv4/IPv6 interfaces (Sebastian Wiedenroth)
* sunos: fix cmpxchgi and cmpxchgl type error (Sai Ke WANG)
* unix: reset signal disposition before execve() (Ben Noordhuis)
* unix: reset signal mask before execve() (Ben Noordhuis)
* unix: fix POLLIN assertion on server read (jBarz)
* zos: use stckf builtin for high-res timer (jBarz)
* win,udp: implements uv_udp_try_send (Barnabas Gema)
* win,udp: return UV_EINVAL instead of aborting (Romain Caire)
* freebsd: replace kvm with sysctl (Robert Ayrapetyan)
* aix: fix un-initialized pointer field in fs handle (Gireesh Punathil)
* win,build: support building with VS2017 (Refael Ackermann)
* doc: add instructions for building on Windows (Refael Ackermann)
* doc: format README (Refael Ackermann)
2017.05.31, Version 1.12.0 (Stable), d6ac141ac674657049598c36604f26e031fae917
Changes since version 1.11.0:
+117 -42
View File
@@ -3,7 +3,7 @@
## Overview
libuv is a multi-platform support library with a focus on asynchronous I/O. It
was primarily developed for use by [Node.js](http://nodejs.org), but it's also
was primarily developed for use by [Node.js][], but it's also
used by [Luvit](http://luvit.io/), [Julia](http://julialang.org/),
[pyuv](https://github.com/saghul/pyuv), and [others](https://github.com/libuv/libuv/wiki/Projects-that-use-libuv).
@@ -62,24 +62,34 @@ formats.
Show different supported building options:
$ make help
```bash
$ make help
```
Build documentation as HTML:
$ make html
```bash
$ make html
```
Build documentation as HTML and live reload it when it changes (this requires
sphinx-autobuild to be installed and is only supported on Unix):
$ make livehtml
```bash
$ make livehtml
```
Build documentation as man pages:
$ make man
```bash
$ make man
```
Build documentation as ePub:
$ make epub
```bash
$ make epub
```
NOTE: Windows users need to use make.bat instead of plain 'make'.
@@ -116,25 +126,32 @@ file, but are also available as git blob objects for easier use.
Importing a key the usual way:
$ gpg --keyserver pool.sks-keyservers.net \
--recv-keys AE9BC059
```bash
$ gpg --keyserver pool.sks-keyservers.net --recv-keys AE9BC059
```
Importing a key from a git blob object:
$ git show pubkey-saghul | gpg --import
```bash
$ git show pubkey-saghul | gpg --import
```
### Verifying releases
Git tags are signed with the developer's key, they can be verified as follows:
$ git verify-tag v1.6.1
```bash
$ git verify-tag v1.6.1
```
Starting with libuv 1.7.0, the tarballs stored in the
[downloads site](http://dist.libuv.org/dist/) are signed and an accompanying
signature file sit alongside each. Once both the release tarball and the
signature file are downloaded, the file can be verified as follows:
$ gpg --verify libuv-1.7.0.tar.gz.sign
```bash
$ gpg --verify libuv-1.7.0.tar.gz.sign
```
## Build Instructions
@@ -144,38 +161,82 @@ backends. It is best used for integration into other projects.
To build with autotools:
$ sh autogen.sh
$ ./configure
$ make
$ make check
$ make install
```bash
$ sh autogen.sh
$ ./configure
$ make
$ make check
$ make install
```
### Windows
First, [Python][] 2.6 or 2.7 must be installed as it is required by [GYP][].
If python is not in your path, set the environment variable `PYTHON` to its
location. For example: `set PYTHON=C:\Python27\python.exe`
Prerequisites:
To build with Visual Studio, launch a git shell (e.g. Cmd or PowerShell)
and run vcbuild.bat which will checkout the GYP code into build/gyp and
generate uv.sln as well as related project files.
* [Python 2.6 or 2.7][] as it is required
by [GYP][].
If python is not in your path, set the environment variable `PYTHON` to its
location. For example: `set PYTHON=C:\Python27\python.exe`
* One of:
* [Visual C++ Build Tools][]
* [Visual Studio 2015 Update 3][], all editions
including the Community edition (remember to select
"Common Tools for Visual C++ 2015" feature during installation).
* [Visual Studio 2017][], any edition (including the Build Tools SKU).
**Required Components:** "MSbuild", "VC++ 2017 v141 toolset" and one of the
Windows SDKs (10 or 8.1).
* Basic Unix tools required for some tests,
[Git for Windows][] includes Git Bash
and tools which can be included in the global `PATH`.
To have GYP generate build script for another system, checkout GYP into the
project tree manually:
To build, launch a git shell (e.g. Cmd or PowerShell), run `vcbuild.bat`
(to build with VS2017 you need to explicitly add a `vs2017` argument),
which will checkout the GYP code into `build/gyp`, generate `uv.sln`
as well as the necesery related project files, and start building.
```console
> vcbuild
```
Or:
```console
> vcbuild vs2017
```
To run the tests:
```console
> vcbuild test
```
To see all the options that could passed to `vcbuild`:
```console
> vcbuild help
vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [vs2017] [x86/x64] [static/shared]
Examples:
vcbuild.bat : builds debug build
vcbuild.bat test : builds debug build and runs tests
vcbuild.bat release bench: builds release build and runs benchmarks
```
$ git clone https://chromium.googlesource.com/external/gyp.git build/gyp
### Unix
For Debug builds (recommended) run:
$ ./gyp_uv.py -f make
$ make -C out
```bash
$ ./gyp_uv.py -f make
$ make -C out
```
For Release builds run:
$ ./gyp_uv.py -f make
$ BUILDTYPE=Release make -C out
```bash
$ ./gyp_uv.py -f make
$ BUILDTYPE=Release make -C out
```
Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries.
@@ -183,13 +244,17 @@ Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries.
Run:
$ ./gyp_uv.py -f xcode
$ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \
-configuration Release -target All
```bash
$ ./gyp_uv.py -f xcode
$ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \
-configuration Release -target All
```
Using Homebrew:
$ brew install --HEAD libuv
```bash
$ brew install --HEAD libuv
```
Note to OS X users:
@@ -201,8 +266,10 @@ Make sure that you specify the architecture you wish to build for in the
Run:
$ source ./android-configure NDK_PATH gyp
$ make -C out
```bash
$ source ./android-configure NDK_PATH gyp
$ make -C out
```
Note for UNIX users: compile your project with `-D_LARGEFILE_SOURCE` and
`-D_FILE_OFFSET_BITS=64`. GYP builds take care of that automatically.
@@ -211,18 +278,22 @@ Note for UNIX users: compile your project with `-D_LARGEFILE_SOURCE` and
To use ninja for build on ninja supported platforms, run:
$ ./gyp_uv.py -f ninja
$ ninja -C out/Debug #for debug build OR
$ ninja -C out/Release
```bash
$ ./gyp_uv.py -f ninja
$ ninja -C out/Debug #for debug build OR
$ ninja -C out/Release
```
### Running tests
Run:
$ ./gyp_uv.py -f make
$ make -C out
$ ./out/Debug/run-tests
```bash
$ ./gyp_uv.py -f make
$ make -C out
$ ./out/Debug/run-tests
```
## Supported Platforms
@@ -244,7 +315,11 @@ See the [guidelines for contributing][].
[node.js]: http://nodejs.org/
[GYP]: http://code.google.com/p/gyp/
[Python]: https://www.python.org/downloads/
[guidelines for contributing]: https://github.com/libuv/libuv/blob/master/CONTRIBUTING.md
[libuv_banner]: https://raw.githubusercontent.com/libuv/libuv/master/img/banner.png
[x32]: https://en.wikipedia.org/wiki/X32_ABI
[Python 2.6 or 2.7]: https://www.python.org/downloads/
[Visual C++ Build Tools]: http://landinghub.visualstudio.com/visual-cpp-build-tools
[Visual Studio 2015 Update 3]: https://www.visualstudio.com/vs/older-downloads/
[Visual Studio 2017]: https://www.visualstudio.com/downloads/
[Git for Windows]: http://git-scm.com/download/win
+1 -1
View File
@@ -1,4 +1,4 @@
version: v1.12.0.build{build}
version: v1.13.1.build{build}
install:
- cinst -y nsis
+9 -3
View File
@@ -49,9 +49,6 @@
'cflags': [
'-O3',
'-fstrict-aliasing',
'-fomit-frame-pointer',
'-fdata-sections',
'-ffunction-sections',
],
'msvs_settings': {
'VCCLCompilerTool': {
@@ -82,6 +79,15 @@
'LinkIncremental': 1, # disable incremental linking
},
},
'conditions': [
['OS != "os390"', {
'cflags': [
'-fomit-frame-pointer',
'-fdata-sections',
'-ffunction-sections',
],
}],
]
}
},
'msvs_settings': {
+2 -4
View File
@@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AC_PREREQ(2.57)
AC_INIT([libuv], [1.12.0], [https://github.com/libuv/libuv/issues])
AC_INIT([libuv], [1.13.1], [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])
@@ -66,9 +66,7 @@ AM_CONDITIONAL([WINNT], [AS_CASE([$host_os],[mingw*], [true], [false])
AS_CASE([$host_os],[mingw*], [
LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32"
])
AS_CASE([$host_os], [openbsd*], [], [
AC_CHECK_LIB([kvm], [kvm_open])
])
AS_CASE([$host_os], [netbsd*], [AC_CHECK_LIB([kvm], [kvm_open])])
AC_CHECK_HEADERS([sys/ahafs_evProds.h])
AC_CHECK_PROG(PKG_CONFIG, pkg-config, yes)
AM_CONDITIONAL([HAVE_PKG_CONFIG], [test "x$PKG_CONFIG" != "x"])
+2 -2
View File
@@ -31,8 +31,8 @@
*/
#define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 12
#define UV_VERSION_PATCH 0
#define UV_VERSION_MINOR 13
#define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX ""
+1
View File
@@ -855,6 +855,7 @@ int uv_fs_event_start(uv_fs_event_t* handle,
uv__io_init(&handle->event_watcher, uv__ahafs_event, fd);
handle->path = uv__strdup(filename);
handle->cb = cb;
handle->dir_filename = NULL;
uv__io_start(handle->loop, &handle->event_watcher, POLLIN);
+4 -1
View File
@@ -20,7 +20,6 @@
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#include <atomic.h>
#define __sync_val_compare_and_swap(p, o, n) atomic_cas_ptr(p, o, n)
#endif
UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval));
@@ -49,6 +48,8 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
return oldval;
else
return op4;
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
return atomic_cas_uint(ptr, oldval, newval);
#else
return __sync_val_compare_and_swap(ptr, oldval, newval);
#endif
@@ -83,6 +84,8 @@ UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) {
return oldval;
else
return op4;
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
return atomic_cas_ulong(ptr, oldval, newval);
#else
return __sync_val_compare_and_swap(ptr, oldval, newval);
#endif
+4 -1
View File
@@ -28,7 +28,6 @@
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -82,6 +81,10 @@
#include <sys/ioctl.h>
#endif
#if !defined(__MVS__)
#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
#endif
/* Fallback for the maximum hostname length */
#ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN 256
+15 -20
View File
@@ -25,7 +25,6 @@
#include <string.h>
#include <errno.h>
#include <kvm.h>
#include <paths.h>
#include <sys/user.h>
#include <sys/types.h>
@@ -203,35 +202,31 @@ int uv_get_process_title(char* buffer, size_t size) {
return 0;
}
int uv_resident_set_memory(size_t* rss) {
kvm_t *kd = NULL;
struct kinfo_proc *kinfo = NULL;
pid_t pid;
int nprocs;
size_t page_size = getpagesize();
struct kinfo_proc kinfo;
size_t page_size;
size_t kinfo_size;
int mib[4];
pid = getpid();
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = getpid();
kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, "kvm_open");
if (kd == NULL) goto error;
kinfo_size = sizeof(kinfo);
kinfo = kvm_getprocs(kd, KERN_PROC_PID, pid, &nprocs);
if (kinfo == NULL) goto error;
if (sysctl(mib, 4, &kinfo, &kinfo_size, NULL, 0))
return -errno;
page_size = getpagesize();
#ifdef __DragonFly__
*rss = kinfo->kp_vm_rssize * page_size;
*rss = kinfo.kp_vm_rssize * page_size;
#else
*rss = kinfo->ki_rssize * page_size;
*rss = kinfo.ki_rssize * page_size;
#endif
kvm_close(kd);
return 0;
error:
if (kd) kvm_close(kd);
return -EPERM;
}
+5 -3
View File
@@ -25,6 +25,7 @@
#include <utmpx.h>
#include <unistd.h>
#include <sys/ps.h>
#include <builtins.h>
#if defined(__clang__)
#include "csrsic.h"
#else
@@ -118,9 +119,10 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
uint64_t uv__hrtime(uv_clocktype_t type) {
struct timeval time;
gettimeofday(&time, NULL);
return (uint64_t) time.tv_sec * 1e9 + time.tv_usec * 1e3;
unsigned long long timestamp;
__stckf(&timestamp);
/* Convert to nanoseconds */
return timestamp / 10;
}
+28
View File
@@ -279,9 +279,12 @@ static void uv__process_child_init(const uv_process_options_t* options,
int stdio_count,
int (*pipes)[2],
int error_fd) {
sigset_t set;
int close_fd;
int use_fd;
int err;
int fd;
int n;
if (options->flags & UV_PROCESS_DETACHED)
setsid();
@@ -376,6 +379,31 @@ static void uv__process_child_init(const uv_process_options_t* options,
environ = options->env;
}
/* Reset signal disposition. Use a hard-coded limit because NSIG
* is not fixed on Linux: it's either 32, 34 or 64, depending on
* whether RT signals are enabled. We are not allowed to touch
* RT signal handlers, glibc uses them internally.
*/
for (n = 1; n < 32; n += 1) {
if (n == SIGKILL || n == SIGSTOP)
continue; /* Can't be changed. */
if (SIG_ERR != signal(n, SIG_DFL))
continue;
uv__write_int(error_fd, -errno);
_exit(127);
}
/* Reset signal mask. */
sigemptyset(&set);
err = pthread_sigmask(SIG_SETMASK, &set, NULL);
if (err != 0) {
uv__write_int(error_fd, -err);
_exit(127);
}
execvp(options->file, options->args);
uv__write_int(error_fd, -errno);
_exit(127);
+3 -1
View File
@@ -98,7 +98,9 @@ int uv_get_process_title(char* buffer, size_t size) {
else if (size <= process_title.len)
return -ENOBUFS;
memcpy(buffer, process_title.str, process_title.len + 1);
if (process_title.len != 0)
memcpy(buffer, process_title.str, process_title.len + 1);
buffer[process_title.len] = '\0';
return 0;
+22 -10
View File
@@ -514,7 +514,7 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
int err;
stream = container_of(w, uv_stream_t, io_watcher);
assert(events == POLLIN);
assert(events & POLLIN);
assert(stream->accepted_fd == -1);
assert(!(stream->flags & UV_CLOSING));
@@ -750,6 +750,7 @@ static void uv__write(uv_stream_t* stream) {
int iovmax;
int iovcnt;
ssize_t n;
int err;
start:
@@ -782,14 +783,21 @@ start:
*/
if (req->send_handle) {
int fd_to_send;
struct msghdr msg;
struct cmsghdr *cmsg;
int fd_to_send = uv__handle_fd((uv_handle_t*) req->send_handle);
union {
char data[64];
struct cmsghdr alias;
} scratch;
if (uv__is_closing(req->send_handle)) {
err = -EBADF;
goto error;
}
fd_to_send = uv__handle_fd((uv_handle_t*) req->send_handle);
memset(&scratch, 0, sizeof(scratch));
assert(fd_to_send >= 0);
@@ -852,14 +860,8 @@ start:
if (n < 0) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
/* Error */
req->error = -errno;
uv__write_req_finish(req);
uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT);
if (!uv__io_active(&stream->io_watcher, POLLIN))
uv__handle_stop(stream);
uv__stream_osx_interrupt_select(stream);
return;
err = -errno;
goto error;
} else if (stream->flags & UV_STREAM_BLOCKING) {
/* If this is a blocking stream, try again. */
goto start;
@@ -923,6 +925,16 @@ start:
/* Notify select() thread about state change */
uv__stream_osx_interrupt_select(stream);
return;
error:
req->error = err;
uv__write_req_finish(req);
uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT);
if (!uv__io_active(&stream->io_watcher, POLLIN))
uv__handle_stop(stream);
uv__stream_osx_interrupt_select(stream);
}
+2 -1
View File
@@ -747,7 +747,8 @@ static int uv__ifaddr_exclude(struct ifaddrs *ent) {
return 1;
if (ent->ifa_addr == NULL)
return 1;
if (ent->ifa_addr->sa_family == PF_PACKET)
if (ent->ifa_addr->sa_family != AF_INET &&
ent->ifa_addr->sa_family != AF_INET6)
return 1;
return 0;
}
+24
View File
@@ -556,9 +556,14 @@ void fs__read(uv_fs_t* req) {
DWORD error;
int result;
unsigned int index;
LARGE_INTEGER original_position;
LARGE_INTEGER zero_offset;
int restore_position;
VERIFY_FD(fd, req);
zero_offset.QuadPart = 0;
restore_position = 0;
handle = uv__get_osfhandle(fd);
if (handle == INVALID_HANDLE_VALUE) {
@@ -569,6 +574,10 @@ void fs__read(uv_fs_t* req) {
if (offset != -1) {
memset(&overlapped, 0, sizeof overlapped);
overlapped_ptr = &overlapped;
if (SetFilePointerEx(handle, zero_offset, &original_position,
FILE_CURRENT)) {
restore_position = 1;
}
} else {
overlapped_ptr = NULL;
}
@@ -593,6 +602,9 @@ void fs__read(uv_fs_t* req) {
++index;
} while (result && index < req->fs.info.nbufs);
if (restore_position)
SetFilePointerEx(handle, original_position, NULL, FILE_BEGIN);
if (result || bytes > 0) {
SET_REQ_RESULT(req, bytes);
} else {
@@ -615,9 +627,14 @@ void fs__write(uv_fs_t* req) {
DWORD bytes;
int result;
unsigned int index;
LARGE_INTEGER original_position;
LARGE_INTEGER zero_offset;
int restore_position;
VERIFY_FD(fd, req);
zero_offset.QuadPart = 0;
restore_position = 0;
handle = uv__get_osfhandle(fd);
if (handle == INVALID_HANDLE_VALUE) {
SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE);
@@ -627,6 +644,10 @@ void fs__write(uv_fs_t* req) {
if (offset != -1) {
memset(&overlapped, 0, sizeof overlapped);
overlapped_ptr = &overlapped;
if (SetFilePointerEx(handle, zero_offset, &original_position,
FILE_CURRENT)) {
restore_position = 1;
}
} else {
overlapped_ptr = NULL;
}
@@ -651,6 +672,9 @@ void fs__write(uv_fs_t* req) {
++index;
} while (result && index < req->fs.info.nbufs);
if (restore_position)
SetFilePointerEx(handle, original_position, NULL, FILE_BEGIN);
if (result || bytes > 0) {
SET_REQ_RESULT(req, bytes);
} else {
+27 -20
View File
@@ -968,27 +968,31 @@ static DWORD WINAPI uv_pipe_zero_readfile_thread_proc(void* parameter) {
uv_mutex_unlock(m);
}
restart_readfile:
result = ReadFile(handle->handle,
&uv_zero_,
0,
&bytes,
NULL);
if (!result) {
err = GetLastError();
if (err == ERROR_OPERATION_ABORTED &&
handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) {
if (handle->flags & UV_HANDLE_READING) {
/* just a brief break to do something else */
handle->pipe.conn.readfile_thread = NULL;
/* resume after it is finished */
uv_mutex_lock(m);
handle->pipe.conn.readfile_thread = hThread;
uv_mutex_unlock(m);
goto restart_readfile;
} else {
result = 1; /* successfully stopped reading */
if (handle->flags & UV_HANDLE_READING) {
result = ReadFile(handle->handle,
&uv_zero_,
0,
&bytes,
NULL);
if (!result) {
err = GetLastError();
if (err == ERROR_OPERATION_ABORTED &&
handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) {
if (handle->flags & UV_HANDLE_READING) {
/* just a brief break to do something else */
handle->pipe.conn.readfile_thread = NULL;
/* resume after it is finished */
uv_mutex_lock(m);
handle->pipe.conn.readfile_thread = hThread;
uv_mutex_unlock(m);
goto restart_readfile;
} else {
result = 1; /* successfully stopped reading */
}
}
}
} else {
result = 1; /* successfully aborted read before it even started */
}
if (hThread) {
assert(hThread == handle->pipe.conn.readfile_thread);
@@ -1515,7 +1519,10 @@ static void uv_pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error,
static void uv_pipe_read_error_or_eof(uv_loop_t* loop, uv_pipe_t* handle,
int error, uv_buf_t buf) {
if (error == ERROR_BROKEN_PIPE) {
if (error == ERROR_OPERATION_ABORTED) {
/* do nothing (equivalent to EINTR) */
}
else if (error == ERROR_BROKEN_PIPE) {
uv_pipe_read_eof(loop, handle, buf);
} else {
uv_pipe_read_error(loop, handle, error, buf);
+40 -6
View File
@@ -897,13 +897,12 @@ int uv__udp_send(uv_udp_send_t* req,
int err;
if (!(handle->flags & UV_HANDLE_BOUND)) {
if (addrlen == sizeof(uv_addr_ip4_any_)) {
if (addrlen == sizeof(uv_addr_ip4_any_))
bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_;
} else if (addrlen == sizeof(uv_addr_ip6_any_)) {
else if (addrlen == sizeof(uv_addr_ip6_any_))
bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_;
} else {
abort();
}
else
return UV_EINVAL;
err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0);
if (err)
return uv_translate_sys_error(err);
@@ -922,5 +921,40 @@ int uv__udp_try_send(uv_udp_t* handle,
unsigned int nbufs,
const struct sockaddr* addr,
unsigned int addrlen) {
return UV_ENOSYS;
DWORD bytes;
const struct sockaddr* bind_addr;
int err;
assert(nbufs > 0);
/* Already sending a message.*/
if (handle->send_queue_count != 0)
return UV_EAGAIN;
if (!(handle->flags & UV_HANDLE_BOUND)) {
if (addrlen == sizeof(uv_addr_ip4_any_))
bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_;
else if (addrlen == sizeof(uv_addr_ip6_any_))
bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_;
else
return UV_EINVAL;
err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0);
if (err)
return uv_translate_sys_error(err);
}
err = WSASendTo(handle->socket,
(WSABUF*)bufs,
nbufs,
&bytes,
0,
addr,
addrlen,
NULL,
NULL);
if (err)
return uv_translate_sys_error(WSAGetLastError());
return bytes;
}
+5
View File
@@ -38,6 +38,7 @@
int ipc_helper(int listen_after_write);
int ipc_helper_tcp_connection(void);
int ipc_helper_closed_handle(void);
int ipc_send_recv_helper(void);
int ipc_helper_bind_twice(void);
int stdio_over_pipes_helper(void);
@@ -89,6 +90,10 @@ static int maybe_run_test(int argc, char **argv) {
return ipc_helper_tcp_connection();
}
if (strcmp(argv[1], "ipc_helper_closed_handle") == 0) {
return ipc_helper_closed_handle();
}
if (strcmp(argv[1], "ipc_helper_bind_twice") == 0) {
return ipc_helper_bind_twice();
}
+4 -2
View File
@@ -61,12 +61,14 @@ int platform_init(int argc, char **argv) {
/* Make sure that all stdio output of the processes is buffered up. */
int process_start(char* name, char* part, process_info_t* p, int is_helper) {
FILE* stdout_file;
int stdout_fd;
const char* arg;
char* args[16];
int n;
pid_t pid;
stdout_file = tmpfile();
stdout_fd = fileno(stdout_file);
if (!stdout_file) {
perror("tmpfile");
return -1;
@@ -103,8 +105,8 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) {
args[n++] = part;
args[n++] = NULL;
dup2(fileno(stdout_file), STDOUT_FILENO);
dup2(fileno(stdout_file), STDERR_FILENO);
dup2(stdout_fd, STDOUT_FILENO);
dup2(stdout_fd, STDERR_FILENO);
execvp(args[0], args);
perror("execvp()");
_exit(127);
+9
View File
@@ -21,6 +21,7 @@
#include "uv.h"
#include "task.h"
#include <string.h>
static uv_async_t async_handle;
static uv_check_t check_handle;
@@ -43,6 +44,14 @@ static void check_cb(uv_check_t* handle) {
TEST_IMPL(async_null_cb) {
/*
* Fill async_handle with garbage values.
* uv_async_init() should properly initialize struct fields regardless of
* initial values.
* This is added to verify paddings between fields do not affect behavior.
*/
memset(&async_handle, 0xff, sizeof(async_handle));
ASSERT(0 == uv_async_init(uv_default_loop(), &async_handle, NULL));
ASSERT(0 == uv_check_init(uv_default_loop(), &check_handle));
ASSERT(0 == uv_check_start(&check_handle, check_cb));
+40
View File
@@ -2804,3 +2804,43 @@ TEST_IMPL(get_osfhandle_valid_handle) {
MAKE_VALGRIND_HAPPY();
return 0;
}
TEST_IMPL(fs_file_pos_after_op_with_offset) {
int r;
/* Setup. */
unlink("test_file");
loop = uv_default_loop();
r = uv_fs_open(loop,
&open_req1,
"test_file",
O_RDWR | O_CREAT,
S_IWUSR | S_IRUSR,
NULL);
ASSERT(r > 0);
uv_fs_req_cleanup(&open_req1);
iov = uv_buf_init(test_buf, sizeof(test_buf));
r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, 0, NULL);
ASSERT(r == sizeof(test_buf));
ASSERT(lseek(open_req1.result, 0, SEEK_CUR) == 0);
uv_fs_req_cleanup(&write_req);
iov = uv_buf_init(buf, sizeof(buf));
r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, 0, NULL);
ASSERT(r == sizeof(test_buf));
ASSERT(strcmp(buf, test_buf) == 0);
ASSERT(lseek(open_req1.result, 0, SEEK_CUR) == 0);
uv_fs_req_cleanup(&read_req);
r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
ASSERT(r == 0);
uv_fs_req_cleanup(&close_req);
/* Cleanup */
unlink("test_file");
MAKE_VALGRIND_HAPPY();
return 0;
}
+96
View File
@@ -44,6 +44,7 @@ static int close_cb_called;
static int connection_accepted;
static int tcp_conn_read_cb_called;
static int tcp_conn_write_cb_called;
static int closed_handle_data_read;
typedef struct {
uv_connect_t conn_req;
@@ -53,6 +54,7 @@ typedef struct {
#define CONN_COUNT 100
#define BACKLOG 128
#define LARGE_SIZE 1000000
static void close_server_conn_cb(uv_handle_t* handle) {
@@ -395,6 +397,26 @@ static void on_read_connection(uv_stream_t* handle,
}
#ifndef _WIN32
static void on_read_closed_handle(uv_stream_t* handle,
ssize_t nread,
const uv_buf_t* buf) {
if (nread == 0 || nread == UV_EOF) {
free(buf->base);
return;
}
if (nread < 0) {
printf("error recving on channel: %s\n", uv_strerror(nread));
abort();
}
closed_handle_data_read += nread;
free(buf->base);
}
#endif
static int run_ipc_test(const char* helper, uv_read_cb read_cb) {
uv_process_t process;
int r;
@@ -448,6 +470,15 @@ TEST_IMPL(ipc_tcp_connection) {
return r;
}
#ifndef _WIN32
TEST_IMPL(ipc_closed_handle) {
int r;
r = run_ipc_test("ipc_helper_closed_handle", on_read_closed_handle);
ASSERT(r == 0);
return 0;
}
#endif
#ifdef _WIN32
TEST_IMPL(listen_with_simultaneous_accepts) {
@@ -536,6 +567,17 @@ static void tcp_connection_write_cb(uv_write_t* req, int status) {
}
static void closed_handle_large_write_cb(uv_write_t* req, int status) {
ASSERT(status == 0);
ASSERT(closed_handle_data_read = LARGE_SIZE);
}
static void closed_handle_write_cb(uv_write_t* req, int status) {
ASSERT(status == UV_EBADF);
}
static void on_tcp_child_process_read(uv_stream_t* tcp,
ssize_t nread,
const uv_buf_t* buf) {
@@ -742,6 +784,60 @@ int ipc_helper_tcp_connection(void) {
return 0;
}
int ipc_helper_closed_handle(void) {
int r;
struct sockaddr_in addr;
uv_write_t write_req;
uv_write_t write_req2;
uv_buf_t buf;
char buffer[LARGE_SIZE];
r = uv_pipe_init(uv_default_loop(), &channel, 1);
ASSERT(r == 0);
uv_pipe_open(&channel, 0);
ASSERT(1 == uv_is_readable((uv_stream_t*) &channel));
ASSERT(1 == uv_is_writable((uv_stream_t*) &channel));
ASSERT(0 == uv_is_closing((uv_handle_t*) &channel));
memset(buffer, '.', LARGE_SIZE);
buf = uv_buf_init(buffer, LARGE_SIZE);
r = uv_tcp_init(uv_default_loop(), &tcp_server);
ASSERT(r == 0);
ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr));
r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0);
ASSERT(r == 0);
r = uv_write(&write_req,
(uv_stream_t*)&channel,
&buf,
1,
closed_handle_large_write_cb);
ASSERT(r == 0);
r = uv_write2(&write_req2,
(uv_stream_t*)&channel,
&buf,
1,
(uv_stream_t*)&tcp_server,
closed_handle_write_cb);
ASSERT(r == 0);
uv_close((uv_handle_t*)&tcp_server, NULL);
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
MAKE_VALGRIND_HAPPY();
return 0;
}
int ipc_helper_bind_twice(void) {
/*
* This is launched from test-ipc.c. stdin is a duplex channel
+8
View File
@@ -63,6 +63,9 @@ TEST_DECLARE (ipc_send_recv_pipe_inprocess)
TEST_DECLARE (ipc_send_recv_tcp)
TEST_DECLARE (ipc_send_recv_tcp_inprocess)
TEST_DECLARE (ipc_tcp_connection)
#ifndef _WIN32
TEST_DECLARE (ipc_closed_handle)
#endif
TEST_DECLARE (tcp_alloc_cb_fail)
TEST_DECLARE (tcp_ping_pong)
TEST_DECLARE (tcp_ping_pong_v6)
@@ -308,6 +311,7 @@ TEST_DECLARE (fs_read_write_null_arguments)
TEST_DECLARE (get_osfhandle_valid_handle)
TEST_DECLARE (fs_write_alotof_bufs)
TEST_DECLARE (fs_write_alotof_bufs_with_offset)
TEST_DECLARE (fs_file_pos_after_op_with_offset)
TEST_DECLARE (threadpool_queue_work_simple)
TEST_DECLARE (threadpool_queue_work_einval)
TEST_DECLARE (threadpool_multiple_event_loops)
@@ -443,6 +447,9 @@ TASK_LIST_START
TEST_ENTRY (ipc_send_recv_tcp)
TEST_ENTRY (ipc_send_recv_tcp_inprocess)
TEST_ENTRY (ipc_tcp_connection)
#ifndef _WIN32
TEST_ENTRY (ipc_closed_handle)
#endif
TEST_ENTRY (tcp_alloc_cb_fail)
@@ -793,6 +800,7 @@ TASK_LIST_START
TEST_ENTRY (fs_write_alotof_bufs)
TEST_ENTRY (fs_write_alotof_bufs_with_offset)
TEST_ENTRY (fs_read_write_null_arguments)
TEST_ENTRY (fs_file_pos_after_op_with_offset)
TEST_ENTRY (get_osfhandle_valid_handle)
TEST_ENTRY (threadpool_queue_work_simple)
TEST_ENTRY (threadpool_queue_work_einval)
+21
View File
@@ -929,9 +929,30 @@ TEST_IMPL(kill) {
init_process_options("spawn_helper4", kill_cb);
/* Verify that uv_spawn() resets the signal disposition. */
#ifndef _WIN32
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGTERM);
ASSERT(0 == pthread_sigmask(SIG_BLOCK, &set, NULL));
}
ASSERT(SIG_ERR != signal(SIGTERM, SIG_IGN));
#endif
r = uv_spawn(uv_default_loop(), &process, &options);
ASSERT(r == 0);
#ifndef _WIN32
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGTERM);
ASSERT(0 == pthread_sigmask(SIG_UNBLOCK, &set, NULL));
}
ASSERT(SIG_ERR != signal(SIGTERM, SIG_DFL));
#endif
/* Sending signum == 0 should check if the
* child process is still alive, not kill it.
*/
-12
View File
@@ -26,16 +26,6 @@
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
TEST_IMPL(udp_try_send) {
MAKE_VALGRIND_HAPPY();
return 0;
}
#else /* !_WIN32 */
#define CHECK_HANDLE(handle) \
ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client)
@@ -129,5 +119,3 @@ TEST_IMPL(udp_try_send) {
MAKE_VALGRIND_HAPPY();
return 0;
}
#endif /* !_WIN32 */
+33
View File
@@ -0,0 +1,33 @@
:: Copyright 2017 - Refael Ackermann
:: 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
@if not defined DEBUG_HELPER @ECHO OFF
setlocal
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
:: Manipulate %Path% for easier " handeling
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"
SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT%
for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do (
endlocal
set "VCINSTALLDIR=%%i\VC\"
set "VS150COMNTOOLS=%%i\Common7\Tools\"
exit /B 0
)
:no-vswhere
endlocal
echo could not find "vswhere"
exit /B 1
+4 -4
View File
@@ -253,7 +253,7 @@
'src/unix/linux-syscalls.h',
'src/unix/pthread-fixes.c',
'src/unix/android-ifaddrs.c',
'src/unix/pthread-barrier.c'
'src/unix/pthread-barrier.c',
'src/unix/procfs-exepath.c',
'src/unix/sysinfo-loadavg.c',
'src/unix/sysinfo-memory.c',
@@ -302,12 +302,12 @@
'sources': [ 'src/unix/openbsd.c' ],
}],
[ 'OS=="netbsd"', {
'sources': [ 'src/unix/netbsd.c' ],
}],
[ 'OS in "freebsd dragonflybsd openbsd netbsd".split()', {
'link_settings': {
'libraries': [ '-lkvm' ],
},
'sources': [ 'src/unix/netbsd.c' ],
}],
[ 'OS in "freebsd dragonflybsd openbsd netbsd".split()', {
'sources': [ 'src/unix/posix-hrtime.c' ],
}],
[ 'OS in "ios mac freebsd dragonflybsd openbsd netbsd".split()', {
+26 -4
View File
@@ -14,10 +14,11 @@ if /i "%1"=="/?" goto help
@rem Process arguments.
set config=
set target=Build
set target_arch=ia32
set target_env=
set noprojgen=
set nobuild=
set run=
set target_arch=ia32
set vs_toolset=x86
set msbuild_platform=WIN32
set library=static_library
@@ -29,6 +30,7 @@ if /i "%1"=="release" set config=Release&goto arg-ok
if /i "%1"=="test" set run=run-tests.exe&goto arg-ok
if /i "%1"=="bench" set run=run-benchmarks.exe&goto arg-ok
if /i "%1"=="clean" set target=Clean&goto arg-ok
if /i "%1"=="vs2017" set target_env=vs2017&goto arg-ok
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
if /i "%1"=="x86" set target_arch=ia32&set msbuild_platform=WIN32&set vs_toolset=x86&goto arg-ok
@@ -41,10 +43,28 @@ shift
goto next-arg
:args-done
if defined WindowsSDKDir goto select-target
if defined VCINSTALLDIR goto select-target
@rem Look for Visual Studio 2017 only if explicitly requested.
if "%target_env%" NEQ "vs2017" goto vs-set-2015
echo Looking for Visual Studio 2017
@rem Check if VS2017 is already setup, and for the requested arch.
if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%vs_toolset%_" goto found_vs2017
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.
set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vs_toolset%
echo calling: %vcvars_call%
call %vcvars_call%
:found_vs2017
echo Found MSVS version %VisualStudioVersion%
if %VSCMD_ARG_TGT_ARCH%==x64 set target_arch=x64&set msbuild_platform=x64&set vs_toolset=x64
set GYP_MSVS_VERSION=2017
goto select-target
@rem Look for Visual Studio 2015
:vs-set-2015
if not defined VS140COMNTOOLS goto vc-set-2013
if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2013
call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
@@ -148,7 +168,9 @@ echo Failed to create vc project files.
exit /b 1
:help
echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared]
echo "vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [vs2017] [x86/x64] [static/shared]"
echo Examples:
echo vcbuild.bat : builds debug build
echo vcbuild.bat test : builds debug build and runs tests