Skip to content

Commit ffd938a

Browse files
cjihrigitaloacasas
authored andcommitted
deps: upgrade libuv to 1.10.2
Refs: #9439 Fixes: #9464 Fixes: #9690 PR-URL: #10717 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Saúl Ibarra Corretgé <[email protected]>
1 parent 30926ac commit ffd938a

17 files changed

+275
-33
lines changed

deps/uv/AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,4 @@ Brad King <[email protected]>
278278
Philippe Laferriere <[email protected]>
279279
Will Speak <[email protected]>
280280
Hitesh Kanwathirtha <[email protected]>
281+
Eric Sciple <[email protected]>

deps/uv/ChangeLog

+28
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
2017.01.10, Version 1.10.2 (Stable), cb9f579a454b8db592030ffa274ae58df78dbe20
2+
3+
Changes since version 1.10.1:
4+
5+
* Now working on version 1.10.2 (cjihrig)
6+
7+
* darwin: fix fsync and fdatasync (Joran Dirk Greef)
8+
9+
* Revert "Revert "win,tty: add support for ANSI codes in win10 v1511""
10+
(Santiago Gimeno)
11+
12+
* win,tty: fix MultiByteToWideChar output buffer (Santiago Gimeno)
13+
14+
* win: remove dead code related to BACKUP_SEMANTICS (Sam Roberts)
15+
16+
* win: fix comment in quote_cmd_arg (Eric Sciple)
17+
18+
* darwin: use clock_gettime in macOS 10.12 (Saúl Ibarra Corretgé)
19+
20+
* win, tty: fix crash on restarting with pending data (Nicholas Vavilov)
21+
22+
* fs: fix uv__to_stat on BSD platforms (Santiago Gimeno)
23+
24+
* win: map ERROR_ELEVATION_REQUIRED to UV_EACCES (Richard Lau)
25+
26+
* win: fix free() on bad input in uv_getaddrinfo() (Ben Noordhuis)
27+
28+
129
2016.11.17, Version 1.10.1 (Stable), 2e49e332bdede6db7cf17fa784a902e8386d5d86
230

331
Changes since version 1.10.0:

deps/uv/appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: v1.10.1.build{build}
1+
version: v1.10.2.build{build}
22

