Skip to content

Commit

Permalink
deps: upgrade to libuv 1.26.0
Browse files Browse the repository at this point in the history
Notable changes:
- A bug that could result in 100% CPU utilization in Node
  has been fixed (libuv/libuv#2162)
- Node's report module will now include the entire Windows
  product name (libuv/libuv#2170)

PR-URL: nodejs#26037
Fixes: nodejs#26013
Fixes: nodejs#25875
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
  • Loading branch information
cjihrig committed Feb 13, 2019
1 parent ec76f7c commit 0109e12
Show file tree
Hide file tree
Showing 28 changed files with 613 additions and 58 deletions.
3 changes: 3 additions & 0 deletions deps/uv/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,6 @@ ptlomholt <pt@lomholt.com>
Victor Costan <pwnall@chromium.org>
sid <sidyhe@hotmail.com>
Kevin Adler <kadler@us.ibm.com>
Stephen Belanger <admin@stephenbelanger.com>
yeyuanfeng <yeyuanfeng@bytedance.com>
erw7 <erw7.github@gmail.com>
1 change: 1 addition & 0 deletions deps/uv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ set(uv_test_sources
test/test-timer-from-check.c
test/test-timer.c
test/test-tmpdir.c
test/test-tty-duplicate-key.c
test/test-tty.c
test/test-udp-alloc-cb-fail.c
test/test-udp-bind.c
Expand Down
23 changes: 23 additions & 0 deletions deps/uv/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
2019.02.11, Version 1.26.0 (Stable), 8669d8d3e93cddb62611b267ef62a3ddb5ba3ca0

Changes since version 1.25.0:

* doc: fix uv_get_free_memory doc (Stephen Belanger)

* unix: fix epoll cpu 100% issue (yeyuanfeng)

* openbsd,tcp: special handling of EINVAL on connect (ptlomholt)

* win: simplify registry closing in uv_cpu_info() (cjihrig)

* src,include: define UV_MAXHOSTNAMESIZE (cjihrig)

* win: return product name in uv_os_uname() version (cjihrig)

* thread: allow specifying stack size for new thread (Anna Henningsen)

* win: fix duplicate tty vt100 fn key (erw7)

* unix: don't attempt to invalidate invalid fd (Ben Noordhuis)


2019.01.19, Version 1.25.0 (Stable), 4a10a9d425863330af199e4b74bd688e62d945f1

Changes since version 1.24.1:
Expand Down
1 change: 1 addition & 0 deletions deps/uv/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-timer-from-check.c \
test/test-timer.c \
test/test-tmpdir.c \
test/test-tty-duplicate-key.c \
test/test-tty.c \
test/test-udp-alloc-cb-fail.c \
test/test-udp-bind.c \
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.25.0], [https://github.com/libuv/libuv/issues])
AC_INIT([libuv], [1.26.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])
Expand Down
9 changes: 8 additions & 1 deletion deps/uv/docs/src/misc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,10 @@ API
.. versionadded:: 1.9.0
.. uint64_t uv_get_free_memory(void)
.. c:function:: uint64_t uv_get_free_memory(void)
Gets memory information (in bytes).
.. c:function:: uint64_t uv_get_total_memory(void)
Gets memory information (in bytes).
Expand Down Expand Up @@ -531,6 +534,10 @@ API
.. versionadded:: 1.12.0
.. versionchanged:: 1.26.0 `UV_MAXHOSTNAMESIZE` is available and represents
the maximum `buffer` size required to store a
hostname and terminating `nul` character.
.. c:function:: int uv_os_getpriority(uv_pid_t pid, int* priority)
Retrieves the scheduling priority of the process specified by `pid`. The
Expand Down
29 changes: 29 additions & 0 deletions deps/uv/docs/src/threading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,39 @@ API
Threads
^^^^^^^

.. c:type:: uv_thread_options_t
Options for spawning a new thread (passed to :c:func:`uv_thread_create_ex`).

::

typedef struct uv_process_options_s {
enum {
UV_THREAD_NO_FLAGS = 0x00,
UV_THREAD_HAS_STACK_SIZE = 0x01
} flags;
size_t stack_size;
} uv_process_options_t;

More fields may be added to this struct at any time, so its exact
layout and size should not be relied upon.

.. versionadded:: 1.26.0

.. c:function:: int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg)
.. versionchanged:: 1.4.1 returns a UV_E* error code on failure
.. c:function:: int uv_thread_create_ex(uv_thread_t* tid, const uv_thread_options_t* params, uv_thread_cb entry, void* arg)
Like :c:func:`uv_thread_create`, but additionally specifies options for creating a new thread.
If `UV_THREAD_HAS_STACK_SIZE` is set, `stack_size` specifies a stack size for the new thread.
`0` indicates that the default value should be used, i.e. behaves as if the flag was not set.
Other values will be rounded up to the nearest page boundary.
.. versionadded:: 1.26.0
.. c:function:: uv_thread_t uv_thread_self(void)
.. c:function:: int uv_thread_join(uv_thread_t *tid)
.. c:function:: int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2)
Expand Down
29 changes: 29 additions & 0 deletions deps/uv/include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,17 @@ UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size);
UV_EXTERN int uv_os_setenv(const char* name, const char* value);
UV_EXTERN int uv_os_unsetenv(const char* name);

