Skip to content

Commit

Permalink
deps: upgrade libuv to 1.20.0
Browse files Browse the repository at this point in the history
Notable changes:
- uv_fs_copyfile() adds support for copy-on-write behavior.
- uv_relative_path() now uses the long directory name
  for handle->dirw.
- File operations on files > 2 GB on 32-bit platforms are
  working again.
- uv_fs_fchmod() on Windows works on files with the
  Archive flag cleared.

Backport-PR-URL: #24103
Fixes: #19170
Fixes: #19455
Fixes: #12803
PR-URL: #19758
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cjihrig authored and MylesBorins committed Nov 11, 2018
1 parent 26d145a commit a1b94d3
Show file tree
Hide file tree
Showing 39 changed files with 466 additions and 140 deletions.
1 change: 1 addition & 0 deletions deps/uv/.mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Frank Denis <github@pureftpd.org>
Imran Iqbal <imrani@ca.ibm.com> <imran@imraniqbal.org>
Isaac Z. Schlueter <i@izs.me>
Jason Williams <necmon@yahoo.com>
Jesse Gorzinski <jgorzinski@gmail.com>
Justin Venus <justin.venus@gmail.com> <justin.venus@orbitz.com>
Keno Fischer <kenof@stanford.edu> <kfischer+github@college.harvard.edu>
Keno Fischer <kenof@stanford.edu> <kfischer@college.harvard.edu>
Expand Down
2 changes: 2 additions & 0 deletions deps/uv/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,5 @@ Mason X <me@masonx.ca>
Jesse Gorzinski <jgorzinski@gmail.com>
Ryuichi KAWAMATA <ryuichi.kawamata@dena.jp>
Joyee Cheung <joyeec9h3@gmail.com>
Michael Kilburn <crusader.mike@gmail.com>
Ruslan Bekenev <furyinbox@gmail.com>
50 changes: 50 additions & 0 deletions deps/uv/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
2018.04.03, Version 1.20.0 (Stable), 0012178ee2b04d9e4a2c66c27cf8891ad8325ceb

Changes since version 1.19.2:

* unix,spawn: respect user stdio flags for new pipe (Jameson Nash)

* Revert "Revert "unix,tcp: avoid marking server sockets connected"" (Jameson
Nash)

* req: revisions to uv_req_t handling (Jameson Nash)

* win: remove unnecessary initialization (cjihrig)

* win: update uv_os_homedir() to use uv_os_getenv() (cjihrig)

* test: fix tcp_oob test flakiness (Santiago Gimeno)

* posix: fix uv__pollfds_del() for invalidated fd's (Jesse Gorzinski)

* doc: README: add note on installing gyp (Jamie Davis)

* unix: refactor uv_os_homedir to use uv_os_getenv (Santiago Gimeno)

* unix: fix several instances of lost errno (Michael Kilburn)

* win,tty: update several TODO comments (Ruslan Bekenev)

* unix: add UV_FS_COPYFILE_FICLONE support (cjihrig)

* test: fix connect_unspecified (Santiago Gimeno)

* unix,win: add UV_FS_COPYFILE_FICLONE_FORCE support (cjihrig)

* win: use long directory name for handle->dirw (Nicholas Vavilov)

* build: build with -D_FILE_OFFSET_BITS=64 again (Ben Noordhuis)

* win, fs: fix uv_fs_unlink for +R -A files (Bartosz Sosnowski)

* win, fs: use FILE_WRITE_ATTRIBUTES when opening files (Bartosz Sosnowski)

* unix: use __PASE__ on IBM i platforms (Jesse Gorzinski)

* test,freebsd: fix flaky poll tests (Santiago Gimeno)

* test: increase connection timeout to 1 second (jBarz)

* win,tcp: handle canceled connect with ECANCELED (Jameson Nash)


2018.02.22, Version 1.19.2 (Stable), c5afc37e2a8a70d8ab0da8dac10b77ba78c0488c

