Skip to content

Commit 46d8af5

Browse files
committed
deps: upgrade to libuv 1.29.1
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 <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0ca9297 commit 46d8af5

39 files changed

+596
-76
lines changed

deps/uv/.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ Yuki Okumura <[email protected]>
4646
4747
4848
ptlomholt <[email protected]>
49+

deps/uv/AUTHORS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,9 @@ Rich Trott <[email protected]>
376376
Milad Farazmand <[email protected]>
377377
378378
Yury Selivanov <[email protected]>
379+
Oscar Waddell <[email protected]>
380+
FX Coudert <[email protected]>
381+
George Zhao <[email protected]>
382+
Kyle Edwards <[email protected]>
383+
ken-cunningham-webuse <[email protected]>
384+
Kelvin Jin <[email protected]>

deps/uv/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
297297
src/unix/linux-inotify.c
298298
src/unix/linux-syscalls.c
299299
src/unix/procfs-exepath.c
300-
src/unix/sysinfo-loadavg.c
301-
src/unix/sysinfo-memory.c)
300+
src/unix/sysinfo-loadavg.c)
302301
endif()
303302

304303
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")

deps/uv/ChangeLog

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
1+
2019.05.22, Version 1.29.1 (Stable), d16e6094e1eb3b0b5981ef1dd7e03ec4d466944d
2+
3+
Changes since version 1.29.0:
4+
5+
* unix: simplify uv/posix.h include logic (cjihrig)
6+
7+
* test: increase test timeout (cjihrig)
8+
9+
* linux: fix sscanf() overflows reading from /proc (Ben Noordhuis)
10+
11+
12+
2019.05.16, Version 1.29.0 (Stable), 43957efd92c167b352b4c948b617ca7afbee0ed1
13+
14+
Changes since version 1.28.0:
15+
16+
* ibmi: read memory and CPU usage info (Xu Meng)
17+
18+
* doc: update the cmake testing instruction (zlargon)
19+
20+
* unix: fix race condition in uv_async_send() (Ben Noordhuis)
21+
22+
* linux: use O_CLOEXEC instead of EPOLL_CLOEXEC (Ben Noordhuis)
23+
24+
* doc: mark uv_async_send() as async-signal-safe (Ben Noordhuis)
25+
26+
* linux: init st_flags and st_gen when using statx (Oscar Waddell)
27+
28+
* linux: read free/total memory from /proc/meminfo (Ben Noordhuis)
29+
30+
* test: test zero-sized uv_fs_sendfile() writes (Ben Noordhuis)
31+
32+
* unix: don't assert on UV_PROCESS_WINDOWS_* flags (Ben Noordhuis)
33+
34+
* linux: set correct mac address for IP-aliases (Santiago Gimeno)
35+
36+
* win,util: fix null pointer dereferencing (Tobias Nießen)
37+
38+
* unix,win: fix `uv_fs_poll_stop()` when active (Anna Henningsen)
39+
40+
* doc: add missing uv_fs_type entries (Michele Caini)
41+
42+
* doc: fix build with sphinx 2.x (FX Coudert)
43+
44+
* unix: don't make statx system call on Android (George Zhao)
45+
46+
* unix: fix clang scan-build warning (Kyle Edwards)
47+
48+
* unix: fall back to kqueue on older macOS systems (ken-cunningham-webuse)
49+
50+
* unix,win: add uv_get_constrained_memory() (Kelvin Jin)
51+
52+
* darwin: fix thread cancellation fd leak (Ben Noordhuis)
53+
54+
* linux: fix thread cancellation fd leak (Ben Noordhuis)
55+
56+
157
2019.04.16, Version 1.28.0 (Stable), 7bf8fabfa934660ee0fe889f78e151198a1165fc
258

359
Changes since version 1.27.0:

deps/uv/Makefile.am

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ libuv_la_SOURCES += src/unix/linux-core.c \
425425
src/unix/linux-syscalls.h \
426426
src/unix/procfs-exepath.c \
427427
src/unix/proctitle.c \
428-
src/unix/sysinfo-loadavg.c \
429-
src/unix/sysinfo-memory.c
428+
src/unix/sysinfo-loadavg.c
430429
test_run_tests_LDFLAGS += -lutil
431430
endif
432431