#ifdef MAXHOSTNAMELEN
# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
#else
/*
Fallback for the maximum hostname size, including the null terminator. The
Windows gethostname() documentation states that 256 bytes will always be
large enough to hold the null-terminated hostname.
*/
# define UV_MAXHOSTNAMESIZE 256
#endif

UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size);

UV_EXTERN int uv_os_uname(uv_utsname_t* buffer);
Expand Down Expand Up @@ -1574,6 +1585,24 @@ UV_EXTERN void uv_key_set(uv_key_t* key, void* value);
typedef void (*uv_thread_cb)(void* arg);

UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);

typedef enum {
UV_THREAD_NO_FLAGS = 0x00,
UV_THREAD_HAS_STACK_SIZE = 0x01
} uv_thread_create_flags;

struct uv_thread_options_s {
unsigned int flags;
size_t stack_size;
/* More fields may be added at any time. */
};

typedef struct uv_thread_options_s uv_thread_options_t;

UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid,
const uv_thread_options_t* params,
uv_thread_cb entry,
void* arg);
UV_EXTERN uv_thread_t uv_thread_self(void);
UV_EXTERN int uv_thread_join(uv_thread_t *tid);
UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2);
Expand Down
3 changes: 2 additions & 1 deletion deps/uv/include/uv/unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netdb.h> /* MAXHOSTNAMELEN on Solaris */

#include <termios.h>
#include <pwd.h>

#if !defined(__MVS__)
#include <semaphore.h>
#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
#endif
#include <pthread.h>
#include <signal.h>
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/include/uv/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/

#define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 25
#define UV_VERSION_MINOR 26
#define UV_VERSION_PATCH 0
#define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX ""
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/aix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
struct poll_ctl pc;

assert(loop->watchers != NULL);
assert(fd >= 0);

events = (struct pollfd*) loop->watchers[loop->nwatchers];
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
Expand Down
15 changes: 3 additions & 12 deletions deps/uv/src/unix/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <sys/utsname.h>

#ifdef __sun
# include <netdb.h> /* MAXHOSTNAMELEN on Solaris */
# include <sys/filio.h>
# include <sys/types.h>
# include <sys/wait.h>
Expand Down Expand Up @@ -88,15 +87,6 @@
#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
#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 @@ -892,7 +882,8 @@ void uv__io_close(uv_loop_t* loop, uv__io_t* w) {
QUEUE_REMOVE(&w->pending_queue);

/* Remove stale events for this file descriptor */
uv__platform_invalidate_fd(loop, w->fd);
if (w->fd != -1)
uv__platform_invalidate_fd(loop, w->fd);
}