33
install:
44
- cinst -y nsis

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.10.1], [https://github.com./libuv/libuv/issues])
16+
AC_INIT([libuv], [1.10.2], [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/include/uv-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#define UV_VERSION_MAJOR 1
3434
#define UV_VERSION_MINOR 10
35-
#define UV_VERSION_PATCH 1
35+
#define UV_VERSION_PATCH 2
3636
#define UV_VERSION_IS_RELEASE 1
3737
#define UV_VERSION_SUFFIX ""
3838

deps/uv/src/unix/darwin.c

+10
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@
3434
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
3535
#include <sys/resource.h>
3636
#include <sys/sysctl.h>
37+
#include <time.h>
3738
#include <unistd.h> /* sysconf */
3839

40+
#undef NANOSEC
41+
#define NANOSEC ((uint64_t) 1e9)
42+
3943

4044
int uv__platform_loop_init(uv_loop_t* loop) {
4145
loop->cf_state = NULL;
@@ -53,6 +57,11 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
5357

5458

5559
uint64_t uv__hrtime(uv_clocktype_t type) {
60+
#ifdef MAC_OS_X_VERSION_10_12
61+
struct timespec ts;
62+
clock_gettime(CLOCK_MONOTONIC, &ts);
63+
return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec);
64+
#else
5665
static mach_timebase_info_data_t info;
5766

5867
if ((ACCESS_ONCE(uint32_t, info.numer) == 0 ||
@@ -61,6 +70,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) {
6170
abort();
6271

6372
return mach_absolute_time() * info.numer / info.denom;
73+
#endif
6474
}
6575

6676

deps/uv/src/unix/fs.c

+23-6
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,23 @@
129129
static ssize_t uv__fs_fdatasync(uv_fs_t* req) {
130130
#if defined(__linux__) || defined(__sun) || defined(__NetBSD__)
131131
return fdatasync(req->file);
132-
#elif defined(__APPLE__) && defined(SYS_fdatasync)
133-
return syscall(SYS_fdatasync, req->file);
132+
#elif defined(__APPLE__)
133+
/* Apple's fdatasync and fsync explicitly do NOT flush the drive write cache
134+
* to the drive platters. This is in contrast to Linux's fdatasync and fsync
135+
* which do, according to recent man pages. F_FULLFSYNC is Apple's equivalent
136+
* for flushing buffered data to permanent storage.
137+
*/
138+
return fcntl(req->file, F_FULLFSYNC);
139+
#else
140+
return fsync(req->file);
141+
#endif
142+
}
143+
144+
145+
static ssize_t uv__fs_fsync(uv_fs_t* req) {
146+
#if defined(__APPLE__)
147+
/* See the comment in uv__fs_fdatasync. */
148+
return fcntl(req->file, F_FULLFSYNC);
134149
#else
135150
return fsync(req->file);
136151
#endif
@@ -798,6 +813,10 @@ static void uv__to_stat(struct stat* src, uv_stat_t* dst) {
798813
dst->st_flags = 0;
799814
dst->st_gen = 0;
800815
#elif !defined(_AIX) && ( \
816+
defined(__DragonFly__) || \
817+
defined(__FreeBSD__) || \
818+
defined(__OpenBSD__) || \
819+
defined(__NetBSD__) || \
801820
defined(_GNU_SOURCE) || \
802821
defined(_BSD_SOURCE) || \
803822
defined(_SVID_SOURCE) || \
@@ -809,9 +828,7 @@ static void uv__to_stat(struct stat* src, uv_stat_t* dst) {
809828
dst->st_mtim.tv_nsec = src->st_mtim.tv_nsec;
810829
dst->st_ctim.tv_sec = src->st_ctim.tv_sec;
811830
dst->st_ctim.tv_nsec = src->st_ctim.tv_nsec;
812-
# if defined(__DragonFly__) || \
813-
defined(__FreeBSD__) || \
814-
defined(__OpenBSD__) || \
831+
# if defined(__FreeBSD__) || \
815832
defined(__NetBSD__)
816833
dst->st_birthtim.tv_sec = src->st_birthtim.tv_sec;
817834
dst->st_birthtim.tv_nsec = src->st_birthtim.tv_nsec;
@@ -945,7 +962,7 @@ static void uv__fs_work(struct uv__work* w) {
945962
X(FCHOWN, fchown(req->file, req->uid, req->gid));
946963
X(FDATASYNC, uv__fs_fdatasync(req));
947964
X(FSTAT, uv__fs_fstat(req->file, &req->statbuf));
948-
X(FSYNC, fsync(req->file));
965+
X(FSYNC, uv__fs_fsync(req));
949966
X(FTRUNCATE, ftruncate(req->file, req->off));
950967
X(FUTIME, uv__fs_futime(req));
951968
X(LSTAT, uv__fs_lstat(req->path, &req->statbuf));

deps/uv/src/win/error.c

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ int uv_translate_sys_error(int sys_errno) {
7171
switch (sys_errno) {
7272
case ERROR_NOACCESS: return UV_EACCES;
7373
case WSAEACCES: return UV_EACCES;
74+
case ERROR_ELEVATION_REQUIRED: return UV_EACCES;
7475
case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE;
7576
case WSAEADDRINUSE: return UV_EADDRINUSE;
7677
case WSAEADDRNOTAVAIL: return UV_EADDRNOTAVAIL;

deps/uv/src/win/fs.c

-2
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ void fs__open(uv_fs_t* req) {
403403
switch (flags & (_O_RDONLY | _O_WRONLY | _O_RDWR)) {
404404
case _O_RDONLY:
405405
access = FILE_GENERIC_READ;
406-
attributes |= FILE_FLAG_BACKUP_SEMANTICS;
407406
break;
408407
case _O_WRONLY:
409408
access = FILE_GENERIC_WRITE;
@@ -418,7 +417,6 @@ void fs__open(uv_fs_t* req) {
418417
if (flags & _O_APPEND) {
419418
access &= ~FILE_WRITE_DATA;
420419
access |= FILE_APPEND_DATA;
421-
attributes &= ~FILE_FLAG_BACKUP_SEMANTICS;
422420
}
423421

424422
/*

deps/uv/src/win/getaddrinfo.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
262262
int err;
263263

264264
if (req == NULL || (node == NULL && service == NULL)) {
265-
err = WSAEINVAL;
266-
goto error;
265+
return UV_EINVAL;
267266
}
268267

269268
uv_req_init(loop, (uv_req_t*)req);

deps/uv/src/win/process.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ WCHAR* quote_cmd_arg(const WCHAR *source, WCHAR *target) {
492492
* input : hello\\"world
493493
* output: "hello\\\\\"world"
494494
* input : hello world\
495-
* output: "hello world\"
495+
* output: "hello world\\"
496496
*/
497497

498498
*(target++) = L'"';

deps/uv/src/win/tty.c

+97-10
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@
5656
#define ANSI_BACKSLASH_SEEN 0x80
5757

5858
#define MAX_INPUT_BUFFER_LENGTH 8192
59+
#define MAX_CONSOLE_CHAR 8192
5960

61+
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
62+
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
63+
#endif
6064

6165
static void uv_tty_capture_initial_style(CONSOLE_SCREEN_BUFFER_INFO* info);
6266
static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info);
@@ -125,6 +129,14 @@ static char uv_tty_default_fg_bright = 0;
125129
static char uv_tty_default_bg_bright = 0;
126130
static char uv_tty_default_inverse = 0;
127131

132+
typedef enum {
133+
UV_SUPPORTED,
134+
UV_UNCHECKED,
135+
UV_UNSUPPORTED
136+
} uv_vtermstate_t;
137+
/* Determine whether or not ANSI support is enabled. */
138+
static uv_vtermstate_t uv__vterm_state = UV_UNCHECKED;
139+
static void uv__determine_vterm_state(HANDLE handle);
128140

129141
void uv_console_init() {
130142
if (uv_sem_init(&uv_tty_output_lock, 1))
@@ -168,6 +180,9 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) {
168180
/* shared between all uv_tty_t handles. */
169181
uv_sem_wait(&uv_tty_output_lock);
170182

183+
if (uv__vterm_state == UV_UNCHECKED)
184+
uv__determine_vterm_state(handle);
185+
171186
/* Store the global tty output handle. This handle is used by TTY read */
172187
/* streams to update the virtual window when a CONSOLE_BUFFER_SIZE_EVENT */
173188
/* is received. */
@@ -989,6 +1004,9 @@ int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb,
9891004
if (handle->tty.rd.last_key_len > 0) {
9901005
SET_REQ_SUCCESS(&handle->read_req);
9911006
uv_insert_pending_req(handle->loop, (uv_req_t*) &handle->read_req);
1007+
/* Make sure no attempt is made to insert it again until it's handled. */
1008+
handle->flags |= UV_HANDLE_READ_PENDING;
1009+
handle->reqs_pending++;
9921010
return 0;
9931011
}
9941012

@@ -1602,17 +1620,29 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
16021620
DWORD* error) {
16031621
/* We can only write 8k characters at a time. Windows can't handle */
16041622
/* much more characters in a single console write anyway. */
1605-
WCHAR utf16_buf[8192];
1623+
WCHAR utf16_buf[MAX_CONSOLE_CHAR];
1624+
WCHAR* utf16_buffer;
16061625
DWORD utf16_buf_used = 0;
1607-
unsigned int i;
1608-
1609-
#define FLUSH_TEXT() \
1610-
do { \
1611-
if (utf16_buf_used > 0) { \
1612-
uv_tty_emit_text(handle, utf16_buf, utf16_buf_used, error); \
1613-
utf16_buf_used = 0; \
1614-
} \
1615-
} while (0)
1626+
unsigned int i, len, max_len, pos;
1627+
int allocate = 0;
1628+
1629+
#define FLUSH_TEXT() \
1630+
do { \
1631+
pos = 0; \
1632+
do { \
1633+
len = utf16_buf_used - pos; \
1634+
if (len > MAX_CONSOLE_CHAR) \
1635+
len = MAX_CONSOLE_CHAR; \
1636+
uv_tty_emit_text(handle, &utf16_buffer[pos], len, error); \
1637+
pos += len; \
1638+
} while (pos < utf16_buf_used); \
1639+
if (allocate) { \
1640+
uv__free(utf16_buffer); \
1641+
allocate = 0; \
1642+
utf16_buffer = utf16_buf; \
1643+
} \
1644+
utf16_buf_used = 0; \
1645+
} while (0)
16161646

16171647
#define ENSURE_BUFFER_SPACE(wchars_needed) \
16181648
if (wchars_needed > ARRAY_SIZE(utf16_buf) - utf16_buf_used) { \
@@ -1630,12 +1660,48 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
16301660
/* state. */
16311661
*error = ERROR_SUCCESS;
16321662

1663+
utf16_buffer = utf16_buf;
1664+
16331665
uv_sem_wait(&uv_tty_output_lock);
16341666

16351667
for (i = 0; i < nbufs; i++) {
16361668
uv_buf_t buf = bufs[i];
16371669
unsigned int j;
16381670

1671+
if (uv__vterm_state == UV_SUPPORTED && buf.len > 0) {
1672+
utf16_buf_used = MultiByteToWideChar(CP_UTF8,
1673+
0,
1674+
buf.base,
1675+
buf.len,
1676+
NULL,
1677+
0);
1678+
1679+
if (utf16_buf_used == 0) {
1680+
*error = GetLastError();
1681+
break;
1682+
}
1683+
1684+
max_len = (utf16_buf_used + 1) * sizeof(WCHAR);
1685+
allocate = max_len > MAX_CONSOLE_CHAR;
1686+
if (allocate)
1687+
utf16_buffer = uv__malloc(max_len);
1688+
if (!MultiByteToWideChar(CP_UTF8,
1689+
0,
1690+
buf.base,
1691+
buf.len,
1692+
utf16_buffer,
1693+
utf16_buf_used)) {
1694+
if (allocate)
1695+
uv__free(utf16_buffer);
1696+
*error = GetLastError();
1697+
break;
1698+
}
1699+
1700+
FLUSH_TEXT();
1701+
1702+
continue;
1703+
}
1704+
16391705
for (j = 0; j < buf.len; j++) {
16401706
unsigned char c = buf.base[j];
16411707

@@ -2193,3 +2259,24 @@ int uv_tty_reset_mode(void) {
21932259
/* Not necessary to do anything. */
21942260
return 0;
21952261
}
2262+
2263+
/* Determine whether or not this version of windows supports
2264+
* proper ANSI color codes. Should be supported as of windows
2265+
* 10 version 1511, build number 10.0.10586.
2266+
*/
2267+
static void uv__determine_vterm_state(HANDLE handle) {
2268+
DWORD dwMode = 0;
2269+
2270+
if (!GetConsoleMode(handle, &dwMode)) {
2271+
uv__vterm_state = UV_UNSUPPORTED;
2272+
return;
2273+
}
2274+
2275+
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
2276+
if (!SetConsoleMode(handle, dwMode)) {
2277+
uv__vterm_state = UV_UNSUPPORTED;
2278+
return;
2279+
}
2280+
2281+
uv__vterm_state = UV_SUPPORTED;
2282+
}

deps/uv/test/test-error.c

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ TEST_IMPL(error_message) {
5353
TEST_IMPL(sys_error) {
5454
#if defined(_WIN32)
5555
ASSERT(uv_translate_sys_error(ERROR_NOACCESS) == UV_EACCES);
56+
ASSERT(uv_translate_sys_error(ERROR_ELEVATION_REQUIRED) == UV_EACCES);
5657
ASSERT(uv_translate_sys_error(WSAEADDRINUSE) == UV_EADDRINUSE);
5758
ASSERT(uv_translate_sys_error(ERROR_BAD_PIPE) == UV_EPIPE);
5859
#else

deps/uv/test/test-fs.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -1141,22 +1141,24 @@ TEST_IMPL(fs_fstat) {
11411141
ASSERT(s->st_mtim.tv_nsec == t.st_mtimensec);
11421142
ASSERT(s->st_ctim.tv_sec == t.st_ctime);
11431143
ASSERT(s->st_ctim.tv_nsec == t.st_ctimensec);
1144-
#elif defined(__sun) || \
1145-
defined(_GNU_SOURCE) || \
1146-
defined(_BSD_SOURCE) || \
1147-
defined(_SVID_SOURCE) || \
1148-
defined(_XOPEN_SOURCE) || \
1144+
#elif defined(__sun) || \
1145+
defined(__DragonFly__) || \
1146+
defined(__FreeBSD__) || \
1147+
defined(__OpenBSD__) || \
1148+
defined(__NetBSD__) || \
1149+
defined(_GNU_SOURCE) || \
1150+
defined(_BSD_SOURCE) || \
1151+
defined(_SVID_SOURCE) || \
1152+
defined(_XOPEN_SOURCE) || \
11491153
defined(_DEFAULT_SOURCE)
11501154
ASSERT(s->st_atim.tv_sec == t.st_atim.tv_sec);
11511155
ASSERT(s->st_atim.tv_nsec == t.st_atim.tv_nsec);
11521156
ASSERT(s->st_mtim.tv_sec == t.st_mtim.tv_sec);
11531157
ASSERT(s->st_mtim.tv_nsec == t.st_mtim.tv_nsec);
11541158
ASSERT(s->st_ctim.tv_sec == t.st_ctim.tv_sec);
11551159
ASSERT(s->st_ctim.tv_nsec == t.st_ctim.tv_nsec);
1156-
# if defined(__DragonFly__) || \
1157-
defined(__FreeBSD__) || \
1158-
defined(__OpenBSD__) || \
1159-
defined(__NetBSD__)
1160+
# if defined(__FreeBSD__) || \
1161+
defined(__NetBSD__)
11601162
ASSERT(s->st_birthtim.tv_sec == t.st_birthtim.tv_sec);
11611163
ASSERT(s->st_birthtim.tv_nsec == t.st_birthtim.tv_nsec);
11621164
ASSERT(s->st_flags == t.st_flags);

0 commit comments

Comments
 (0)