Changes since version 1.19.1:
Expand Down
6 changes: 6 additions & 0 deletions deps/uv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ $ make check
$ make install
```

To build with GYP, first run:

```bash
$ git clone https://chromium.googlesource.com/external/gyp build/gyp
```

### Windows

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/checksparse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ AIX)
src/unix/aix.c"
;;
OS400)
SPARSE_FLAGS="$SPARSE_FLAGS -D_PASE=1"
SPARSE_FLAGS="$SPARSE_FLAGS -D__PASE__=1"
SOURCES="$SOURCES
src/unix/aix-common.c
src/unix/ibmi.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.19.2], [https://github.com/libuv/libuv/issues])
AC_INIT([libuv], [1.20.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: 9 additions & 0 deletions deps/uv/docs/src/fs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ API
- `UV_FS_COPYFILE_EXCL`: If present, `uv_fs_copyfile()` will fail with
`UV_EEXIST` if the destination path already exists. The default behavior
is to overwrite the destination if it exists.
- `UV_FS_COPYFILE_FICLONE`: If present, `uv_fs_copyfile()` will attempt to
create a copy-on-write reflink. If the underlying platform does not
support copy-on-write, then a fallback copy mechanism is used.
- `UV_FS_COPYFILE_FICLONE_FORCE`: If present, `uv_fs_copyfile()` will
attempt to create a copy-on-write reflink. If the underlying platform does
not support copy-on-write, then an error is returned.
.. warning::
If the destination path is created, but an error occurs while copying
Expand All @@ -258,6 +264,9 @@ API
.. versionadded:: 1.14.0
.. versionchanged:: 1.20.0 `UV_FS_COPYFILE_FICLONE` and
`UV_FS_COPYFILE_FICLONE_FORCE` are supported.
.. c:function:: int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, uv_file in_fd, int64_t in_offset, size_t length, uv_fs_cb cb)
Limited equivalent to :man:`sendfile(2)`.
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/include/uv-unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
# include "uv-linux.h"
#elif defined (__MVS__)
# include "uv-os390.h"
#elif defined(_PASE)
#elif defined(__PASE__)
# include "uv-posix.h"
#elif defined(_AIX)
# include "uv-aix.h"
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 19
#define UV_VERSION_PATCH 2
#define UV_VERSION_MINOR 20
#define UV_VERSION_PATCH 0
#define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX ""

Expand Down
20 changes: 17 additions & 3 deletions deps/uv/include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ UV_EXTERN const char* uv_err_name(int err);
/* read-only */ \
uv_req_type type; \
/* private */ \
void* active_queue[2]; \
void* reserved[4]; \
void* reserved[6]; \
UV_REQ_PRIVATE_FIELDS \

/* Abstract base class of all requests. */
Expand Down Expand Up @@ -1191,6 +1190,18 @@ UV_EXTERN int uv_fs_write(uv_loop_t* loop,
*/
#define UV_FS_COPYFILE_EXCL 0x0001

/*
* This flag can be used with uv_fs_copyfile() to attempt to create a reflink.
* If copy-on-write is not supported, a fallback copy mechanism is used.
*/
#define UV_FS_COPYFILE_FICLONE 0x0002

/*
* This flag can be used with uv_fs_copyfile() to attempt to create a reflink.
* If copy-on-write is not supported, an error is returned.
*/
#define UV_FS_COPYFILE_FICLONE_FORCE 0x0004

UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
Expand Down Expand Up @@ -1531,7 +1542,10 @@ struct uv_loop_s {
/* Loop reference counting. */
unsigned int active_handles;
void* handle_queue[2];
void* active_reqs[2];
union {
void* unused[2];
unsigned int count;
} active_reqs;
/* Internal flag to signal loop stop. */
unsigned int stop_flag;
UV_LOOP_PRIVATE_FIELDS
Expand Down
27 changes: 7 additions & 20 deletions deps/uv/src/unix/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ int uv__close_nocheckstdio(int fd) {
int uv__close(int fd) {
assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */
#if defined(__MVS__)
epoll_file_close(fd);
SAVE_ERRNO(epoll_file_close(fd));
#endif
return uv__close_nocheckstdio(fd);
}
Expand Down Expand Up @@ -1048,29 +1048,16 @@ int uv__dup2_cloexec(int oldfd, int newfd) {

int uv_os_homedir(char* buffer, size_t* size) {
uv_passwd_t pwd;
char* buf;
size_t len;
int r;

if (buffer == NULL || size == NULL || *size == 0)
return UV_EINVAL;

/* Check if the HOME environment variable is set first */
buf = getenv("HOME");

if (buf != NULL) {
len = strlen(buf);
/* Check if the HOME environment variable is set first. The task of
performing input validation on buffer and size is taken care of by
uv_os_getenv(). */
r = uv_os_getenv("HOME", buffer, size);

if (len >= *size) {
*size = len + 1;
return UV_ENOBUFS;
}

memcpy(buffer, buf, len + 1);
*size = len;

return 0;
}
if (r != UV_ENOENT)
return r;

/* HOME is not set, so call uv__getpwuid_r() */
r = uv__getpwuid_r(&pwd);
Expand Down
44 changes: 43 additions & 1 deletion deps/uv/src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@

#if defined(__APPLE__)
# include <copyfile.h>
#elif defined(__linux__) && !defined(FICLONE)
# include <sys/ioctl.h>
# define FICLONE _IOW(0x94, 9, int)
#endif

#define INIT(subtype) \
Expand Down Expand Up @@ -790,6 +793,19 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
if (req->flags & UV_FS_COPYFILE_EXCL)
flags |= COPYFILE_EXCL;

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

if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
#ifdef COPYFILE_CLONE_FORCE
flags |= COPYFILE_CLONE_FORCE;
#else
return UV_ENOSYS;
#endif
}

return copyfile(req->path, req->new_path, NULL, flags);
#else
uv_fs_t fs_req;
Expand Down Expand Up @@ -842,6 +858,29 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
goto out;
}

#ifdef FICLONE
if (req->flags & UV_FS_COPYFILE_FICLONE ||
req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
if (ioctl(dstfd, FICLONE, srcfd) == -1) {
/* If an error occurred that the sendfile fallback also won't handle, or
this is a force clone then exit. Otherwise, fall through to try using
sendfile(). */
if ((errno != ENOTTY && errno != EOPNOTSUPP && errno != EXDEV) ||
req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
err = -errno;
goto out;
}
} else {
goto out;
}
}
#else
if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
err = UV_ENOSYS;
goto out;
}
#endif

bytes_to_send = statsbuf.st_size;
in_offset = 0;
while (bytes_to_send != 0) {
Expand Down Expand Up @@ -1504,8 +1543,11 @@ int uv_fs_copyfile(uv_loop_t* loop,
uv_fs_cb cb) {
INIT(COPYFILE);

if (flags & ~UV_FS_COPYFILE_EXCL)
if (flags & ~(UV_FS_COPYFILE_EXCL |
UV_FS_COPYFILE_FICLONE |
UV_FS_COPYFILE_FICLONE_FORCE)) {
return UV_EINVAL;
}

PATH2;
req->flags = flags;
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/src/unix/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ int uv__cloexec_ioctl(int fd, int set);
int uv__cloexec_fcntl(int fd, int set);
int uv__nonblock_ioctl(int fd, int set);
int uv__nonblock_fcntl(int fd, int set);
int uv__close(int fd);
int uv__close(int fd); /* preserves errno */
int uv__close_nocheckstdio(int fd);
int uv__socket(int domain, int type, int protocol);
int uv__dup(int fd);
Expand Down
3 changes: 2 additions & 1 deletion deps/uv/src/unix/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ int uv_loop_init(uv_loop_t* loop) {

heap_init((struct heap*) &loop->timer_heap);
QUEUE_INIT(&loop->wq);
QUEUE_INIT(&loop->active_reqs);
QUEUE_INIT(&loop->idle_handles);
QUEUE_INIT(&loop->async_handles);
QUEUE_INIT(&loop->check_handles);
QUEUE_INIT(&loop->prepare_handles);
QUEUE_INIT(&loop->handle_queue);

loop->active_handles = 0;
loop->active_reqs.count = 0;
loop->nfds = 0;
loop->watchers = NULL;
loop->nwatchers = 0;
Expand Down
14 changes: 12 additions & 2 deletions deps/uv/src/unix/posix-poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,25 @@ static void uv__pollfds_add(uv_loop_t* loop, uv__io_t* w) {
static void uv__pollfds_del(uv_loop_t* loop, int fd) {
size_t i;
assert(!loop->poll_fds_iterating);
for (i = 0; i < loop->poll_fds_used; ++i) {
for (i = 0; i < loop->poll_fds_used;) {
if (loop->poll_fds[i].fd == fd) {
/* swap to last position and remove */
--loop->poll_fds_used;
uv__pollfds_swap(loop, i, loop->poll_fds_used);
loop->poll_fds[loop->poll_fds_used].fd = -1;
loop->poll_fds[loop->poll_fds_used].events = 0;
loop->poll_fds[loop->poll_fds_used].revents = 0;
return;
/* This method is called with an fd of -1 to purge the invalidated fds,
* so we may possibly have multiples to remove.
*/
if (-1 != fd)
return;
} else {
/* We must only increment the loop counter when the fds do not match.
* Otherwise, when we are purging an invalidated fd, the value just
* swapped here from the previous end of the array will be skipped.
*/
++i;
}
}
}
Expand Down
17 changes: 7 additions & 10 deletions deps/uv/src/unix/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ static int uv__process_init_stdio(uv_stdio_container_t* container, int fds[2]) {


static int uv__process_open_stream(uv_stdio_container_t* container,
int pipefds[2],
int writable) {
int pipefds[2]) {
int flags;
int err;

Expand All @@ -238,13 +237,11 @@ static int uv__process_open_stream(uv_stdio_container_t* container,
pipefds[1] = -1;
uv__nonblock(pipefds[0], 1);

if (container->data.stream->type == UV_NAMED_PIPE &&
((uv_pipe_t*)container->data.stream)->ipc)
flags = UV_STREAM_READABLE | UV_STREAM_WRITABLE;
else if (writable)
flags = UV_STREAM_WRITABLE;
else
flags = UV_STREAM_READABLE;
flags = 0;
if (container->flags & UV_WRITABLE_PIPE)
flags |= UV_STREAM_READABLE;
if (container->flags & UV_READABLE_PIPE)
flags |= UV_STREAM_WRITABLE;

return uv__stream_open(container->data.stream, pipefds[0], flags);
}
Expand Down Expand Up @@ -533,7 +530,7 @@ int uv_spawn(uv_loop_t* loop,
uv__close_nocheckstdio(signal_pipe[0]);

for (i = 0; i < options->stdio_count; i++) {
err = uv__process_open_stream(options->stdio + i, pipes[i], i == 0);
err = uv__process_open_stream(options->stdio + i, pipes[i]);
if (err == 0)
continue;

Expand Down
Loading

0 comments on commit a1b94d3

Please sign in to comment.