Skip to content

Commit a1b94d3

Browse files
cjihrigMylesBorins
authored andcommitted
deps: upgrade libuv to 1.20.0
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 <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 26d145a commit a1b94d3

39 files changed

+466
-140
lines changed

deps/uv/.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Frank Denis <[email protected]>
1616
1717
Isaac Z. Schlueter <[email protected]>
1818
Jason Williams <[email protected]>
19+
Jesse Gorzinski <[email protected]>
1920
2021
2122

deps/uv/AUTHORS

+2
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,5 @@ Mason X <[email protected]>
330330
Jesse Gorzinski <[email protected]>
331331
Ryuichi KAWAMATA <[email protected]>
332332
Joyee Cheung <[email protected]>
333+
Michael Kilburn <[email protected]>
334+
Ruslan Bekenev <[email protected]>

deps/uv/ChangeLog

+50
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
1+
2018.04.03, Version 1.20.0 (Stable), 0012178ee2b04d9e4a2c66c27cf8891ad8325ceb
2+
3+
Changes since version 1.19.2:
4+
5+
* unix,spawn: respect user stdio flags for new pipe (Jameson Nash)
6+
7+
* Revert "Revert "unix,tcp: avoid marking server sockets connected"" (Jameson
8+
Nash)
9+
10+
* req: revisions to uv_req_t handling (Jameson Nash)
11+
12+
* win: remove unnecessary initialization (cjihrig)
13+
14+
* win: update uv_os_homedir() to use uv_os_getenv() (cjihrig)
15+
16+
* test: fix tcp_oob test flakiness (Santiago Gimeno)
17+
18+
* posix: fix uv__pollfds_del() for invalidated fd's (Jesse Gorzinski)
19+
20+
* doc: README: add note on installing gyp (Jamie Davis)
21+
22+
* unix: refactor uv_os_homedir to use uv_os_getenv (Santiago Gimeno)
23+
24+
* unix: fix several instances of lost errno (Michael Kilburn)
25+
26+
* win,tty: update several TODO comments (Ruslan Bekenev)
27+
28+
* unix: add UV_FS_COPYFILE_FICLONE support (cjihrig)
29+
30+
* test: fix connect_unspecified (Santiago Gimeno)
31+
32+
* unix,win: add UV_FS_COPYFILE_FICLONE_FORCE support (cjihrig)
33+
34+
* win: use long directory name for handle->dirw (Nicholas Vavilov)
35+
36+
* build: build with -D_FILE_OFFSET_BITS=64 again (Ben Noordhuis)
37+
38+
* win, fs: fix uv_fs_unlink for +R -A files (Bartosz Sosnowski)
39+
40+
* win, fs: use FILE_WRITE_ATTRIBUTES when opening files (Bartosz Sosnowski)
41+
42+
* unix: use __PASE__ on IBM i platforms (Jesse Gorzinski)
43+
44+
* test,freebsd: fix flaky poll tests (Santiago Gimeno)
45+
46+
* test: increase connection timeout to 1 second (jBarz)
47+
48+
* win,tcp: handle canceled connect with ECANCELED (Jameson Nash)
49+
50+
151
2018.02.22, Version 1.19.2 (Stable), c5afc37e2a8a70d8ab0da8dac10b77ba78c0488c
252

353
Changes since version 1.19.1:

