Skip to content

Commit

Permalink
deps: upgrade to libuv 1.24.1
Browse files Browse the repository at this point in the history
PR-URL: #25078
Fixes: #24521
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
  • Loading branch information
cjihrig authored and MylesBorins committed Dec 25, 2018
1 parent 4f28da8 commit 155d1d5
Show file tree
Hide file tree
Showing 60 changed files with 421 additions and 127 deletions.
2 changes: 1 addition & 1 deletion deps/uv/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Makefile.in
/android-toolchain

/out/
/build/gyp
/build/

/test/.libs/
/test/run-tests
Expand Down
6 changes: 6 additions & 0 deletions deps/uv/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,9 @@ hitesh <sainihitesh.scientist@gmail.com>
Svante Signell <svante.signell@gmail.com>
Samuel Thibault <sthibault@debian.org>
Jeremy Studer <studerj1.mail@gmail.com>
damon-kwok <563066990@qq.com>
Damon Kwok <MedusaIDE@outlook.com>
Ashe Connor <ashe@kivikakk.ee>
Rick <lcw0622@163.com>
Ivan Krylov <krylov.r00t@gmail.com>
Michael Meier <michael.meier@leica-geosystems.com>
8 changes: 7 additions & 1 deletion deps/uv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set(uv_sources
src/fs-poll.c
src/idna.c
src/inet.c
src/strscpy.c
src/threadpool.c
src/timer.c
src/uv-common.c
Expand Down Expand Up @@ -116,6 +117,7 @@ set(uv_test_sources
test/test-socket-buffer-size.c
test/test-spawn.c
test/test-stdio-over-pipes.c
test/test-strscpy.c
test/test-tcp-alloc-cb-fail.c
test/test-tcp-bind-error.c
test/test-tcp-bind6-error.c
Expand Down Expand Up @@ -208,7 +210,11 @@ if(WIN32)
list(APPEND uv_test_sources src/win/snprintf.c test/runner-win.c)
else()
list(APPEND uv_defines _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE)
list(APPEND uv_libraries pthread)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
# Android has pthread as part of its c library, not as a separate
# libpthread.so.
list(APPEND uv_libraries pthread)
endif()
list(APPEND uv_sources
src/unix/async.c
src/unix/core.c
Expand Down
33 changes: 33 additions & 0 deletions deps/uv/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
2018.12.17, Version 1.24.1 (Stable), 274f2bd3b70847cadd9a3965577a87e666ab9ac3

Changes since version 1.24.0:

* test: fix platform_output test on cygwin (damon-kwok)

* gitignore: ignore build/ directory (Damon Kwok)

* unix: zero epoll_event before use (Ashe Connor)

* darwin: use runtime check for file cloning (Ben Noordhuis)

* doc: replace deprecated build command on macOS (Rick)

* warnings: fix code that emits compiler warnings (Jameson Nash)

* doc: clarify expected memory management strategy (Ivan Krylov)

* test: add uv_inet_ntop(AF_INET) coverage (Ben Noordhuis)

* unix: harden string copying, introduce strscpy() (Ben Noordhuis)

* linux: get rid of strncpy() call (Ben Noordhuis)

* aix: get rid of strcat() calls (Ben Noordhuis)

* aix: fix data race in uv_fs_event_start() (Ben Noordhuis)

* win: fs: fix `FILE_FLAG_NO_BUFFERING` for writes (Joran Dirk Greef)

* build: don't link against -lpthread on Android (Michael Meier)


2018.11.14, Version 1.24.0 (Stable), 2d427ee0083d1baf995df4ebf79a3f8890e9a3e1

Changes since version 1.23.2:
Expand Down
3 changes: 3 additions & 0 deletions deps/uv/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ libuv_la_SOURCES = src/fs-poll.c \
src/idna.c \
src/inet.c \
src/queue.h \
src/strscpy.c \
src/strscpy.h \
src/threadpool.c \
src/timer.c \
src/uv-data-getter-setters.c \
Expand Down Expand Up @@ -241,6 +243,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-socket-buffer-size.c \
test/test-spawn.c \
test/test-stdio-over-pipes.c \
test/test-strscpy.c \
test/test-tcp-alloc-cb-fail.c \
test/test-tcp-bind-error.c \
test/test-tcp-bind6-error.c \
Expand Down
3 changes: 1 addition & 2 deletions deps/uv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ Run:

```bash
$ ./gyp_uv.py -f xcode
$ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \
-configuration Release -target All
$ xcodebuild -ARCHS="x86_64" -project out/uv.xcodeproj -configuration Release -alltargets
```

Using Homebrew:
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.24.0], [https://github.com/libuv/libuv/issues])
AC_INIT([libuv], [1.24.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
2 changes: 2 additions & 0 deletions deps/uv/docs/src/handle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ API
Request handle to be closed. `close_cb` will be called asynchronously after
this call. This MUST be called on each handle before memory is released.
Moreover, the memory can only be released in `close_cb` or after it has
returned.
Handles that wrap file descriptors are closed immediately but
`close_cb` will still be deferred to the next iteration of the event loop.
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 @@ -32,7 +32,7 @@

#define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 24
#define UV_VERSION_PATCH 0
#define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX ""

Expand Down
1 change: 1 addition & 0 deletions deps/uv/include/uv/win.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
typedef intptr_t ssize_t;
# define SSIZE_MAX INTPTR_MAX
# define _SSIZE_T_
# define _SSIZE_T_DEFINED
#endif
Expand Down
11 changes: 2 additions & 9 deletions deps/uv/src/inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ static int inet_ntop4(const unsigned char *src, char *dst, size_t size) {
if (l <= 0 || (size_t) l >= size) {
return UV_ENOSPC;
}
strncpy(dst, tmp, size);
dst[size - 1] = '\0';
uv__strscpy(dst, tmp, size);
return 0;
}

Expand Down Expand Up @@ -142,14 +141,8 @@ static int inet_ntop6(const unsigned char *src, char *dst, size_t size) {
if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words))
*tp++ = ':';
*tp++ = '\0';

/*
* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size) {
if (UV_E2BIG == uv__strscpy(dst, tmp, size))
return UV_ENOSPC;
}
strcpy(dst, tmp);
return 0;
}

Expand Down
17 changes: 17 additions & 0 deletions deps/uv/src/strscpy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "strscpy.h"
#include <limits.h> /* SSIZE_MAX */

ssize_t uv__strscpy(char* d, const char* s, size_t n) {
size_t i;

for (i = 0; i < n; i++)
if ('\0' == (d[i] = s[i]))
return i > SSIZE_MAX ? UV_E2BIG : (ssize_t) i;

if (i == 0)
return 0;

d[--i] = '\0';

return UV_E2BIG;
}
18 changes: 18 additions & 0 deletions deps/uv/src/strscpy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef UV_STRSCPY_H_
#define UV_STRSCPY_H_

/* Include uv.h for its definitions of size_t and ssize_t.
* size_t can be obtained directly from <stddef.h> but ssize_t requires
* some hoop jumping on Windows that I didn't want to duplicate here.
*/
#include "uv.h"

/* Copies up to |n-1| bytes from |d| to |s| and always zero-terminates
* the result, except when |n==0|. Returns the number of bytes copied
* or UV_E2BIG if |d| is too small.
*
* See https://www.kernel.org/doc/htmldocs/kernel-api/API-strscpy.html
*/
ssize_t uv__strscpy(char* d, const char* s, size_t n);

#endif /* UV_STRSCPY_H_ */
2 changes: 1 addition & 1 deletion deps/uv/src/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int uv__next_timeout(const uv_loop_t* loop) {
if (diff > INT_MAX)
diff = INT_MAX;

return diff;
return (int) diff;
}


Expand Down
32 changes: 16 additions & 16 deletions deps/uv/src/unix/aix.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,15 @@ void uv_loadavg(double avg[3]) {


#ifdef HAVE_SYS_AHAFS_EVPRODS_H
static char *uv__rawname(char *cp) {
static char rawbuf[FILENAME_MAX+1];
char *dp = rindex(cp, '/');
static char* uv__rawname(const char* cp, char (*dst)[FILENAME_MAX+1]) {
char* dp;

dp = rindex(cp, '/');
if (dp == 0)
return 0;

*dp = 0;
strcpy(rawbuf, cp);
*dp = '/';
strcat(rawbuf, "/r");
strcat(rawbuf, dp+1);
return rawbuf;
snprintf(*dst, sizeof(*dst), "%.*s/r%s", (int) (dp - cp), cp, dp + 1);
return *dst;
}


Expand Down Expand Up @@ -399,6 +395,7 @@ static int uv__path_is_a_directory(char* filename) {
* Returns 0 if AHAFS is mounted, or an error code < 0 on failure
*/
static int uv__is_ahafs_mounted(void){
char rawbuf[FILENAME_MAX+1];
int rv, i = 2;
struct vmount *p;
int size_multiplier = 10;
Expand Down Expand Up @@ -432,7 +429,7 @@ static int uv__is_ahafs_mounted(void){
obj = vmt2dataptr(vmt, VMT_OBJECT); /* device */
stub = vmt2dataptr(vmt, VMT_STUB); /* mount point */

if (EQ(obj, dev) || EQ(uv__rawname(obj), dev) || EQ(stub, dev)) {
if (EQ(obj, dev) || EQ(uv__rawname(obj, &rawbuf), dev) || EQ(stub, dev)) {
uv__free(p); /* Found a match */
return 0;
}
Expand All @@ -453,7 +450,8 @@ static int uv__makedir_p(const char *dir) {
size_t len;
int err;

snprintf(tmp, sizeof(tmp),"%s",dir);
/* TODO(bnoordhuis) Check uv__strscpy() return value. */
uv__strscpy(tmp, dir, sizeof(tmp));
len = strlen(tmp);
if (tmp[len - 1] == '/')
tmp[len - 1] = 0;
Expand Down Expand Up @@ -702,9 +700,9 @@ static void uv__ahafs_event(uv_loop_t* loop, uv__io_t* event_watch, unsigned int
else
p++;
}
strncpy(fname, p, sizeof(fname) - 1);
/* Just in case */
fname[sizeof(fname) - 1] = '\0';

/* TODO(bnoordhuis) Check uv__strscpy() return value. */
uv__strscpy(fname, p, sizeof(fname));

handle->cb(handle, fname, events, 0);
}
Expand Down Expand Up @@ -735,7 +733,8 @@ int uv_fs_event_start(uv_fs_event_t* handle,
/* Figure out whether filename is absolute or not */
if (filename[0] == '/') {
/* We have absolute pathname */
snprintf(absolute_path, sizeof(absolute_path), "%s", filename);
/* TODO(bnoordhuis) Check uv__strscpy() return value. */
uv__strscpy(absolute_path, filename, sizeof(absolute_path));
} else {
/* We have a relative pathname, compose the absolute pathname */
snprintf(cwd, sizeof(cwd), "/proc/%lu/cwd", (unsigned long) getpid());
Expand Down Expand Up @@ -986,7 +985,8 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
return UV_ENOMEM;
}

strcpy(cpu_id.name, FIRST_CPU);
/* TODO(bnoordhuis) Check uv__strscpy() return value. */
uv__strscpy(cpu_id.name, FIRST_CPU, sizeof(cpu_id.name));
result = perfstat_cpu(&cpu_id, ps_cpus, sizeof(perfstat_cpu_t), ncpus);
if (result == -1) {
uv__free(ps_cpus);
Expand Down
3 changes: 1 addition & 2 deletions deps/uv/src/unix/darwin-proctitle.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ void uv__set_process_title(const char* title) {

if (dynamic_pthread_setname_np != NULL) {
char namebuf[64]; /* MAXTHREADNAMESIZE */
strncpy(namebuf, title, sizeof(namebuf) - 1);
namebuf[sizeof(namebuf) - 1] = '\0';
uv__strscpy(namebuf, title, sizeof(namebuf));
dynamic_pthread_setname_np(namebuf);
}
}
42 changes: 31 additions & 11 deletions deps/uv/src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

#if defined(__APPLE__)
# include <copyfile.h>
# include <sys/sysctl.h>
#elif defined(__linux__) && !defined(FICLONE)
# include <sys/ioctl.h>
# define FICLONE _IOW(0x94, 9, int)
Expand All @@ -70,6 +71,10 @@
# include <utime.h>
#endif

#if defined(_AIX) && _XOPEN_SOURCE <= 600
extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
#endif

#define INIT(subtype) \
do { \
if (req == NULL) \
Expand Down Expand Up @@ -722,7 +727,7 @@ static ssize_t uv__fs_utime(uv_fs_t* req) {
atr.att_atimechg = 1;
atr.att_mtime = req->mtime;
atr.att_atime = req->atime;
return __lchattr(req->path, &atr, sizeof(atr));
return __lchattr((char*) req->path, &atr, sizeof(atr));
#else
errno = ENOSYS;
return -1;
Expand Down Expand Up @@ -793,26 +798,41 @@ static ssize_t uv__fs_write(uv_fs_t* req) {
static ssize_t uv__fs_copyfile(uv_fs_t* req) {
#if defined(__APPLE__) && !TARGET_OS_IPHONE
/* On macOS, use the native copyfile(3). */
static int can_clone;
copyfile_flags_t flags;
char buf[64];
size_t len;
int major;

flags = COPYFILE_ALL;

if (req->flags & UV_FS_COPYFILE_EXCL)
flags |= COPYFILE_EXCL;

#ifdef COPYFILE_CLONE
if (req->flags & UV_FS_COPYFILE_FICLONE)
flags |= COPYFILE_CLONE;
#endif

/* Check OS version. Cloning is only supported on macOS >= 10.12. */
if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
#ifdef COPYFILE_CLONE_FORCE
flags |= COPYFILE_CLONE_FORCE;
#else
return UV_ENOSYS;
#endif
if (can_clone == 0) {
len = sizeof(buf);
if (sysctlbyname("kern.osrelease", buf, &len, NULL, 0))
return UV__ERR(errno);

if (1 != sscanf(buf, "%d", &major))
abort();

can_clone = -1 + 2 * (major >= 16); /* macOS >= 10.12 */
}

if (can_clone < 0)
return UV_ENOSYS;
}

/* copyfile() simply ignores COPYFILE_CLONE if it's not supported. */
if (req->flags & UV_FS_COPYFILE_FICLONE)
flags |= 1 << 24; /* COPYFILE_CLONE */

if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE)
flags |= 1 << 25; /* COPYFILE_CLONE_FORCE */

return copyfile(req->path, req->new_path, NULL, flags);
#else
uv_fs_t fs_req;
Expand Down
Loading

0 comments on commit 155d1d5

Please sign in to comment.