Skip to content

Commit

Permalink
deps: upgrade to libuv 1.29.1
Browse files Browse the repository at this point in the history
Notable changes:

- uv_get_constrained_memory() has been added.
- A race condition in uv_async_send() has been fixed.
- uv_get_free_memory() and uv_get_total_memory() now read from
  /proc/meminfo, which should improve correctness when called
  from inside an lxc container.
- A failed assertion in uv_fs_poll_stop() has been fixed.
- A bug in MAC addresses for IP-aliases has been fixed.

Fixes: #27170
Fixes: #27493
PR-URL: #27718
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cjihrig authored and BridgeAR committed May 22, 2019
1 parent 594c986 commit aed74cc
Show file tree
Hide file tree
Showing 39 changed files with 596 additions and 76 deletions.
1 change: 1 addition & 0 deletions deps/uv/.mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ 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>
ptlomholt <pt@lomholt.com>
zlargon <zlargon1988@gmail.com>
6 changes: 6 additions & 0 deletions deps/uv/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,9 @@ Rich Trott <rtrott@gmail.com>
Milad Farazmand <miladfar@ca.ibm.com>
zlargon <zlargon1988@gmail.com>
Yury Selivanov <yury@magic.io>
Oscar Waddell <owaddell@beckman.com>
FX Coudert <fxcoudert@gmail.com>
George Zhao <zhaozg@gmail.com>
Kyle Edwards <kyle.edwards@kitware.com>
ken-cunningham-webuse <ken.cunningham.webuse@gmail.com>
Kelvin Jin <kelvinjin@google.com>
3 changes: 1 addition & 2 deletions deps/uv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
src/unix/linux-inotify.c
src/unix/linux-syscalls.c
src/unix/procfs-exepath.c
src/unix/sysinfo-loadavg.c
src/unix/sysinfo-memory.c)
src/unix/sysinfo-loadavg.c)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
Expand Down
56 changes: 56 additions & 0 deletions deps/uv/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
2019.05.22, Version 1.29.1 (Stable), d16e6094e1eb3b0b5981ef1dd7e03ec4d466944d

Changes since version 1.29.0:

* unix: simplify uv/posix.h include logic (cjihrig)

* test: increase test timeout (cjihrig)

* linux: fix sscanf() overflows reading from /proc (Ben Noordhuis)


2019.05.16, Version 1.29.0 (Stable), 43957efd92c167b352b4c948b617ca7afbee0ed1

Changes since version 1.28.0:

* ibmi: read memory and CPU usage info (Xu Meng)

* doc: update the cmake testing instruction (zlargon)

* unix: fix race condition in uv_async_send() (Ben Noordhuis)

* linux: use O_CLOEXEC instead of EPOLL_CLOEXEC (Ben Noordhuis)

* doc: mark uv_async_send() as async-signal-safe (Ben Noordhuis)

* linux: init st_flags and st_gen when using statx (Oscar Waddell)

* linux: read free/total memory from /proc/meminfo (Ben Noordhuis)

* test: test zero-sized uv_fs_sendfile() writes (Ben Noordhuis)

* unix: don't assert on UV_PROCESS_WINDOWS_* flags (Ben Noordhuis)

* linux: set correct mac address for IP-aliases (Santiago Gimeno)

* win,util: fix null pointer dereferencing (Tobias Nießen)

* unix,win: fix `uv_fs_poll_stop()` when active (Anna Henningsen)

* doc: add missing uv_fs_type entries (Michele Caini)

* doc: fix build with sphinx 2.x (FX Coudert)

* unix: don't make statx system call on Android (George Zhao)

* unix: fix clang scan-build warning (Kyle Edwards)

* unix: fall back to kqueue on older macOS systems (ken-cunningham-webuse)

* unix,win: add uv_get_constrained_memory() (Kelvin Jin)

* darwin: fix thread cancellation fd leak (Ben Noordhuis)

* linux: fix thread cancellation fd leak (Ben Noordhuis)


2019.04.16, Version 1.28.0 (Stable), 7bf8fabfa934660ee0fe889f78e151198a1165fc

Changes since version 1.27.0:
Expand Down
3 changes: 1 addition & 2 deletions deps/uv/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,7 @@ libuv_la_SOURCES += src/unix/linux-core.c \
src/unix/linux-syscalls.h \
src/unix/procfs-exepath.c \
src/unix/proctitle.c \
src/unix/sysinfo-loadavg.c \
src/unix/sysinfo-memory.c
src/unix/sysinfo-loadavg.c
test_run_tests_LDFLAGS += -lutil
endif