deps/uv/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,14 @@ $ make install
172172
To build with [CMake](https://cmake.org/):
173173

174174
```bash
175-
$ mkdir -p out/cmake ; cd out/cmake ; cmake -DBUILD_TESTING=ON ../..
176-
$ make all test
177-
# Or manually:
178-
$ ./uv_run_tests # shared library build
179-
$ ./uv_run_tests_a # static library build
175+
$ mkdir -p out/cmake ; cd out/cmake # create build directory
176+
$ cmake ../.. -DBUILD_TESTING=ON # generate project with test
177+
$ cmake --build . # build
178+
$ ctest -C Debug --output-on-failure # run tests
179+
180+
# Or manually run tests:
181+
$ ./out/cmake/uv_run_tests # shared library build
182+
$ ./out/cmake/uv_run_tests_a # static library build
180183
```
181184

182185
To build with GYP, first run:

deps/uv/configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

1515
AC_PREREQ(2.57)
16-
AC_INIT([libuv], [1.28.0], [https://github.com/libuv/libuv/issues])
16+
AC_INIT([libuv], [1.29.1], [https://github.com/libuv/libuv/issues])
1717
AC_CONFIG_MACRO_DIR([m4])
1818
m4_include([m4/libuv-extra-automake-flags.m4])
1919
m4_include([m4/as_case.m4])

deps/uv/docs/src/async.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ API
5050
It's safe to call this function from any thread. The callback will be called on the
5151
loop thread.
5252
53+
.. note::
54+
:c:func:`uv_async_send` is `async-signal-safe <http://man7.org/linux/man-pages/man7/signal-safety.7.html>`_.
55+
It's safe to call this function from a signal handler.
56+
5357
.. warning::
5458
libuv will coalesce calls to :c:func:`uv_async_send`, that is, not every call to it will
5559
yield an execution of the callback. For example: if :c:func:`uv_async_send` is called 5

deps/uv/docs/src/fs.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ Data types
9696
UV_FS_FCHOWN,
9797
UV_FS_REALPATH,
9898
UV_FS_COPYFILE,
99-
UV_FS_LCHOWN
99+
UV_FS_LCHOWN,
100+
UV_FS_OPENDIR,
101+
UV_FS_READDIR,
102+
UV_FS_CLOSEDIR
100103
} uv_fs_type;
101104

102105
.. c:type:: uv_dirent_t

deps/uv/docs/src/misc.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,19 @@ API
461461
462462
Gets memory information (in bytes).
463463
464+
.. c:function:: uint64_t uv_get_constrained_memory(void)
465+
466+
Gets the amount of memory available to the process (in bytes) based on
467+
limits imposed by the OS. If there is no such constraint, or the constraint
468+
is unknown, `0` is returned. Note that it is not unusual for this value to
469+
be less than or greater than :c:func:`uv_get_total_memory`.
470+
471+
.. note::
472+
This function currently only returns a non-zero value on Linux, based
473+
on cgroups if it is present.
474+
475+
.. versionadded:: 1.29.0
476+
464477
.. c:function:: uint64_t uv_hrtime(void)
465478
466479
Returns the current high-resolution real time. This is expressed in

deps/uv/docs/src/sphinx-plugins/manpage.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def man_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
3939

4040

4141
def setup(app):
42-
app.info('Initializing manpage plugin')
4342
app.add_role('man', man_role)
4443
app.add_config_value('man_url_regex', None, 'env')
4544
return

deps/uv/include/uv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,7 @@ UV_EXTERN int uv_chdir(const char* dir);
15611561

15621562
UV_EXTERN uint64_t uv_get_free_memory(void);
15631563
UV_EXTERN uint64_t uv_get_total_memory(void);
1564+
UV_EXTERN uint64_t uv_get_constrained_memory(void);
15641565

15651566
UV_EXTERN uint64_t uv_hrtime(void);
15661567

deps/uv/include/uv/unix.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
# include "uv/linux.h"
5050
#elif defined (__MVS__)
5151
# include "uv/os390.h"
52-
#elif defined(__PASE__)
53-
# include "uv/posix.h"
5452
#elif defined(_AIX)
5553
# include "uv/aix.h"
5654
#elif defined(__sun)
@@ -63,9 +61,10 @@
6361
defined(__OpenBSD__) || \
6462
defined(__NetBSD__)
6563
# include "uv/bsd.h"
66-
#elif defined(__CYGWIN__) || defined(__MSYS__)
67-
# include "uv/posix.h"
68-
#elif defined(__GNU__)
64+
#elif defined(__PASE__) || \
65+
defined(__CYGWIN__) || \
66+
defined(__MSYS__) || \
67+
defined(__GNU__)
6968
# include "uv/posix.h"
7069
#endif
7170

deps/uv/include/uv/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
*/
3232

3333
#define UV_VERSION_MAJOR 1
34-
#define UV_VERSION_MINOR 28
35-
#define UV_VERSION_PATCH 0
34+
#define UV_VERSION_MINOR 29
35+
#define UV_VERSION_PATCH 1
3636
#define UV_VERSION_IS_RELEASE 1
3737
#define UV_VERSION_SUFFIX ""
3838

deps/uv/src/fs-poll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static void timer_close_cb(uv_handle_t* timer) {
241241
handle = ctx->parent_handle;
242242
if (ctx == handle->poll_ctx) {
243243
handle->poll_ctx = ctx->previous;
244-
if (handle->poll_ctx == NULL)
244+
if (handle->poll_ctx == NULL && uv__is_closing(handle))
245245
uv__make_close_pending((uv_handle_t*)handle);
246246
} else {
247247
for (last = handle->poll_ctx, it = last->previous;

deps/uv/src/unix/aix.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ uint64_t uv_get_total_memory(void) {
344344
}
345345

346346

347+
uint64_t uv_get_constrained_memory(void) {
348+
return 0; /* Memory constraints are unknown. */
349+
}
350+
351+
347352
void uv_loadavg(double avg[3]) {
348353
perfstat_cpu_total_t ps_total;
349354
int result = perfstat_cpu_total(NULL, &ps_total, sizeof(ps_total), 1);

deps/uv/src/unix/async.c

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,43 @@ int uv_async_send(uv_async_t* handle) {
6161
if (ACCESS_ONCE(int, handle->pending) != 0)
6262
return 0;
6363

64-
if (cmpxchgi(&handle->pending, 0, 1) == 0)
65-
uv__async_send(handle->loop);
64+
/* Tell the other thread we're busy with the handle. */
65+
if (cmpxchgi(&handle->pending, 0, 1) != 0)
66+
return 0;
67+
68+
/* Wake up the other thread's event loop. */
69+
uv__async_send(handle->loop);
70+
71+
/* Tell the other thread we're done. */
72+
if (cmpxchgi(&handle->pending, 1, 2) != 1)
73+
abort();
6674

6775
return 0;
6876
}
6977

7078

79+
/* Only call this from the event loop thread. */
80+
static int uv__async_spin(uv_async_t* handle) {
81+
int rc;
82+
83+
for (;;) {
84+
/* rc=0 -- handle is not pending.
85+
* rc=1 -- handle is pending, other thread is still working with it.
86+
* rc=2 -- handle is pending, other thread is done.
87+
*/
88+
rc = cmpxchgi(&handle->pending, 2, 0);
89+
90+
if (rc != 1)
91+
return rc;
92+
93+
/* Other thread is busy with this handle, spin until it's done. */
94+
cpu_relax();
95+
}
96+
}
97+
98+
7199
void uv__async_close(uv_async_t* handle) {
100+
uv__async_spin(handle);
72101
QUEUE_REMOVE(&handle->queue);
73102
uv__handle_stop(handle);
74103
}
@@ -109,8 +138,8 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
109138
QUEUE_REMOVE(q);
110139
QUEUE_INSERT_TAIL(&loop->async_handles, q);
111140

112-
if (cmpxchgi(&h->pending, 1, 0) == 0)
113-
continue;
141+
if (0 == uv__async_spin(h))
142+
continue; /* Not pending. */
114143

115144
if (h->async_cb == NULL)
116145
continue;

deps/uv/src/unix/core.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
#include <sys/ioctl.h>
8989
#endif
9090

91+
#if defined(__linux__)
92+
#include <sys/syscall.h>
93+
#endif
94+
9195
static int uv__run_pending(uv_loop_t* loop);
9296

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

512516

517+
/* close() on macos has the "interesting" quirk that it fails with EINTR
518+
* without closing the file descriptor when a thread is in the cancel state.
519+
* That's why libuv calls close$NOCANCEL() instead.
520+
*
521+
* glibc on linux has a similar issue: close() is a cancellation point and
522+
* will unwind the thread when it's in the cancel state. Work around that
523+
* by making the system call directly. Musl libc is unaffected.
524+
*/
525+
int uv__close_nocancel(int fd) {
526+
#if defined(__APPLE__)
527+
#pragma GCC diagnostic push
528+
#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
529+
extern int close$NOCANCEL(int);
530+
return close$NOCANCEL(fd);
531+
#pragma GCC diagnostic pop
532+
#elif defined(__linux__)
533+
return syscall(SYS_close, fd);
534+
#else
535+
return close(fd);
536+
#endif
537+
}
538+
539+
513540
int uv__close_nocheckstdio(int fd) {
514541
int saved_errno;
515542
int rc;
516543

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

519546
saved_errno = errno;
520-
rc = close(fd);
547+
rc = uv__close_nocancel(fd);
521548
if (rc == -1) {
522549
rc = UV__ERR(errno);
523550
if (rc == UV_EINTR || rc == UV__ERR(EINPROGRESS))

deps/uv/src/unix/darwin.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ uint64_t uv_get_total_memory(void) {
117117
}
118118

119119

120+
uint64_t uv_get_constrained_memory(void) {
121+
return 0; /* Memory constraints are unknown. */
122+
}
123+
124+
120125
void uv_loadavg(double avg[3]) {
121126
struct loadavg info;
122127
size_t size = sizeof(info);

deps/uv/src/unix/freebsd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ uint64_t uv_get_total_memory(void) {
137137
}
138138

139139

140+
uint64_t uv_get_constrained_memory(void) {
141+
return 0; /* Memory constraints are unknown. */
142+
}
143+
144+
140145
void uv_loadavg(double avg[3]) {
141146
struct loadavg info;
142147
size_t size = sizeof(info);

deps/uv/src/unix/fs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
145145
static int uv__fs_close(int fd) {
146146
int rc;
147147

148-
rc = close(fd);
148+
rc = uv__close_nocancel(fd);
149149
if (rc == -1)
150150
if (errno == EINTR || errno == EINPROGRESS)
151151
rc = 0; /* The close is in progress, not an error. */
@@ -1165,6 +1165,8 @@ static int uv__fs_statx(int fd,
11651165
buf->st_ctim.tv_nsec = statxbuf.stx_ctime.tv_nsec;
11661166
buf->st_birthtim.tv_sec = statxbuf.stx_btime.tv_sec;
11671167
buf->st_birthtim.tv_nsec = statxbuf.stx_btime.tv_nsec;
1168+
buf->st_flags = 0;
1169+
buf->st_gen = 0;
11681170

11691171
return 0;
11701172
#else

deps/uv/src/unix/fsevents.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
#include "uv.h"
2222
#include "internal.h"
2323

24-
#if TARGET_OS_IPHONE
24+
#if TARGET_OS_IPHONE || MAC_OS_X_VERSION_MAX_ALLOWED < 1070
2525

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

2829
int uv__fsevents_init(uv_fs_event_t* handle) {
2930
return 0;

0 commit comments

Comments
 (0)