Expand Down Expand Up @@ -1291,7 +1282,7 @@ int uv_os_gethostname(char* buffer, size_t* size) {
instead by creating a large enough buffer and comparing the hostname length
to the size input.
*/
char buf[MAXHOSTNAMELEN + 1];
char buf[UV_MAXHOSTNAMESIZE];
size_t len;

if (buffer == NULL || size == NULL || *size == 0)
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
uintptr_t nfds;

assert(loop->watchers != NULL);
assert(fd >= 0);

events = (struct kevent*) loop->watchers[loop->nwatchers];
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/linux-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
uintptr_t nfds;

assert(loop->watchers != NULL);
assert(fd >= 0);

events = (struct epoll_event*) loop->watchers[loop->nwatchers];
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/os390.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
uintptr_t nfds;

assert(loop->watchers != NULL);
assert(fd >= 0);

events = (struct epoll_event*) loop->watchers[loop->nwatchers];
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/src/unix/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void uv_pipe_connect(uv_connect_t* req,
}

if (err == 0)
uv__io_start(handle->loop, &handle->io_watcher, POLLIN | POLLOUT);
uv__io_start(handle->loop, &handle->io_watcher, POLLOUT);

out:
handle->delayed_error = err;
Expand Down
2 changes: 2 additions & 0 deletions deps/uv/src/unix/posix-poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
size_t i;

assert(fd >= 0);

if (loop->poll_fds_iterating) {
/* uv__io_poll is currently iterating. Just invalidate fd. */
for (i = 0; i < loop->poll_fds_used; i++)
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/sunos.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
uintptr_t nfds;

assert(loop->watchers != NULL);
assert(fd >= 0);

events = (struct port_event*) loop->watchers[loop->nwatchers];
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
Expand Down
14 changes: 9 additions & 5 deletions deps/uv/src/unix/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,16 @@ int uv__tcp_connect(uv_connect_t* req,
if (r == -1 && errno != 0) {
if (errno == EINPROGRESS)
; /* not an error */
else if (errno == ECONNREFUSED)
/* If we get a ECONNREFUSED wait until the next tick to report the
* error. Solaris wants to report immediately--other unixes want to
* wait.
else if (errno == ECONNREFUSED
#if defined(__OpenBSD__)
|| errno == EINVAL
#endif
)
/* If we get ECONNREFUSED (Solaris) or EINVAL (OpenBSD) wait until the
* next tick to report the error. Solaris and OpenBSD wants to report
* immediately -- other unixes want to wait.
*/
handle->delayed_error = UV__ERR(errno);
handle->delayed_error = UV__ERR(ECONNREFUSED);
else
return UV__ERR(errno);
}
Expand Down
25 changes: 23 additions & 2 deletions deps/uv/src/unix/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,34 @@ static size_t thread_stack_size(void) {


int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
uv_thread_options_t params;
params.flags = UV_THREAD_NO_FLAGS;
return uv_thread_create_ex(tid, &params, entry, arg);
}

int uv_thread_create_ex(uv_thread_t* tid,
const uv_thread_options_t* params,
void (*entry)(void *arg),
void *arg) {
int err;
size_t stack_size;
pthread_attr_t* attr;
pthread_attr_t attr_storage;
size_t pagesize;
size_t stack_size;

stack_size =
params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;

attr = NULL;
stack_size = thread_stack_size();
if (stack_size == 0) {
stack_size = thread_stack_size();
} else {
pagesize = (size_t)getpagesize();
/* Round up to the nearest page boundary. */
stack_size = (stack_size + pagesize - 1) &~ (pagesize - 1);
if (stack_size < PTHREAD_STACK_MIN)
stack_size = PTHREAD_STACK_MIN;
}

if (stack_size > 0) {
attr = &attr_storage;
Expand Down
27 changes: 26 additions & 1 deletion deps/uv/src/win/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,34 @@ static UINT __stdcall uv__thread_start(void* arg) {


int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
uv_thread_options_t params;
params.flags = UV_THREAD_NO_FLAGS;
return uv_thread_create_ex(tid, &params, entry, arg);
}

int uv_thread_create_ex(uv_thread_t* tid,
const uv_thread_options_t* params,
void (*entry)(void *arg),
void *arg) {
struct thread_ctx* ctx;
int err;
HANDLE thread;
SYSTEM_INFO sysinfo;
size_t stack_size;
size_t pagesize;

stack_size =
params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;

if (stack_size != 0) {
GetNativeSystemInfo(&sysinfo);
pagesize = (size_t)sysinfo.dwPageSize;
/* Round up to the nearest page boundary. */
stack_size = (stack_size + pagesize - 1) &~ (pagesize - 1);

if ((unsigned)stack_size != stack_size)
return UV_EINVAL;
}

ctx = uv__malloc(sizeof(*ctx));
if (ctx == NULL)
Expand All @@ -126,7 +151,7 @@ int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
/* Create the thread in suspended state so we have a chance to pass
* its own creation handle to it */
thread = (HANDLE) _beginthreadex(NULL,
0,
(unsigned)stack_size,
uv__thread_start,
ctx,
CREATE_SUSPENDED,
Expand Down
Loading

0 comments on commit 0109e12

Please sign in to comment.