Expand Down
13 changes: 8 additions & 5 deletions deps/uv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,14 @@ $ make install
To build with [CMake](https://cmake.org/):

```bash
$ mkdir -p out/cmake ; cd out/cmake ; cmake -DBUILD_TESTING=ON ../..
$ make all test
# Or manually:
$ ./uv_run_tests # shared library build
$ ./uv_run_tests_a # static library build
$ mkdir -p out/cmake ; cd out/cmake # create build directory
$ cmake ../.. -DBUILD_TESTING=ON # generate project with test
$ cmake --build . # build
$ ctest -C Debug --output-on-failure # run tests

# Or manually run tests:
$ ./out/cmake/uv_run_tests # shared library build
$ ./out/cmake/uv_run_tests_a # static library build
```

To build with GYP, first run:
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

AC_PREREQ(2.57)
AC_INIT([libuv], [1.28.0], [https://github.com/libuv/libuv/issues])
AC_INIT([libuv], [1.29.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])
Expand Down
4 changes: 4 additions & 0 deletions deps/uv/docs/src/async.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ API
It's safe to call this function from any thread. The callback will be called on the
loop thread.
.. note::
:c:func:`uv_async_send` is `async-signal-safe <http://man7.org/linux/man-pages/man7/signal-safety.7.html>`_.
It's safe to call this function from a signal handler.
.. warning::
libuv will coalesce calls to :c:func:`uv_async_send`, that is, not every call to it will
yield an execution of the callback. For example: if :c:func:`uv_async_send` is called 5
Expand Down
5 changes: 4 additions & 1 deletion deps/uv/docs/src/fs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ Data types
UV_FS_FCHOWN,
UV_FS_REALPATH,
UV_FS_COPYFILE,
UV_FS_LCHOWN
UV_FS_LCHOWN,
UV_FS_OPENDIR,
UV_FS_READDIR,
UV_FS_CLOSEDIR
} uv_fs_type;

.. c:type:: uv_dirent_t
Expand Down
13 changes: 13 additions & 0 deletions deps/uv/docs/src/misc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,19 @@ API
Gets memory information (in bytes).
.. c:function:: uint64_t uv_get_constrained_memory(void)
Gets the amount of memory available to the process (in bytes) based on
limits imposed by the OS. If there is no such constraint, or the constraint
is unknown, `0` is returned. Note that it is not unusual for this value to
be less than or greater than :c:func:`uv_get_total_memory`.
.. note::
This function currently only returns a non-zero value on Linux, based
on cgroups if it is present.
.. versionadded:: 1.29.0
.. c:function:: uint64_t uv_hrtime(void)
Returns the current high-resolution real time. This is expressed in
Expand Down
1 change: 0 additions & 1 deletion deps/uv/docs/src/sphinx-plugins/manpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def man_role(name, rawtext, text, lineno, inliner, options={}, content=[]):


def setup(app):
app.info('Initializing manpage plugin')
app.add_role('man', man_role)
app.add_config_value('man_url_regex', None, 'env')
return
Expand Down
1 change: 1 addition & 0 deletions deps/uv/include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@ UV_EXTERN int uv_chdir(const char* dir);

UV_EXTERN uint64_t uv_get_free_memory(void);
UV_EXTERN uint64_t uv_get_total_memory(void);
UV_EXTERN uint64_t uv_get_constrained_memory(void);

UV_EXTERN uint64_t uv_hrtime(void);

Expand Down
9 changes: 4 additions & 5 deletions deps/uv/include/uv/unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
# include "uv/linux.h"
#elif defined (__MVS__)
# include "uv/os390.h"
#elif defined(__PASE__)
# include "uv/posix.h"
#elif defined(_AIX)
# include "uv/aix.h"
#elif defined(__sun)
Expand All @@ -63,9 +61,10 @@
defined(__OpenBSD__) || \
defined(__NetBSD__)
# include "uv/bsd.h"
#elif defined(__CYGWIN__) || defined(__MSYS__)
# include "uv/posix.h"
#elif defined(__GNU__)
#elif defined(__PASE__) || \
defined(__CYGWIN__) || \
defined(__MSYS__) || \
defined(__GNU__)
# include "uv/posix.h"
#endif

Expand Down
4 changes: 2 additions & 2 deletions deps/uv/include/uv/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
*/

#define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 28
#define UV_VERSION_PATCH 0
#define UV_VERSION_MINOR 29
#define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX ""

Expand Down
2 changes: 1 addition & 1 deletion deps/uv/src/fs-poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static void timer_close_cb(uv_handle_t* timer) {
handle = ctx->parent_handle;
if (ctx == handle->poll_ctx) {
handle->poll_ctx = ctx->previous;
if (handle->poll_ctx == NULL)
if (handle->poll_ctx == NULL && uv__is_closing(handle))
uv__make_close_pending((uv_handle_t*)handle);
} else {
for (last = handle->poll_ctx, it = last->previous;
Expand Down
5 changes: 5 additions & 0 deletions deps/uv/src/unix/aix.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ uint64_t uv_get_total_memory(void) {
}


uint64_t uv_get_constrained_memory(void) {
return 0; /* Memory constraints are unknown. */
}


void uv_loadavg(double avg[3]) {
perfstat_cpu_total_t ps_total;
int result = perfstat_cpu_total(NULL, &ps_total, sizeof(ps_total), 1);
Expand Down
37 changes: 33 additions & 4 deletions deps/uv/src/unix/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,43 @@ int uv_async_send(uv_async_t* handle) {
if (ACCESS_ONCE(int, handle->pending) != 0)
return 0;

if (cmpxchgi(&handle->pending, 0, 1) == 0)
uv__async_send(handle->loop);
/* Tell the other thread we're busy with the handle. */
if (cmpxchgi(&handle->pending, 0, 1) != 0)
return 0;

/* Wake up the other thread's event loop. */
uv__async_send(handle->loop);

/* Tell the other thread we're done. */
if (cmpxchgi(&handle->pending, 1, 2) != 1)
abort();

return 0;
}


/* Only call this from the event loop thread. */
static int uv__async_spin(uv_async_t* handle) {
int rc;

for (;;) {
/* rc=0 -- handle is not pending.
* rc=1 -- handle is pending, other thread is still working with it.
* rc=2 -- handle is pending, other thread is done.
*/
rc = cmpxchgi(&handle->pending, 2, 0);

if (rc != 1)
return rc;

/* Other thread is busy with this handle, spin until it's done. */
cpu_relax();
}
}


void uv__async_close(uv_async_t* handle) {
uv__async_spin(handle);
QUEUE_REMOVE(&handle->queue);
uv__handle_stop(handle);
}
Expand Down Expand Up @@ -109,8 +138,8 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
QUEUE_REMOVE(q);
QUEUE_INSERT_TAIL(&loop->async_handles, q);

if (cmpxchgi(&h->pending, 1, 0) == 0)
continue;
if (0 == uv__async_spin(h))
continue; /* Not pending. */

if (h->async_cb == NULL)
continue;
Expand Down
29 changes: 28 additions & 1 deletion deps/uv/src/unix/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
#include <sys/ioctl.h>
#endif

#if defined(__linux__)
#include <sys/syscall.h>
#endif

static int uv__run_pending(uv_loop_t* loop);

/* Verify that uv_buf_t is ABI-compatible with struct iovec. */
Expand Down Expand Up @@ -510,14 +514,37 @@ int uv__accept(int sockfd) {
}


/* close() on macos has the "interesting" quirk that it fails with EINTR
* without closing the file descriptor when a thread is in the cancel state.
* That's why libuv calls close$NOCANCEL() instead.
*
* glibc on linux has a similar issue: close() is a cancellation point and
* will unwind the thread when it's in the cancel state. Work around that
* by making the system call directly. Musl libc is unaffected.
*/
int uv__close_nocancel(int fd) {
#if defined(__APPLE__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
extern int close$NOCANCEL(int);
return close$NOCANCEL(fd);
#pragma GCC diagnostic pop
#elif defined(__linux__)
return syscall(SYS_close, fd);
#else
return close(fd);
#endif
}


int uv__close_nocheckstdio(int fd) {
int saved_errno;
int rc;

assert(fd > -1); /* Catch uninitialized io_watcher.fd bugs. */

saved_errno = errno;
rc = close(fd);
rc = uv__close_nocancel(fd);
if (rc == -1) {
rc = UV__ERR(errno);
if (rc == UV_EINTR || rc == UV__ERR(EINPROGRESS))
Expand Down
5 changes: 5 additions & 0 deletions deps/uv/src/unix/darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ uint64_t uv_get_total_memory(void) {
}


uint64_t uv_get_constrained_memory(void) {
return 0; /* Memory constraints are unknown. */
}


void uv_loadavg(double avg[3]) {
struct loadavg info;
size_t size = sizeof(info);
Expand Down
5 changes: 5 additions & 0 deletions deps/uv/src/unix/freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ uint64_t uv_get_total_memory(void) {
}


uint64_t uv_get_constrained_memory(void) {
return 0; /* Memory constraints are unknown. */
}


void uv_loadavg(double avg[3]) {
struct loadavg info;
size_t size = sizeof(info);
Expand Down
4 changes: 3 additions & 1 deletion deps/uv/src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
static int uv__fs_close(int fd) {
int rc;

rc = close(fd);
rc = uv__close_nocancel(fd);
if (rc == -1)
if (errno == EINTR || errno == EINPROGRESS)
rc = 0; /* The close is in progress, not an error. */
Expand Down Expand Up @@ -1165,6 +1165,8 @@ static int uv__fs_statx(int fd,
buf->st_ctim.tv_nsec = statxbuf.stx_ctime.tv_nsec;
buf->st_birthtim.tv_sec = statxbuf.stx_btime.tv_sec;
buf->st_birthtim.tv_nsec = statxbuf.stx_btime.tv_nsec;
buf->st_flags = 0;
buf->st_gen = 0;

return 0;
#else
Expand Down
3 changes: 2 additions & 1 deletion deps/uv/src/unix/fsevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
#include "uv.h"
#include "internal.h"

#if TARGET_OS_IPHONE
#if TARGET_OS_IPHONE || MAC_OS_X_VERSION_MAX_ALLOWED < 1070

/* iOS (currently) doesn't provide the FSEvents-API (nor CoreServices) */
/* macOS prior to 10.7 doesn't provide the full FSEvents API so use kqueue */

int uv__fsevents_init(uv_fs_event_t* handle) {
return 0;
Expand Down
Loading

0 comments on commit aed74cc

Please sign in to comment.