deps/uv/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ $ make check
169169
$ make install
170170
```
171171

172+
To build with GYP, first run:
173+
174+
```bash
175+
$ git clone https://chromium.googlesource.com/external/gyp build/gyp
176+
```
177+
172178
### Windows
173179

174180
Prerequisites:

deps/uv/checksparse.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ AIX)
184184
src/unix/aix.c"
185185
;;
186186
OS400)
187-
SPARSE_FLAGS="$SPARSE_FLAGS -D_PASE=1"
187+
SPARSE_FLAGS="$SPARSE_FLAGS -D__PASE__=1"
188188
SOURCES="$SOURCES
189189
src/unix/aix-common.c
190190
src/unix/ibmi.c

deps/uv/configure.ac

+1-1
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.19.2], [https://github.com/libuv/libuv/issues])
16+
AC_INIT([libuv], [1.20.0], [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/fs.rst

+9
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ API
249249
- `UV_FS_COPYFILE_EXCL`: If present, `uv_fs_copyfile()` will fail with
250250
`UV_EEXIST` if the destination path already exists. The default behavior
251251
is to overwrite the destination if it exists.
252+
- `UV_FS_COPYFILE_FICLONE`: If present, `uv_fs_copyfile()` will attempt to
253+
create a copy-on-write reflink. If the underlying platform does not
254+
support copy-on-write, then a fallback copy mechanism is used.
255+
- `UV_FS_COPYFILE_FICLONE_FORCE`: If present, `uv_fs_copyfile()` will
256+
attempt to create a copy-on-write reflink. If the underlying platform does
257+
not support copy-on-write, then an error is returned.
252258
253259
.. warning::
254260
If the destination path is created, but an error occurs while copying
@@ -258,6 +264,9 @@ API
258264
259265
.. versionadded:: 1.14.0
260266
267+
.. versionchanged:: 1.20.0 `UV_FS_COPYFILE_FICLONE` and
268+
`UV_FS_COPYFILE_FICLONE_FORCE` are supported.
269+
261270
.. 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)
262271
263272
Limited equivalent to :man:`sendfile(2)`.

deps/uv/include/uv-unix.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
# include "uv-linux.h"
4949
#elif defined (__MVS__)
5050
# include "uv-os390.h"
51-
#elif defined(_PASE)
51+
#elif defined(__PASE__)
5252
# include "uv-posix.h"
5353
#elif defined(_AIX)
5454
# include "uv-aix.h"

deps/uv/include/uv-version.h

+2-2
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 19
35-
#define UV_VERSION_PATCH 2
34+
#define UV_VERSION_MINOR 20
35+
#define UV_VERSION_PATCH 0
3636
#define UV_VERSION_IS_RELEASE 1
3737
#define UV_VERSION_SUFFIX ""
3838

deps/uv/include/uv.h

+17-3
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,7 @@ UV_EXTERN const char* uv_err_name(int err);
378378
/* read-only */ \
379379
uv_req_type type; \
380380
/* private */ \
381-
void* active_queue[2]; \
382-
void* reserved[4]; \
381+
void* reserved[6]; \
383382
UV_REQ_PRIVATE_FIELDS \
384383

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

1193+
/*
1194+
* This flag can be used with uv_fs_copyfile() to attempt to create a reflink.
1195+
* If copy-on-write is not supported, a fallback copy mechanism is used.
1196+
*/
1197+
#define UV_FS_COPYFILE_FICLONE 0x0002
1198+
1199+
/*
1200+
* This flag can be used with uv_fs_copyfile() to attempt to create a reflink.
1201+
* If copy-on-write is not supported, an error is returned.
1202+
*/
1203+
#define UV_FS_COPYFILE_FICLONE_FORCE 0x0004
1204+
11941205
UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop,
11951206
uv_fs_t* req,
11961207
const char* path,
@@ -1531,7 +1542,10 @@ struct uv_loop_s {
15311542
/* Loop reference counting. */
15321543
unsigned int active_handles;
15331544
void* handle_queue[2];
1534-
void* active_reqs[2];
1545+
union {
1546+
void* unused[2];
1547+
unsigned int count;
1548+
} active_reqs;
15351549
/* Internal flag to signal loop stop. */
15361550
unsigned int stop_flag;
15371551
UV_LOOP_PRIVATE_FIELDS

deps/uv/src/unix/core.c

+7-20
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ int uv__close_nocheckstdio(int fd) {
536536
int uv__close(int fd) {
537537
assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */
538538
#if defined(__MVS__)
539-
epoll_file_close(fd);
539+
SAVE_ERRNO(epoll_file_close(fd));
540540
#endif
541541
return uv__close_nocheckstdio(fd);
542542
}
@@ -1048,29 +1048,16 @@ int uv__dup2_cloexec(int oldfd, int newfd) {
10481048

10491049
int uv_os_homedir(char* buffer, size_t* size) {
10501050
uv_passwd_t pwd;
1051-
char* buf;
10521051
size_t len;
10531052
int r;
10541053

1055-
if (buffer == NULL || size == NULL || *size == 0)
1056-
return UV_EINVAL;
1057-
1058-
/* Check if the HOME environment variable is set first */
1059-
buf = getenv("HOME");
1060-
1061-
if (buf != NULL) {
1062-
len = strlen(buf);
1054+
/* Check if the HOME environment variable is set first. The task of
1055+
performing input validation on buffer and size is taken care of by
1056+
uv_os_getenv(). */
1057+
r = uv_os_getenv("HOME", buffer, size);
10631058

1064-
if (len >= *size) {
1065-
*size = len + 1;
1066-
return UV_ENOBUFS;
1067-
}
1068-
1069-
memcpy(buffer, buf, len + 1);
1070-
*size = len;
1071-
1072-
return 0;
1073-
}
1059+
if (r != UV_ENOENT)
1060+
return r;
10741061

10751062
/* HOME is not set, so call uv__getpwuid_r() */
10761063
r = uv__getpwuid_r(&pwd);

deps/uv/src/unix/fs.c

+43-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262

6363
#if defined(__APPLE__)
6464
# include <copyfile.h>
65+
#elif defined(__linux__) && !defined(FICLONE)
66+
# include <sys/ioctl.h>
67+
# define FICLONE _IOW(0x94, 9, int)
6568
#endif
6669

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

796+
#ifdef COPYFILE_CLONE
797+
if (req->flags & UV_FS_COPYFILE_FICLONE)
798+
flags |= COPYFILE_CLONE;
799+
#endif
800+
801+
if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
802+
#ifdef COPYFILE_CLONE_FORCE
803+
flags |= COPYFILE_CLONE_FORCE;
804+
#else
805+
return UV_ENOSYS;
806+
#endif
807+
}
808+
793809
return copyfile(req->path, req->new_path, NULL, flags);
794810
#else
795811
uv_fs_t fs_req;
@@ -842,6 +858,29 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
842858
goto out;
843859
}
844860

861+
#ifdef FICLONE
862+
if (req->flags & UV_FS_COPYFILE_FICLONE ||
863+
req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
864+
if (ioctl(dstfd, FICLONE, srcfd) == -1) {
865+
/* If an error occurred that the sendfile fallback also won't handle, or
866+
this is a force clone then exit. Otherwise, fall through to try using
867+
sendfile(). */
868+
if ((errno != ENOTTY && errno != EOPNOTSUPP && errno != EXDEV) ||
869+
req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
870+
err = -errno;
871+
goto out;
872+
}
873+
} else {
874+
goto out;
875+
}
876+
}
877+
#else
878+
if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
879+
err = UV_ENOSYS;
880+
goto out;
881+
}
882+
#endif
883+
845884
bytes_to_send = statsbuf.st_size;
846885
in_offset = 0;
847886
while (bytes_to_send != 0) {
@@ -1504,8 +1543,11 @@ int uv_fs_copyfile(uv_loop_t* loop,
15041543
uv_fs_cb cb) {
15051544
INIT(COPYFILE);
15061545

1507-
if (flags & ~UV_FS_COPYFILE_EXCL)
1546+
if (flags & ~(UV_FS_COPYFILE_EXCL |
1547+
UV_FS_COPYFILE_FICLONE |
1548+
UV_FS_COPYFILE_FICLONE_FORCE)) {
15081549
return UV_EINVAL;
1550+
}
15091551

15101552
PATH2;
15111553
req->flags = flags;

deps/uv/src/unix/internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ int uv__cloexec_ioctl(int fd, int set);
190190
int uv__cloexec_fcntl(int fd, int set);
191191
int uv__nonblock_ioctl(int fd, int set);
192192
int uv__nonblock_fcntl(int fd, int set);
193-
int uv__close(int fd);
193+
int uv__close(int fd); /* preserves errno */
194194
int uv__close_nocheckstdio(int fd);
195195
int uv__socket(int domain, int type, int protocol);
196196
int uv__dup(int fd);

deps/uv/src/unix/loop.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ int uv_loop_init(uv_loop_t* loop) {
3838

3939
heap_init((struct heap*) &loop->timer_heap);
4040
QUEUE_INIT(&loop->wq);
41-
QUEUE_INIT(&loop->active_reqs);
4241
QUEUE_INIT(&loop->idle_handles);
4342
QUEUE_INIT(&loop->async_handles);
4443
QUEUE_INIT(&loop->check_handles);
4544
QUEUE_INIT(&loop->prepare_handles);
4645
QUEUE_INIT(&loop->handle_queue);
4746

47+
loop->active_handles = 0;
48+
loop->active_reqs.count = 0;
4849
loop->nfds = 0;
4950
loop->watchers = NULL;
5051
loop->nwatchers = 0;

deps/uv/src/unix/posix-poll.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,25 @@ static void uv__pollfds_add(uv_loop_t* loop, uv__io_t* w) {
107107
static void uv__pollfds_del(uv_loop_t* loop, int fd) {
108108
size_t i;
109109
assert(!loop->poll_fds_iterating);
110-
for (i = 0; i < loop->poll_fds_used; ++i) {
110+
for (i = 0; i < loop->poll_fds_used;) {
111111
if (loop->poll_fds[i].fd == fd) {
112112
/* swap to last position and remove */
113113
--loop->poll_fds_used;
114114
uv__pollfds_swap(loop, i, loop->poll_fds_used);
115115
loop->poll_fds[loop->poll_fds_used].fd = -1;
116116
loop->poll_fds[loop->poll_fds_used].events = 0;
117117
loop->poll_fds[loop->poll_fds_used].revents = 0;
118-
return;
118+
/* This method is called with an fd of -1 to purge the invalidated fds,
119+
* so we may possibly have multiples to remove.
120+
*/
121+
if (-1 != fd)
122+
return;
123+
} else {
124+
/* We must only increment the loop counter when the fds do not match.
125+
* Otherwise, when we are purging an invalidated fd, the value just
126+
* swapped here from the previous end of the array will be skipped.
127+
*/
128+
++i;
119129
}
120130
}
121131
}

deps/uv/src/unix/process.c

+7-10
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ static int uv__process_init_stdio(uv_stdio_container_t* container, int fds[2]) {
223223

224224

225225
static int uv__process_open_stream(uv_stdio_container_t* container,
226-
int pipefds[2],
227-
int writable) {
226+
int pipefds[2]) {
228227
int flags;
229228
int err;
230229

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

241-
if (container->data.stream->type == UV_NAMED_PIPE &&
242-
((uv_pipe_t*)container->data.stream)->ipc)
243-
flags = UV_STREAM_READABLE | UV_STREAM_WRITABLE;
244-
else if (writable)
245-
flags = UV_STREAM_WRITABLE;
246-
else
247-
flags = UV_STREAM_READABLE;
240+
flags = 0;
241+
if (container->flags & UV_WRITABLE_PIPE)
242+
flags |= UV_STREAM_READABLE;
243+
if (container->flags & UV_READABLE_PIPE)
244+
flags |= UV_STREAM_WRITABLE;
248245

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

535532
for (i = 0; i < options->stdio_count; i++) {
536-
err = uv__process_open_stream(options->stdio + i, pipes[i], i == 0);
533+
err = uv__process_open_stream(options->stdio + i, pipes[i]);
537534
if (err == 0)
538535
continue;
539536

0 commit comments

Comments
 (0)