deps: upgrade to libuv 1.24.0
PR-URL: https://github.com/nodejs/node/pull/24332 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
1ddcccb7e3
commit
9cef7b84b1
4
deps/uv/AUTHORS
vendored
4
deps/uv/AUTHORS
vendored
@ -352,3 +352,7 @@ Andy Zhang <zhangyong232@gmail.com>
|
||||
dmabupt <dmabupt@gmail.com>
|
||||
Ryan Liptak <squeek502@hotmail.com>
|
||||
Ali Ijaz Sheikh <ofrobots@google.com>
|
||||
hitesh <sainihitesh.scientist@gmail.com>
|
||||
Svante Signell <svante.signell@gmail.com>
|
||||
Samuel Thibault <sthibault@debian.org>
|
||||
Jeremy Studer <studerj1.mail@gmail.com>
|
||||
|
4
deps/uv/CMakeLists.txt
vendored
4
deps/uv/CMakeLists.txt
vendored
@ -13,6 +13,7 @@ endif()
|
||||
|
||||
set(uv_sources
|
||||
src/fs-poll.c
|
||||
src/idna.c
|
||||
src/inet.c
|
||||
src/threadpool.c
|
||||
src/timer.c
|
||||
@ -64,6 +65,7 @@ set(uv_test_sources
|
||||
test/test-homedir.c
|
||||
test/test-hrtime.c
|
||||
test/test-idle.c
|
||||
test/test-idna.c
|
||||
test/test-ip4-addr.c
|
||||
test/test-ip6-addr.c
|
||||
test/test-ip6-addr.c
|
||||
@ -260,7 +262,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
|
||||
list(APPEND uv_sources src/unix/posix-hrtime.c)
|
||||
list(APPEND uv_sources src/unix/posix-hrtime.c src/unix/bsd-proctitle.c)
|
||||
list(APPEND uv_libraries kvm)
|
||||
endif()
|
||||
|
||||
|
57
deps/uv/ChangeLog
vendored
57
deps/uv/ChangeLog
vendored
@ -1,3 +1,60 @@
|
||||
2018.11.14, Version 1.24.0 (Stable), 2d427ee0083d1baf995df4ebf79a3f8890e9a3e1
|
||||
|
||||
Changes since version 1.23.2:
|
||||
|
||||
* unix: do not require PATH_MAX to be defined (Brad King)
|
||||
|
||||
* win,doc: path encoding in uv_fs_XX is UTF-8 (hitesh)
|
||||
|
||||
* unix: add missing link dependency on kFreeBSD (Svante Signell)
|
||||
|
||||
* unix: add support for GNU/Hurd (Samuel Thibault)
|
||||
|
||||
* test: avoid memory leak for test_output (Carlo Marcelo Arenas Belón)
|
||||
|
||||
* zos: avoid UB with NULL pointer arithmetic (Carlo Marcelo Arenas Belón)
|
||||
|
||||
* doc: add vtjnash to maintainers (Jameson Nash)
|
||||
|
||||
* unix: restore skipping of phys_addr copy (cjihrig)
|
||||
|
||||
* unix,win: make uv_interface_addresses() consistent (cjihrig)
|
||||
|
||||
* unix: remove unnecessary linebreaks (cjihrig)
|
||||
|
||||
* unix,win: handle zero-sized allocations uniformly (Ben Noordhuis)
|
||||
|
||||
* unix: remove unused uv__dup() function (Ben Noordhuis)
|
||||
|
||||
* core,bsd: refactor process_title functions (Santiago Gimeno)
|
||||
|
||||
* win: Redefine NSIG to consider SIGWINCH (Jeremy Studer)
|
||||
|
||||
* test: make sure that reading a directory fails (Sakthipriyan Vairamani)
|
||||
|
||||
* win, tty: remove zero-size read callbacks (Bartosz Sosnowski)
|
||||
|
||||
* test: fix test runner getenv async-signal-safety (Ben Noordhuis)
|
||||
|
||||
* test: fix test runner execvp async-signal-safety (Ben Noordhuis)
|
||||
|
||||
* test,unix: fix race in test runner (Ben Noordhuis)
|
||||
|
||||
* unix,win: support IDNA 2008 in uv_getaddrinfo() (Ben Noordhuis)
|
||||
|
||||
* win, tcp: avoid starving the loop (Bartosz Sosnowski)
|
||||
|
||||
* win, dl: proper error messages on some systems (Bartosz Sosnowski)
|
||||
|
||||
* win,fs: retry if uv_fs_rename fails (Bartosz Sosnowski)
|
||||
|
||||
* darwin: speed up uv_set_process_title() (Ben Noordhuis)
|
||||
|
||||
* aix: fix race in uv_get_process_title() (Gireesh Punathil)
|
||||
|
||||
* win: support more fine-grained windows hiding (Bartosz Sosnowski)
|
||||
|
||||
|
||||
2018.10.09, Version 1.23.2 (Stable), 34c12788d2e7308f3ac506c0abcbf74c0d6abd20
|
||||
|
||||
Changes since version 1.23.1:
|
||||
|
1
deps/uv/MAINTAINERS.md
vendored
1
deps/uv/MAINTAINERS.md
vendored
@ -15,6 +15,7 @@ libuv is currently managed by the following individuals:
|
||||
- GPG key: AF2E EA41 EC34 47BF DD86 FED9 D706 3CCE 19B7 E890 (pubkey-indutny)
|
||||
* **Imran Iqbal** ([@imran-iq](https://github.com/imran-iq))
|
||||
- GPG key: 9DFE AA5F 481B BF77 2D90 03CE D592 4925 2F8E C41A (pubkey-iwuzhere)
|
||||
* **Jameson Nash** ([@vtjnash](https://github.com/vtjnash))
|
||||
* **John Barboza** ([@jbarz](https://github.com/jbarz))
|
||||
* **Santiago Gimeno** ([@santigimeno](https://github.com/santigimeno))
|
||||
- GPG key: 612F 0EAD 9401 6223 79DF 4402 F28C 3C8D A33C 03BE (pubkey-santigimeno)
|
||||
|
13
deps/uv/Makefile.am
vendored
13
deps/uv/Makefile.am
vendored
@ -29,6 +29,7 @@ libuv_la_CFLAGS = @CFLAGS@
|
||||
libuv_la_LDFLAGS = -no-undefined -version-info 1:0:0
|
||||
libuv_la_SOURCES = src/fs-poll.c \
|
||||
src/heap-inl.h \
|
||||
src/idna.c \
|
||||
src/inet.c \
|
||||
src/queue.h \
|
||||
src/threadpool.c \
|
||||
@ -189,6 +190,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \
|
||||
test/test-homedir.c \
|
||||
test/test-hrtime.c \
|
||||
test/test-idle.c \
|
||||
test/test-idna.c \
|
||||
test/test-ip4-addr.c \
|
||||
test/test-ip6-addr.c \
|
||||
test/test-ipc-heavy-traffic-deadlock-bug.c \
|
||||
@ -374,6 +376,7 @@ endif
|
||||
if DRAGONFLY
|
||||
uvinclude_HEADERS += include/uv/bsd.h
|
||||
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
|
||||
src/unix/bsd-proctitle.c \
|
||||
src/unix/freebsd.c \
|
||||
src/unix/kqueue.c \
|
||||
src/unix/posix-hrtime.c
|
||||
@ -383,12 +386,20 @@ endif
|
||||
if FREEBSD
|
||||
uvinclude_HEADERS += include/uv/bsd.h
|
||||
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
|
||||
src/unix/bsd-proctitle.c \
|
||||
src/unix/freebsd.c \
|
||||
src/unix/kqueue.c \
|
||||
src/unix/posix-hrtime.c
|
||||
test_run_tests_LDFLAGS += -lutil
|
||||
endif
|
||||
|
||||
if HURD
|
||||
uvinclude_HEADERS += include/uv/posix.h
|
||||
libuv_la_SOURCES += src/unix/no-fsevents.c \
|
||||
src/unix/posix-hrtime.c \
|
||||
src/unix/posix-poll.c
|
||||
endif
|
||||
|
||||
if LINUX
|
||||
uvinclude_HEADERS += include/uv/linux.h
|
||||
libuv_la_CFLAGS += -D_GNU_SOURCE
|
||||
@ -419,6 +430,7 @@ endif
|
||||
if NETBSD
|
||||
uvinclude_HEADERS += include/uv/bsd.h
|
||||
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
|
||||
src/unix/bsd-proctitle.c \
|
||||
src/unix/kqueue.c \
|
||||
src/unix/netbsd.c \
|
||||
src/unix/posix-hrtime.c
|
||||
@ -428,6 +440,7 @@ endif
|
||||
if OPENBSD
|
||||
uvinclude_HEADERS += include/uv/bsd.h
|
||||
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
|
||||
src/unix/bsd-proctitle.c \
|
||||
src/unix/kqueue.c \
|
||||
src/unix/openbsd.c \
|
||||
src/unix/posix-hrtime.c
|
||||
|
6
deps/uv/configure.ac
vendored
6
deps/uv/configure.ac
vendored
@ -13,7 +13,7 @@
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([libuv], [1.23.2], [https://github.com/libuv/libuv/issues])
|
||||
AC_INIT([libuv], [1.24.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])
|
||||
@ -56,6 +56,7 @@ AM_CONDITIONAL([CYGWIN], [AS_CASE([$host_os],[cygwin*], [true], [false])
|
||||
AM_CONDITIONAL([DARWIN], [AS_CASE([$host_os],[darwin*], [true], [false])])
|
||||
AM_CONDITIONAL([DRAGONFLY],[AS_CASE([$host_os],[dragonfly*], [true], [false])])
|
||||
AM_CONDITIONAL([FREEBSD], [AS_CASE([$host_os],[*freebsd*], [true], [false])])
|
||||
AM_CONDITIONAL([HURD], [AS_CASE([$host_os],[gnu*], [true], [false])])
|
||||
AM_CONDITIONAL([LINUX], [AS_CASE([$host_os],[linux*], [true], [false])])
|
||||
AM_CONDITIONAL([MSYS], [AS_CASE([$host_os],[msys*], [true], [false])])
|
||||
AM_CONDITIONAL([NETBSD], [AS_CASE([$host_os],[netbsd*], [true], [false])])
|
||||
@ -67,6 +68,9 @@ AS_CASE([$host_os],[mingw*], [
|
||||
LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32"
|
||||
])
|
||||
AS_CASE([$host_os], [netbsd*], [AC_CHECK_LIB([kvm], [kvm_open])])
|
||||
AS_CASE([$host_os], [kfreebsd*], [
|
||||
LIBS="$LIBS -lfreebsd-glue"
|
||||
])
|
||||
AC_CHECK_HEADERS([sys/ahafs_evProds.h])
|
||||
AC_CONFIG_FILES([Makefile libuv.pc])
|
||||
AC_OUTPUT
|
||||
|
11
deps/uv/docs/src/fs.rst
vendored
11
deps/uv/docs/src/fs.rst
vendored
@ -12,6 +12,8 @@ otherwise it will be performed asynchronously.
|
||||
All file operations are run on the threadpool. See :ref:`threadpool` for information
|
||||
on the threadpool size.
|
||||
|
||||
.. note::
|
||||
On Windows `uv_fs_*` functions use utf-8 encoding.
|
||||
|
||||
Data types
|
||||
----------
|
||||
@ -231,6 +233,15 @@ API
|
||||
|
||||
Equivalent to :man:`rename(2)`.
|
||||
|
||||
.. note::
|
||||
On Windows if this function fails with ``UV_EBUSY``, ``UV_EPERM`` or
|
||||
``UV_EACCES``, it will retry to rename the file up to four times with
|
||||
250ms wait between attempts before giving up. If both `path` and
|
||||
`new_path` are existing directories this function will work only if
|
||||
target directory is empty.
|
||||
|
||||
.. versionchanged:: 1.24.0 Added retrying and directory move support on Windows.
|
||||
|
||||
.. c:function:: int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb)
|
||||
|
||||
Equivalent to :man:`fsync(2)`.
|
||||
|
18
deps/uv/docs/src/process.rst
vendored
18
deps/uv/docs/src/process.rst
vendored
@ -70,11 +70,22 @@ Data types
|
||||
*/
|
||||
UV_PROCESS_DETACHED = (1 << 3),
|
||||
/*
|
||||
* Hide the subprocess console window that would normally be created. This
|
||||
* Hide the subprocess window that would normally be created. This option is
|
||||
* only meaningful on Windows systems. On Unix it is silently ignored.
|
||||
*/
|
||||
UV_PROCESS_WINDOWS_HIDE = (1 << 4),
|
||||
/*
|
||||
* Hide the subprocess console window that would normally be created. This
|
||||
* option is only meaningful on Windows systems. On Unix it is silently
|
||||
* ignored.
|
||||
*/
|
||||
UV_PROCESS_WINDOWS_HIDE = (1 << 4)
|
||||
UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5),
|
||||
/*
|
||||
* Hide the subprocess GUI window that would normally be created. This
|
||||
* option is only meaningful on Windows systems. On Unix it is silently
|
||||
* ignored.
|
||||
*/
|
||||
UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6)
|
||||
};
|
||||
|
||||
.. c:type:: uv_stdio_container_t
|
||||
@ -217,6 +228,9 @@ API
|
||||
setgid specified, or not having enough memory to allocate for the new
|
||||
process.
|
||||
|
||||
.. versionchanged:: 1.24.0 Added `UV_PROCESS_WINDOWS_HIDE_CONSOLE` and
|
||||
`UV_PROCESS_WINDOWS_HIDE_GUI` flags.
|
||||
|
||||
.. c:function:: int uv_process_kill(uv_process_t* handle, int signum)
|
||||
|
||||
Sends the specified signal to the given process handle. Check the documentation
|
||||
|
15
deps/uv/include/uv.h
vendored
15
deps/uv/include/uv.h
vendored
@ -963,11 +963,22 @@ enum uv_process_flags {
|
||||
*/
|
||||
UV_PROCESS_DETACHED = (1 << 3),
|
||||
/*
|
||||
* Hide the subprocess console window that would normally be created. This
|
||||
* Hide the subprocess window that would normally be created. This option is
|
||||
* only meaningful on Windows systems. On Unix it is silently ignored.
|
||||
*/
|
||||
UV_PROCESS_WINDOWS_HIDE = (1 << 4),
|
||||
/*
|
||||
* Hide the subprocess console window that would normally be created. This
|
||||
* option is only meaningful on Windows systems. On Unix it is silently
|
||||
* ignored.
|
||||
*/
|
||||
UV_PROCESS_WINDOWS_HIDE = (1 << 4)
|
||||
UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5),
|
||||
/*
|
||||
* Hide the subprocess GUI window that would normally be created. This
|
||||
* option is only meaningful on Windows systems. On Unix it is silently
|
||||
* ignored.
|
||||
*/
|
||||
UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6)
|
||||
};
|
||||
|
||||
/*
|
||||
|
2
deps/uv/include/uv/unix.h
vendored
2
deps/uv/include/uv/unix.h
vendored
@ -64,6 +64,8 @@
|
||||
# include "uv/bsd.h"
|
||||
#elif defined(__CYGWIN__) || defined(__MSYS__)
|
||||
# include "uv/posix.h"
|
||||
#elif defined(__GNU__)
|
||||
# include "uv/posix.h"
|
||||
#endif
|
||||
|
||||
#ifndef NI_MAXHOST
|
||||
|
4
deps/uv/include/uv/version.h
vendored
4
deps/uv/include/uv/version.h
vendored
@ -31,8 +31,8 @@
|
||||
*/
|
||||
|
||||
#define UV_VERSION_MAJOR 1
|
||||
#define UV_VERSION_MINOR 23
|
||||
#define UV_VERSION_PATCH 2
|
||||
#define UV_VERSION_MINOR 24
|
||||
#define UV_VERSION_PATCH 0
|
||||
#define UV_VERSION_IS_RELEASE 1
|
||||
#define UV_VERSION_SUFFIX ""
|
||||
|
||||
|
8
deps/uv/include/uv/win.h
vendored
8
deps/uv/include/uv/win.h
vendored
@ -86,6 +86,14 @@ typedef struct pollfd {
|
||||
#define SIGKILL 9
|
||||
#define SIGWINCH 28
|
||||
|
||||
/* Redefine NSIG to take SIGWINCH into consideration */
|
||||
#if defined(NSIG) && NSIG <= SIGWINCH
|
||||
# undef NSIG
|
||||
#endif
|
||||
#ifndef NSIG
|
||||
# define NSIG SIGWINCH + 1
|
||||
#endif
|
||||
|
||||
/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many unix-like
|
||||
* platforms. However MinGW doesn't define it, so we do. */
|
||||
#ifndef SIGABRT_COMPAT
|
||||
|
291
deps/uv/src/idna.c
vendored
Normal file
291
deps/uv/src/idna.c
vendored
Normal file
@ -0,0 +1,291 @@
|
||||
/* Copyright (c) 2011, 2018 Ben Noordhuis <info@bnoordhuis.nl>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* Derived from https://github.com/bnoordhuis/punycode
|
||||
* but updated to support IDNA 2008.
|
||||
*/
|
||||
|
||||
#include "uv.h"
|
||||
#include "idna.h"
|
||||
#include <string.h>
|
||||
|
||||
static unsigned uv__utf8_decode1_slow(const char** p,
|
||||
const char* pe,
|
||||
unsigned a) {
|
||||
unsigned b;
|
||||
unsigned c;
|
||||
unsigned d;
|
||||
unsigned min;
|
||||
|
||||
if (a > 0xF7)
|
||||
return -1;
|
||||
|
||||
switch (*p - pe) {
|
||||
default:
|
||||
if (a > 0xEF) {
|
||||
min = 0x10000;
|
||||
a = a & 7;
|
||||
b = (unsigned char) *(*p)++;
|
||||
c = (unsigned char) *(*p)++;
|
||||
d = (unsigned char) *(*p)++;
|
||||
break;
|
||||
}
|
||||
/* Fall through. */
|
||||
case 2:
|
||||
if (a > 0xDF) {
|
||||
min = 0x800;
|
||||
b = 0x80 | (a & 15);
|
||||
c = (unsigned char) *(*p)++;
|
||||
d = (unsigned char) *(*p)++;
|
||||
a = 0;
|
||||
break;
|
||||
}
|
||||
/* Fall through. */
|
||||
case 1:
|
||||
if (a > 0xBF) {
|
||||
min = 0x80;
|
||||
b = 0x80;
|
||||
c = 0x80 | (a & 31);
|
||||
d = (unsigned char) *(*p)++;
|
||||
a = 0;
|
||||
break;
|
||||
}
|
||||
return -1; /* Invalid continuation byte. */
|
||||
}
|
||||
|
||||
if (0x80 != (0xC0 & (b ^ c ^ d)))
|
||||
return -1; /* Invalid sequence. */
|
||||
|
||||
b &= 63;
|
||||
c &= 63;
|
||||
d &= 63;
|
||||
a = (a << 18) | (b << 12) | (c << 6) | d;
|
||||
|
||||
if (a < min)
|
||||
return -1; /* Overlong sequence. */
|
||||
|
||||
if (a > 0x10FFFF)
|
||||
return -1; /* Four-byte sequence > U+10FFFF. */
|
||||
|
||||
if (a >= 0xD800 && a <= 0xDFFF)
|
||||
return -1; /* Surrogate pair. */
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
unsigned uv__utf8_decode1(const char** p, const char* pe) {
|
||||
unsigned a;
|
||||
|
||||
a = (unsigned char) *(*p)++;
|
||||
|
||||
if (a < 128)
|
||||
return a; /* ASCII, common case. */
|
||||
|
||||
return uv__utf8_decode1_slow(p, pe, a);
|
||||
}
|
||||
|
||||
#define foreach_codepoint(c, p, pe) \
|
||||
for (; (void) (*p <= pe && (c = uv__utf8_decode1(p, pe))), *p <= pe;)
|
||||
|
||||
static int uv__idna_toascii_label(const char* s, const char* se,
|
||||
char** d, char* de) {
|
||||
static const char alphabet[] = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const char* ss;
|
||||
unsigned c;
|
||||
unsigned h;
|
||||
unsigned k;
|
||||
unsigned n;
|
||||
unsigned m;
|
||||
unsigned q;
|
||||
unsigned t;
|
||||
unsigned x;
|
||||
unsigned y;
|
||||
unsigned bias;
|
||||
unsigned delta;
|
||||
unsigned todo;
|
||||
int first;
|
||||
|
||||
h = 0;
|
||||
ss = s;
|
||||
todo = 0;
|
||||
|
||||
foreach_codepoint(c, &s, se) {
|
||||
if (c < 128)
|
||||
h++;
|
||||
else if (c == (unsigned) -1)
|
||||
return UV_EINVAL;
|
||||
else
|
||||
todo++;
|
||||
}
|
||||
|
||||
if (todo > 0) {
|
||||
if (*d < de) *(*d)++ = 'x';
|
||||
if (*d < de) *(*d)++ = 'n';
|
||||
if (*d < de) *(*d)++ = '-';
|
||||
if (*d < de) *(*d)++ = '-';
|
||||
}
|
||||
|
||||
x = 0;
|
||||
s = ss;
|
||||
foreach_codepoint(c, &s, se) {
|
||||
if (c > 127)
|
||||
continue;
|
||||
|
||||
if (*d < de)
|
||||
*(*d)++ = c;
|
||||
|
||||
if (++x == h)
|
||||
break; /* Visited all ASCII characters. */
|
||||
}
|
||||
|
||||
if (todo == 0)
|
||||
return h;
|
||||
|
||||
/* Only write separator when we've written ASCII characters first. */
|
||||
if (h > 0)
|
||||
if (*d < de)
|
||||
*(*d)++ = '-';
|
||||
|
||||
n = 128;
|
||||
bias = 72;
|
||||
delta = 0;
|
||||
first = 1;
|
||||
|
||||
while (todo > 0) {
|
||||
m = -1;
|
||||
s = ss;
|
||||
foreach_codepoint(c, &s, se)
|
||||
if (c >= n)
|
||||
if (c < m)
|
||||
m = c;
|
||||
|
||||
x = m - n;
|
||||
y = h + 1;
|
||||
|
||||
if (x > ~delta / y)
|
||||
return UV_E2BIG; /* Overflow. */
|
||||
|
||||
delta += x * y;
|
||||
n = m;
|
||||
|
||||
s = ss;
|
||||
foreach_codepoint(c, &s, se) {
|
||||
if (c < n)
|
||||
if (++delta == 0)
|
||||
return UV_E2BIG; /* Overflow. */
|
||||
|
||||
if (c != n)
|
||||
continue;
|
||||
|
||||
for (k = 36, q = delta; /* empty */; k += 36) {
|
||||
t = 1;
|
||||
|
||||
if (k > bias)
|
||||
t = k - bias;
|
||||
|
||||
if (t > 26)
|
||||
t = 26;
|
||||
|
||||
if (q < t)
|
||||
break;
|
||||
|
||||
/* TODO(bnoordhuis) Since 1 <= t <= 26 and therefore
|
||||
* 10 <= y <= 35, we can optimize the long division
|
||||
* into a table-based reciprocal multiplication.
|
||||
*/
|
||||
x = q - t;
|
||||
y = 36 - t; /* 10 <= y <= 35 since 1 <= t <= 26. */
|
||||
q = x / y;
|
||||
t = t + x % y; /* 1 <= t <= 35 because of y. */
|
||||
|
||||
if (*d < de)
|
||||
*(*d)++ = alphabet[t];
|
||||
}
|
||||
|
||||
if (*d < de)
|
||||
*(*d)++ = alphabet[q];
|
||||
|
||||
delta /= 2;
|
||||
|
||||
if (first) {
|
||||
delta /= 350;
|
||||
first = 0;
|
||||
}
|
||||
|
||||
/* No overflow check is needed because |delta| was just
|
||||
* divided by 2 and |delta+delta >= delta + delta/h|.
|
||||
*/
|
||||
h++;
|
||||
delta += delta / h;
|
||||
|
||||
for (bias = 0; delta > 35 * 26 / 2; bias += 36)
|
||||
delta /= 35;
|
||||
|
||||
bias += 36 * delta / (delta + 38);
|
||||
delta = 0;
|
||||
todo--;
|
||||
}
|
||||
|
||||
delta++;
|
||||
n++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef foreach_codepoint
|
||||
|
||||
long uv__idna_toascii(const char* s, const char* se, char* d, char* de) {
|
||||
const char* si;
|
||||
const char* st;
|
||||
unsigned c;
|
||||
char* ds;
|
||||
int rc;
|
||||
|
||||
ds = d;
|
||||
|
||||
for (si = s; si < se; /* empty */) {
|
||||
st = si;
|
||||
c = uv__utf8_decode1(&si, se);
|
||||
|
||||
if (c != '.')
|
||||
if (c != 0x3002) /* 。 */
|
||||
if (c != 0xFF0E) /* . */
|
||||
if (c != 0xFF61) /* 。 */
|
||||
continue;
|
||||
|
||||
rc = uv__idna_toascii_label(s, st, &d, de);
|
||||
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
if (d < de)
|
||||
*d++ = '.';
|
||||
|
||||
s = si;
|
||||
}
|
||||
|
||||
if (s < se) {
|
||||
rc = uv__idna_toascii_label(s, se, &d, de);
|
||||
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (d < de)
|
||||
*d++ = '\0';
|
||||
|
||||
return d - ds; /* Number of bytes written. */
|
||||
}
|
31
deps/uv/src/idna.h
vendored
Normal file
31
deps/uv/src/idna.h
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/* Copyright (c) 2011, 2018 Ben Noordhuis <info@bnoordhuis.nl>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef UV_SRC_IDNA_H_
|
||||
#define UV_SRC_IDNA_H_
|
||||
|
||||
/* Decode a single codepoint. Returns the codepoint or UINT32_MAX on error.
|
||||
* |p| is updated on success _and_ error, i.e., bad multi-byte sequences are
|
||||
* skipped in their entirety, not just the first bad byte.
|
||||
*/
|
||||
unsigned uv__utf8_decode1(const char** p, const char* pe);
|
||||
|
||||
/* Convert a UTF-8 domain name to IDNA 2008 / Punycode. A return value >= 0
|
||||
* is the number of bytes written to |d|, including the trailing nul byte.
|
||||
* A return value < 0 is a libuv error code. |s| and |d| can not overlap.
|
||||
*/
|
||||
long uv__idna_toascii(const char* s, const char* se, char* d, char* de);
|
||||
|
||||
#endif /* UV_SRC_IDNA_H_ */
|
11
deps/uv/src/unix/aix-common.c
vendored
11
deps/uv/src/unix/aix-common.c
vendored
@ -166,8 +166,7 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
|
||||
}
|
||||
|
||||
|
||||
int uv_interface_addresses(uv_interface_address_t** addresses,
|
||||
int* count) {
|
||||
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
|
||||
uv_interface_address_t* address;
|
||||
int sockfd, inet6, size = 1;
|
||||
struct ifconf ifc;
|
||||
@ -175,6 +174,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
|
||||
struct sockaddr_dl* sa_addr;
|
||||
|
||||
*count = 0;
|
||||
*addresses = NULL;
|
||||
|
||||
if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
|
||||
return UV__ERR(errno);
|
||||
@ -217,6 +217,11 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
if (*count == 0) {
|
||||
uv__close(sockfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Alloc the return interface structs */
|
||||
*addresses = uv__malloc(*count * sizeof(uv_interface_address_t));
|
||||
if (!(*addresses)) {
|
||||
@ -289,4 +294,4 @@ void uv_free_interface_addresses(uv_interface_address_t* addresses,
|
||||
}
|
||||
|
||||
uv__free(addresses);
|
||||
}
|
||||
}
|
||||
|
12
deps/uv/src/unix/aix.c
vendored
12
deps/uv/src/unix/aix.c
vendored
@ -886,16 +886,20 @@ int uv_set_process_title(const char* title) {
|
||||
|
||||
int uv_get_process_title(char* buffer, size_t size) {
|
||||
size_t len;
|
||||
len = strlen(process_argv[0]);
|
||||
if (buffer == NULL || size == 0)
|
||||
return UV_EINVAL;
|
||||
else if (size <= len)
|
||||
return UV_ENOBUFS;
|
||||
|
||||
uv_once(&process_title_mutex_once, init_process_title_mutex_once);
|
||||
uv_mutex_lock(&process_title_mutex);
|
||||
|
||||
memcpy(buffer, process_argv[0], len + 1);
|
||||
len = strlen(process_argv[0]);
|
||||
if (size <= len) {
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
return UV_ENOBUFS;
|
||||
}
|
||||
|
||||
memcpy(buffer, process_argv[0], len);
|
||||
buffer[len] = '\0';
|
||||
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
|
||||
|
17
deps/uv/src/unix/bsd-ifaddrs.c
vendored
17
deps/uv/src/unix/bsd-ifaddrs.c
vendored
@ -69,11 +69,12 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
|
||||
uv_interface_address_t* address;
|
||||
int i;
|
||||
|
||||
*count = 0;
|
||||
*addresses = NULL;
|
||||
|
||||
if (getifaddrs(&addrs) != 0)
|
||||
return UV__ERR(errno);
|
||||
|
||||
*count = 0;
|
||||
|
||||
/* Count the number of interfaces */
|
||||
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
|
||||
if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR))
|
||||
@ -81,6 +82,11 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
if (*count == 0) {
|
||||
freeifaddrs(addrs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*addresses = uv__malloc(*count * sizeof(**addresses));
|
||||
|
||||
if (*addresses == NULL) {
|
||||
@ -119,14 +125,19 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
|
||||
continue;
|
||||
|
||||
address = *addresses;
|
||||
memset(address->phys_addr, 0, sizeof(address->phys_addr));
|
||||
|
||||
for (i = 0; i < *count; i++) {
|
||||
#if defined(__CYGWIN__) || defined(__MSYS__)
|
||||
memset(address->phys_addr, 0, sizeof(address->phys_addr));
|
||||
#else
|
||||
if (strcmp(address->name, ent->ifa_name) == 0) {
|
||||
struct sockaddr_dl* sa_addr;
|
||||
sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
|
||||
memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
|
||||
} else {
|
||||
memset(address->phys_addr, 0, sizeof(address->phys_addr));
|
||||
}
|
||||
#endif
|
||||
address++;
|
||||
}
|
||||
}
|
||||
|
93
deps/uv/src/unix/bsd-proctitle.c
vendored
Normal file
93
deps/uv/src/unix/bsd-proctitle.c
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
/* Copyright libuv project contributors. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "uv.h"
|
||||
#include "internal.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static uv_mutex_t process_title_mutex;
|
||||
static uv_once_t process_title_mutex_once = UV_ONCE_INIT;
|
||||
static char* process_title;
|
||||
|
||||
|
||||
static void init_process_title_mutex_once(void) {
|
||||
if (uv_mutex_init(&process_title_mutex))
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
char** uv_setup_args(int argc, char** argv) {
|
||||
process_title = argc > 0 ? uv__strdup(argv[0]) : NULL;
|
||||
return argv;
|
||||
}
|
||||
|
||||
|
||||
int uv_set_process_title(const char* title) {
|
||||
char* new_title;
|
||||
|
||||
new_title = uv__strdup(title);
|
||||
if (new_title == NULL)
|
||||
return UV_ENOMEM;
|
||||
|
||||
uv_once(&process_title_mutex_once, init_process_title_mutex_once);
|
||||
uv_mutex_lock(&process_title_mutex);
|
||||
|
||||
uv__free(process_title);
|
||||
process_title = new_title;
|
||||
setproctitle("%s", title);
|
||||
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv_get_process_title(char* buffer, size_t size) {
|
||||
size_t len;
|
||||
|
||||
if (buffer == NULL || size == 0)
|
||||
return UV_EINVAL;
|
||||
|
||||
uv_once(&process_title_mutex_once, init_process_title_mutex_once);
|
||||
uv_mutex_lock(&process_title_mutex);
|
||||
|
||||
if (process_title != NULL) {
|
||||
len = strlen(process_title) + 1;
|
||||
|
||||
if (size < len) {
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
return UV_ENOBUFS;
|
||||
}
|
||||
|
||||
memcpy(buffer, process_title, len);
|
||||
} else {
|
||||
len = 0;
|
||||
}
|
||||
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
|
||||
buffer[len] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
21
deps/uv/src/unix/core.c
vendored
21
deps/uv/src/unix/core.c
vendored
@ -636,27 +636,6 @@ int uv__cloexec_fcntl(int fd, int set) {
|
||||
}
|
||||
|
||||
|
||||
/* This function is not execve-safe, there is a race window
|
||||
* between the call to dup() and fcntl(FD_CLOEXEC).
|
||||
*/
|
||||
int uv__dup(int fd) {
|
||||
int err;
|
||||
|
||||
fd = dup(fd);
|
||||
|
||||
if (fd == -1)
|
||||
return UV__ERR(errno);
|
||||
|
||||
err = uv__cloexec(fd, 1);
|
||||
if (err) {
|
||||
uv__close(fd);
|
||||
return err;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) {
|
||||
struct cmsghdr* cmsg;
|
||||
ssize_t rc;
|
||||
|
152
deps/uv/src/unix/darwin-proctitle.c
vendored
152
deps/uv/src/unix/darwin-proctitle.c
vendored
@ -33,61 +33,56 @@
|
||||
# include <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
|
||||
#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8)
|
||||
|
||||
static int uv__pthread_setname_np(const char* name) {
|
||||
int (*dynamic_pthread_setname_np)(const char* name);
|
||||
char namebuf[64]; /* MAXTHREADNAMESIZE */
|
||||
int err;
|
||||
|
||||
static int (*dynamic_pthread_setname_np)(const char* name);
|
||||
#if !TARGET_OS_IPHONE
|
||||
static CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef,
|
||||
const char*,
|
||||
CFStringEncoding);
|
||||
static CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef);
|
||||
static void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef);
|
||||
static void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef);
|
||||
static CFTypeRef (*pLSGetCurrentApplicationASN)(void);
|
||||
static OSStatus (*pLSSetApplicationInformationItem)(int,
|
||||
CFTypeRef,
|
||||
CFStringRef,
|
||||
CFStringRef,
|
||||
CFDictionaryRef*);
|
||||
static void* application_services_handle;
|
||||
static void* core_foundation_handle;
|
||||
static CFBundleRef launch_services_bundle;
|
||||
static CFStringRef* display_name_key;
|
||||
static CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef);
|
||||
static CFBundleRef (*pCFBundleGetMainBundle)(void);
|
||||
static CFBundleRef hi_services_bundle;
|
||||
static OSStatus (*pSetApplicationIsDaemon)(int);
|
||||
static CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef);
|
||||
static void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t,
|
||||
void*);
|
||||
|
||||
|
||||
UV_DESTRUCTOR(static void uv__set_process_title_platform_fini(void)) {
|
||||
if (core_foundation_handle != NULL) {
|
||||
dlclose(core_foundation_handle);
|
||||
core_foundation_handle = NULL;
|
||||
}
|
||||
|
||||
if (application_services_handle != NULL) {
|
||||
dlclose(application_services_handle);
|
||||
application_services_handle = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* !TARGET_OS_IPHONE */
|
||||
|
||||
|
||||
void uv__set_process_title_platform_init(void) {
|
||||
/* pthread_setname_np() first appeared in OS X 10.6 and iOS 3.2. */
|
||||
*(void **)(&dynamic_pthread_setname_np) =
|
||||
dlsym(RTLD_DEFAULT, "pthread_setname_np");
|
||||
|
||||
if (dynamic_pthread_setname_np == NULL)
|
||||
return UV_ENOSYS;
|
||||
|
||||
strncpy(namebuf, name, sizeof(namebuf) - 1);
|
||||
namebuf[sizeof(namebuf) - 1] = '\0';
|
||||
|
||||
err = dynamic_pthread_setname_np(namebuf);
|
||||
if (err)
|
||||
return UV__ERR(err);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv__set_process_title(const char* title) {
|
||||
#if TARGET_OS_IPHONE
|
||||
return uv__pthread_setname_np(title);
|
||||
#else
|
||||
CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef,
|
||||
const char*,
|
||||
CFStringEncoding);
|
||||
CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef);
|
||||
void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef);
|
||||
void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef);
|
||||
CFTypeRef (*pLSGetCurrentApplicationASN)(void);
|
||||
OSStatus (*pLSSetApplicationInformationItem)(int,
|
||||
CFTypeRef,
|
||||
CFStringRef,
|
||||
CFStringRef,
|
||||
CFDictionaryRef*);
|
||||
void* application_services_handle;
|
||||
void* core_foundation_handle;
|
||||
CFBundleRef launch_services_bundle;
|
||||
CFStringRef* display_name_key;
|
||||
CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef);
|
||||
CFBundleRef (*pCFBundleGetMainBundle)(void);
|
||||
CFBundleRef hi_services_bundle;
|
||||
OSStatus (*pSetApplicationIsDaemon)(int);
|
||||
CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef);
|
||||
void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t,
|
||||
void*);
|
||||
CFTypeRef asn;
|
||||
int err;
|
||||
|
||||
err = UV_ENOENT;
|
||||
#if !TARGET_OS_IPHONE
|
||||
application_services_handle = dlopen("/System/Library/Frameworks/"
|
||||
"ApplicationServices.framework/"
|
||||
"Versions/A/ApplicationServices",
|
||||
@ -116,8 +111,6 @@ int uv__set_process_title(const char* title) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8)
|
||||
|
||||
launch_services_bundle =
|
||||
pCFBundleGetBundleWithIdentifier(S("com.apple.LaunchServices"));
|
||||
|
||||
@ -148,13 +141,14 @@ int uv__set_process_title(const char* title) {
|
||||
"CFBundleGetInfoDictionary");
|
||||
*(void **)(&pCFBundleGetMainBundle) = dlsym(core_foundation_handle,
|
||||
"CFBundleGetMainBundle");
|
||||
|
||||
if (pCFBundleGetInfoDictionary == NULL || pCFBundleGetMainBundle == NULL)
|
||||
goto out;
|
||||
|
||||
/* Black 10.9 magic, to remove (Not responding) mark in Activity Monitor */
|
||||
hi_services_bundle =
|
||||
pCFBundleGetBundleWithIdentifier(S("com.apple.HIServices"));
|
||||
err = UV_ENOENT;
|
||||
|
||||
if (hi_services_bundle == NULL)
|
||||
goto out;
|
||||
|
||||
@ -168,42 +162,38 @@ int uv__set_process_title(const char* title) {
|
||||
pCFBundleGetFunctionPointerForName(
|
||||
launch_services_bundle,
|
||||
S("_LSSetApplicationLaunchServicesServerConnectionStatus"));
|
||||
|
||||
if (pSetApplicationIsDaemon == NULL ||
|
||||
pLSApplicationCheckIn == NULL ||
|
||||
pLSSetApplicationLaunchServicesServerConnectionStatus == NULL) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (pSetApplicationIsDaemon(1) != noErr)
|
||||
goto out;
|
||||
|
||||
pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL);
|
||||
|
||||
/* Check into process manager?! */
|
||||
pLSApplicationCheckIn(-2,
|
||||
pCFBundleGetInfoDictionary(pCFBundleGetMainBundle()));
|
||||
|
||||
asn = pLSGetCurrentApplicationASN();
|
||||
|
||||
err = UV_EINVAL;
|
||||
if (pLSSetApplicationInformationItem(-2, /* Magic value. */
|
||||
asn,
|
||||
*display_name_key,
|
||||
S(title),
|
||||
NULL) != noErr) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
uv__pthread_setname_np(title); /* Don't care if it fails. */
|
||||
err = 0;
|
||||
return;
|
||||
|
||||
out:
|
||||
if (core_foundation_handle != NULL)
|
||||
dlclose(core_foundation_handle);
|
||||
|
||||
if (application_services_handle != NULL)
|
||||
dlclose(application_services_handle);
|
||||
|
||||
return err;
|
||||
uv__set_process_title_platform_fini();
|
||||
#endif /* !TARGET_OS_IPHONE */
|
||||
}
|
||||
|
||||
|
||||
void uv__set_process_title(const char* title) {
|
||||
#if !TARGET_OS_IPHONE
|
||||
if (core_foundation_handle != NULL && pSetApplicationIsDaemon(1) != noErr) {
|
||||
CFTypeRef asn;
|
||||
pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL);
|
||||
pLSApplicationCheckIn(/* Magic value */ -2,
|
||||
pCFBundleGetInfoDictionary(pCFBundleGetMainBundle()));
|
||||
asn = pLSGetCurrentApplicationASN();
|
||||
pLSSetApplicationInformationItem(/* Magic value */ -2, asn,
|
||||
*display_name_key, S(title), NULL);
|
||||
}
|
||||
#endif /* !TARGET_OS_IPHONE */
|
||||
|
||||
if (dynamic_pthread_setname_np != NULL) {
|
||||
char namebuf[64]; /* MAXTHREADNAMESIZE */
|
||||
strncpy(namebuf, title, sizeof(namebuf) - 1);
|
||||
namebuf[sizeof(namebuf) - 1] = '\0';
|
||||
dynamic_pthread_setname_np(namebuf);
|
||||
}
|
||||
}
|
||||
|
79
deps/uv/src/unix/freebsd.c
vendored
79
deps/uv/src/unix/freebsd.c
vendored
@ -47,15 +47,6 @@
|
||||
# define CP_INTR 4
|
||||
#endif
|
||||
|
||||
static uv_mutex_t process_title_mutex;
|
||||
static uv_once_t process_title_mutex_once = UV_ONCE_INIT;
|
||||
static char *process_title;
|
||||
|
||||
|
||||
static void init_process_title_mutex_once(void) {
|
||||
uv_mutex_init(&process_title_mutex);
|
||||
}
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop) {
|
||||
return uv__kqueue_init(loop);
|
||||
@ -159,76 +150,6 @@ void uv_loadavg(double avg[3]) {
|
||||
}
|
||||
|
||||
|
||||
char** uv_setup_args(int argc, char** argv) {
|
||||
process_title = argc ? uv__strdup(argv[0]) : NULL;
|
||||
return argv;
|
||||
}
|
||||
|
||||
|
||||
int uv_set_process_title(const char* title) {
|
||||
int oid[4];
|
||||
char* new_title;
|
||||
|
||||
new_title = uv__strdup(title);
|
||||
|
||||
uv_once(&process_title_mutex_once, init_process_title_mutex_once);
|
||||
uv_mutex_lock(&process_title_mutex);
|
||||
|
||||
if (process_title == NULL) {
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
return UV_ENOMEM;
|
||||
}
|
||||
|
||||
uv__free(process_title);
|
||||
process_title = new_title;
|
||||
|
||||
oid[0] = CTL_KERN;
|
||||
oid[1] = KERN_PROC;
|
||||
oid[2] = KERN_PROC_ARGS;
|
||||
oid[3] = getpid();
|
||||
|
||||
sysctl(oid,
|
||||
ARRAY_SIZE(oid),
|
||||
NULL,
|
||||
NULL,
|
||||
process_title,
|
||||
strlen(process_title) + 1);
|
||||
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv_get_process_title(char* buffer, size_t size) {
|
||||
size_t len;
|
||||
|
||||
if (buffer == NULL || size == 0)
|
||||
return UV_EINVAL;
|
||||
|
||||
uv_once(&process_title_mutex_once, init_process_title_mutex_once);
|
||||
uv_mutex_lock(&process_title_mutex);
|
||||
|
||||
if (process_title) {
|
||||
len = strlen(process_title) + 1;
|
||||
|
||||
if (size < len) {
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
return UV_ENOBUFS;
|
||||
}
|
||||
|
||||
memcpy(buffer, process_title, len);
|
||||
} else {
|
||||
len = 0;
|
||||
}
|
||||
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
|
||||
buffer[len] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uv_resident_set_memory(size_t* rss) {
|
||||
struct kinfo_proc kinfo;
|
||||
size_t page_size;
|
||||
|
47
deps/uv/src/unix/fs.c
vendored
47
deps/uv/src/unix/fs.c
vendored
@ -358,19 +358,22 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) {
|
||||
return n;
|
||||
}
|
||||
|
||||
#if defined(_POSIX_PATH_MAX)
|
||||
# define UV__FS_PATH_MAX _POSIX_PATH_MAX
|
||||
#elif defined(PATH_MAX)
|
||||
# define UV__FS_PATH_MAX PATH_MAX
|
||||
#else
|
||||
# define UV__FS_PATH_MAX_FALLBACK 8192
|
||||
# define UV__FS_PATH_MAX UV__FS_PATH_MAX_FALLBACK
|
||||
#endif
|
||||
|
||||
static ssize_t uv__fs_pathmax_size(const char* path) {
|
||||
ssize_t pathmax;
|
||||
|
||||
pathmax = pathconf(path, _PC_PATH_MAX);
|
||||
|
||||
if (pathmax == -1) {
|
||||
#if defined(PATH_MAX)
|
||||
return PATH_MAX;
|
||||
#else
|
||||
#error "PATH_MAX undefined in the current platform"
|
||||
#endif
|
||||
}
|
||||
if (pathmax == -1)
|
||||
pathmax = UV__FS_PATH_MAX;
|
||||
|
||||
return pathmax;
|
||||
}
|
||||
@ -381,7 +384,28 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
|
||||
char* buf;
|
||||
char* newbuf;
|
||||
|
||||
#if defined(UV__FS_PATH_MAX_FALLBACK)
|
||||
/* We may not have a real PATH_MAX. Read size of link. */
|
||||
struct stat st;
|
||||
int ret;
|
||||
ret = lstat(req->path, &st);
|
||||
if (ret != 0)
|
||||
return -1;
|
||||
if (!S_ISLNK(st.st_mode)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
maxlen = st.st_size;
|
||||
|
||||
/* According to readlink(2) lstat can report st_size == 0
|
||||
for some symlinks, such as those in /proc or /sys. */
|
||||
if (maxlen == 0)
|
||||
maxlen = uv__fs_pathmax_size(req->path);
|
||||
#else
|
||||
maxlen = uv__fs_pathmax_size(req->path);
|
||||
#endif
|
||||
|
||||
buf = uv__malloc(maxlen);
|
||||
|
||||
if (buf == NULL) {
|
||||
@ -419,9 +443,15 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
|
||||
}
|
||||
|
||||
static ssize_t uv__fs_realpath(uv_fs_t* req) {
|
||||
ssize_t len;
|
||||
char* buf;
|
||||
|
||||
#if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L
|
||||
buf = realpath(req->path, NULL);
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
#else
|
||||
ssize_t len;
|
||||
|
||||
len = uv__fs_pathmax_size(req->path);
|
||||
buf = uv__malloc(len + 1);
|
||||
|
||||
@ -434,6 +464,7 @@ static ssize_t uv__fs_realpath(uv_fs_t* req) {
|
||||
uv__free(buf);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
req->ptr = buf;
|
||||
|
||||
|
20
deps/uv/src/unix/getaddrinfo.c
vendored
20
deps/uv/src/unix/getaddrinfo.c
vendored
@ -27,6 +27,7 @@
|
||||
|
||||
#include "uv.h"
|
||||
#include "internal.h"
|
||||
#include "idna.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h> /* NULL */
|
||||
@ -141,15 +142,34 @@ int uv_getaddrinfo(uv_loop_t* loop,
|
||||
const char* hostname,
|
||||
const char* service,
|
||||
const struct addrinfo* hints) {
|
||||
char hostname_ascii[256];
|
||||
size_t hostname_len;
|
||||
size_t service_len;
|
||||
size_t hints_len;
|
||||
size_t len;
|
||||
char* buf;
|
||||
long rc;
|
||||
|
||||
if (req == NULL || (hostname == NULL && service == NULL))
|
||||
return UV_EINVAL;
|
||||
|
||||
/* FIXME(bnoordhuis) IDNA does not seem to work z/OS,
|
||||
* probably because it uses EBCDIC rather than ASCII.
|
||||
*/
|
||||
#ifdef __MVS__
|
||||
(void) &hostname_ascii;
|
||||
#else
|
||||
if (hostname != NULL) {
|
||||
rc = uv__idna_toascii(hostname,
|
||||
hostname + strlen(hostname),
|
||||
hostname_ascii,
|
||||
hostname_ascii + sizeof(hostname_ascii));
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
hostname = hostname_ascii;
|
||||
}
|
||||
#endif
|
||||
|
||||
hostname_len = hostname ? strlen(hostname) + 1 : 0;
|
||||
service_len = service ? strlen(service) + 1 : 0;
|
||||
hints_len = hints ? sizeof(*hints) : 0;
|
||||
|
1
deps/uv/src/unix/internal.h
vendored
1
deps/uv/src/unix/internal.h
vendored
@ -185,7 +185,6 @@ int uv__nonblock_fcntl(int fd, int set);
|
||||
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);
|
||||
ssize_t uv__recvmsg(int fd, struct msghdr *msg, int flags);
|
||||
void uv__make_close_pending(uv_handle_t* handle);
|
||||
int uv__getiovmax(void);
|
||||
|
18
deps/uv/src/unix/linux-core.c
vendored
18
deps/uv/src/unix/linux-core.c
vendored
@ -826,9 +826,10 @@ static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type) {
|
||||
return !exclude_type;
|
||||
}
|
||||
|
||||
int uv_interface_addresses(uv_interface_address_t** addresses,
|
||||
int* count) {
|
||||
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
|
||||
#ifndef HAVE_IFADDRS_H
|
||||
*count = 0;
|
||||
*addresses = NULL;
|
||||
return UV_ENOSYS;
|
||||
#else
|
||||
struct ifaddrs *addrs, *ent;
|
||||
@ -836,12 +837,12 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
|
||||
int i;
|
||||
struct sockaddr_ll *sll;
|
||||
|
||||
if (getifaddrs(&addrs))
|
||||
return UV__ERR(errno);
|
||||
|
||||
*count = 0;
|
||||
*addresses = NULL;
|
||||
|
||||
if (getifaddrs(&addrs))
|
||||
return UV__ERR(errno);
|
||||
|
||||
/* Count the number of interfaces */
|
||||
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
|
||||
if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR))
|
||||
@ -850,8 +851,10 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
if (*count == 0)
|
||||
if (*count == 0) {
|
||||
freeifaddrs(addrs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*addresses = uv__malloc(*count * sizeof(**addresses));
|
||||
if (!(*addresses)) {
|
||||
@ -890,12 +893,13 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
|
||||
continue;
|
||||
|
||||
address = *addresses;
|
||||
memset(address->phys_addr, 0, sizeof(address->phys_addr));
|
||||
|
||||
for (i = 0; i < (*count); i++) {
|
||||
if (strcmp(address->name, ent->ifa_name) == 0) {
|
||||
sll = (struct sockaddr_ll*)ent->ifa_addr;
|
||||
memcpy(address->phys_addr, sll->sll_addr, sizeof(address->phys_addr));
|
||||
} else {
|
||||
memset(address->phys_addr, 0, sizeof(address->phys_addr));
|
||||
}
|
||||
address++;
|
||||
}
|
||||
|
68
deps/uv/src/unix/netbsd.c
vendored
68
deps/uv/src/unix/netbsd.c
vendored
@ -40,15 +40,6 @@
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
static uv_mutex_t process_title_mutex;
|
||||
static uv_once_t process_title_mutex_once = UV_ONCE_INIT;
|
||||
static char *process_title;
|
||||
|
||||
|
||||
static void init_process_title_mutex_once(void) {
|
||||
uv_mutex_init(&process_title_mutex);
|
||||
}
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop) {
|
||||
return uv__kqueue_init(loop);
|
||||
@ -134,65 +125,6 @@ uint64_t uv_get_total_memory(void) {
|
||||
}
|
||||
|
||||
|
||||
char** uv_setup_args(int argc, char** argv) {
|
||||
process_title = argc ? uv__strdup(argv[0]) : NULL;
|
||||
return argv;
|
||||
}
|
||||
|
||||
|
||||
int uv_set_process_title(const char* title) {
|
||||
char* new_title;
|
||||
|
||||
new_title = uv__strdup(title);
|
||||
|
||||
uv_once(&process_title_mutex_once, init_process_title_mutex_once);
|
||||
uv_mutex_lock(&process_title_mutex);
|
||||
|
||||
if (process_title == NULL) {
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
return UV_ENOMEM;
|
||||
}
|
||||
|
||||
uv__free(process_title);
|
||||
process_title = new_title;
|
||||
setproctitle("%s", title);
|
||||
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv_get_process_title(char* buffer, size_t size) {
|
||||
size_t len;
|
||||
|
||||
if (buffer == NULL || size == 0)
|
||||
return UV_EINVAL;
|
||||
|
||||
uv_once(&process_title_mutex_once, init_process_title_mutex_once);
|
||||
uv_mutex_lock(&process_title_mutex);
|
||||
|
||||
if (process_title) {
|
||||
len = strlen(process_title) + 1;
|
||||
|
||||
if (size < len) {
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
return UV_ENOBUFS;
|
||||
}
|
||||
|
||||
memcpy(buffer, process_title, len);
|
||||
} else {
|
||||
len = 0;
|
||||
}
|
||||
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
|
||||
buffer[len] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv_resident_set_memory(size_t* rss) {
|
||||
kvm_t *kd = NULL;
|
||||
struct kinfo_proc2 *kinfo = NULL;
|
||||
|
69
deps/uv/src/unix/openbsd.c
vendored
69
deps/uv/src/unix/openbsd.c
vendored
@ -36,16 +36,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static uv_mutex_t process_title_mutex;
|
||||
static uv_once_t process_title_mutex_once = UV_ONCE_INIT;
|
||||
static char *process_title;
|
||||
|
||||
|
||||
static void init_process_title_mutex_once(void) {
|
||||
uv_mutex_init(&process_title_mutex);
|
||||
}
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop) {
|
||||
return uv__kqueue_init(loop);
|
||||
}
|
||||
@ -146,65 +136,6 @@ uint64_t uv_get_total_memory(void) {
|
||||
}
|
||||
|
||||
|
||||
char** uv_setup_args(int argc, char** argv) {
|
||||
process_title = argc ? uv__strdup(argv[0]) : NULL;
|
||||
return argv;
|
||||
}
|
||||
|
||||
|
||||
int uv_set_process_title(const char* title) {
|
||||
char* new_title;
|
||||
|
||||
new_title = uv__strdup(title);
|
||||
|
||||
uv_once(&process_title_mutex_once, init_process_title_mutex_once);
|
||||
uv_mutex_lock(&process_title_mutex);
|
||||
|
||||
if (process_title == NULL) {
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
return UV_ENOMEM;
|
||||
}
|
||||
|
||||
uv__free(process_title);
|
||||
process_title = new_title;
|
||||
setproctitle("%s", title);
|
||||
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv_get_process_title(char* buffer, size_t size) {
|
||||
size_t len;
|
||||
|
||||
if (buffer == NULL || size == 0)
|
||||
return UV_EINVAL;
|
||||
|
||||
uv_once(&process_title_mutex_once, init_process_title_mutex_once);
|
||||
uv_mutex_lock(&process_title_mutex);
|
||||
|
||||
if (process_title) {
|
||||
len = strlen(process_title) + 1;
|
||||
|
||||
if (size < len) {
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
return UV_ENOBUFS;
|
||||
}
|
||||
|
||||
memcpy(buffer, process_title, len);
|
||||
} else {
|
||||
len = 0;
|
||||
}
|
||||
|
||||
uv_mutex_unlock(&process_title_mutex);
|
||||
|
||||
buffer[len] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv_resident_set_memory(size_t* rss) {
|
||||
struct kinfo_proc kinfo;
|
||||
size_t page_size = getpagesize();
|
||||
|
17
deps/uv/src/unix/os390.c
vendored
17
deps/uv/src/unix/os390.c
vendored
@ -357,13 +357,11 @@ uint64_t uv_get_total_memory(void) {
|
||||
|
||||
|
||||
int uv_resident_set_memory(size_t* rss) {
|
||||
char* psa;
|
||||
char* ascb;
|
||||
char* rax;
|
||||
size_t nframes;
|
||||
|
||||
psa = PSA_PTR;
|
||||
ascb = *(char* __ptr32 *)(psa + PSAAOLD);
|
||||
ascb = *(char* __ptr32 *)(PSA_PTR + PSAAOLD);
|
||||
rax = *(char* __ptr32 *)(ascb + ASCBRSME);
|
||||
nframes = *(unsigned int*)(rax + RAXFMCT);
|
||||
|
||||
@ -531,12 +529,14 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
|
||||
struct ifreq* p;
|
||||
int count_v6;
|
||||
|
||||
*count = 0;
|
||||
*addresses = NULL;
|
||||
|
||||
/* get the ipv6 addresses first */
|
||||
uv_interface_address_t* addresses_v6;
|
||||
uv__interface_addresses_v6(&addresses_v6, &count_v6);
|
||||
|
||||
/* now get the ipv4 addresses */
|
||||
*count = 0;
|
||||
|
||||
/* Assume maximum buffer size allowable */
|
||||
maxsize = 16384;
|
||||
@ -578,6 +578,11 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
if (*count == 0) {
|
||||
uv__close(sockfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Alloc the return interface structs */
|
||||
*addresses = uv__malloc((*count + count_v6) *
|
||||
sizeof(uv_interface_address_t));
|
||||
@ -752,7 +757,7 @@ int uv_fs_event_stop(uv_fs_event_t* handle) {
|
||||
memcpy(reg_struct.__rfis_rftok, handle->rfis_rftok,
|
||||
sizeof(handle->rfis_rftok));
|
||||
|
||||
/*
|
||||
/*
|
||||
* This call will take "/" as the path argument in case we
|
||||
* don't care to supply the correct path. The system will simply
|
||||
* ignore it.
|
||||
@ -988,7 +993,7 @@ void uv__set_process_title(const char* title) {
|
||||
}
|
||||
|
||||
int uv__io_fork(uv_loop_t* loop) {
|
||||
/*
|
||||
/*
|
||||
Nullify the msg queue but don't close it because
|
||||
it is still being used by the parent.
|
||||
*/
|
||||
|
4
deps/uv/src/unix/proctitle.c
vendored
4
deps/uv/src/unix/proctitle.c
vendored
@ -24,6 +24,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern void uv__set_process_title_platform_init(void);
|
||||
extern void uv__set_process_title(const char* title);
|
||||
|
||||
static uv_mutex_t process_title_mutex;
|
||||
@ -38,6 +39,9 @@ static struct {
|
||||
|
||||
static void init_process_title_mutex_once(void) {
|
||||
uv_mutex_init(&process_title_mutex);
|
||||
#ifdef __APPLE__
|
||||
uv__set_process_title_platform_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
12
deps/uv/src/unix/sunos.c
vendored
12
deps/uv/src/unix/sunos.c
vendored
@ -692,6 +692,8 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
|
||||
|
||||
#ifdef SUNOS_NO_IFADDRS
|
||||
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
|
||||
*count = 0;
|
||||
*addresses = NULL;
|
||||
return UV_ENOSYS;
|
||||
}
|
||||
#else /* SUNOS_NO_IFADDRS */
|
||||
@ -758,11 +760,12 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
|
||||
struct ifaddrs* addrs;
|
||||
struct ifaddrs* ent;
|
||||
|
||||
*count = 0;
|
||||
*addresses = NULL;
|
||||
|
||||
if (getifaddrs(&addrs))
|
||||
return UV__ERR(errno);
|
||||
|
||||
*count = 0;
|
||||
|
||||
/* Count the number of interfaces */
|
||||
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
|
||||
if (uv__ifaddr_exclude(ent))
|
||||
@ -770,6 +773,11 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
if (*count == 0) {
|
||||
freeifaddrs(addrs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*addresses = uv__malloc(*count * sizeof(**addresses));
|
||||
if (!(*addresses)) {
|
||||
freeifaddrs(addrs);
|
||||
|
9
deps/uv/src/uv-common.c
vendored
9
deps/uv/src/uv-common.c
vendored
@ -72,7 +72,9 @@ char* uv__strndup(const char* s, size_t n) {
|
||||
}
|
||||
|
||||
void* uv__malloc(size_t size) {
|
||||
return uv__allocator.local_malloc(size);
|
||||
if (size > 0)
|
||||
return uv__allocator.local_malloc(size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void uv__free(void* ptr) {
|
||||
@ -91,7 +93,10 @@ void* uv__calloc(size_t count, size_t size) {
|
||||
}
|
||||
|
||||
void* uv__realloc(void* ptr, size_t size) {
|
||||
return uv__allocator.local_realloc(ptr, size);
|
||||
if (size > 0)
|
||||
return uv__allocator.local_realloc(ptr, size);
|
||||
uv__free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int uv_replace_allocator(uv_malloc_func malloc_func,
|
||||
|
3
deps/uv/src/win/dl.c
vendored
3
deps/uv/src/win/dl.c
vendored
@ -107,7 +107,8 @@ static int uv__dlerror(uv_lib_t* lib, const char* filename, DWORD errorno) {
|
||||
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
|
||||
(LPSTR) &lib->errmsg, 0, NULL);
|
||||
|
||||
if (!res && GetLastError() == ERROR_MUI_FILE_NOT_FOUND) {
|
||||
if (!res && (GetLastError() == ERROR_MUI_FILE_NOT_FOUND ||
|
||||
GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND)) {
|
||||
res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno,
|
||||
|
72
deps/uv/src/win/fs.c
vendored
72
deps/uv/src/win/fs.c
vendored
@ -42,6 +42,8 @@
|
||||
#define UV_FS_FREE_PTR 0x0008
|
||||
#define UV_FS_CLEANEDUP 0x0010
|
||||
|
||||
#define UV__RENAME_RETRIES 4
|
||||
#define UV__RENAME_WAIT 250
|
||||
|
||||
#define INIT(subtype) \
|
||||
do { \
|
||||
@ -1329,12 +1331,78 @@ static void fs__fstat(uv_fs_t* req) {
|
||||
|
||||
|
||||
static void fs__rename(uv_fs_t* req) {
|
||||
if (!MoveFileExW(req->file.pathw, req->fs.info.new_pathw, MOVEFILE_REPLACE_EXISTING)) {
|
||||
int tries;
|
||||
int sys_errno;
|
||||
int result;
|
||||
int try_rmdir;
|
||||
WCHAR* src, *dst;
|
||||
DWORD src_attrib, dst_attrib;
|
||||
|
||||
src = req->file.pathw;
|
||||
dst = req->fs.info.new_pathw;
|
||||
try_rmdir = 0;
|
||||
|
||||
/* Do some checks to fail early. */
|
||||
src_attrib = GetFileAttributesW(src);
|
||||
if (src_attrib == INVALID_FILE_ATTRIBUTES) {
|
||||
SET_REQ_WIN32_ERROR(req, GetLastError());
|
||||
return;
|
||||
}
|
||||
dst_attrib = GetFileAttributesW(dst);
|
||||
if (dst_attrib != INVALID_FILE_ATTRIBUTES) {
|
||||
if (dst_attrib & FILE_ATTRIBUTE_READONLY) {
|
||||
req->result = UV_EPERM;
|
||||
return;
|
||||
}
|
||||
/* Renaming folder to a folder name that already exist will fail on
|
||||
* Windows. We will try to delete target folder first.
|
||||
*/
|
||||
if (src_attrib & FILE_ATTRIBUTE_DIRECTORY &&
|
||||
dst_attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
try_rmdir = 1;
|
||||
}
|
||||
|
||||
SET_REQ_RESULT(req, 0);
|
||||
/* Sometimes an antivirus or indexing software can lock the target or the
|
||||
* source file/directory. This is annoying for users, in such cases we will
|
||||
* retry couple of times with some delay before failing.
|
||||
*/
|
||||
for (tries = 0; tries < UV__RENAME_RETRIES; ++tries) {
|
||||
if (tries > 0)
|
||||
Sleep(UV__RENAME_WAIT);
|
||||
|
||||
if (try_rmdir) {
|
||||
result = _wrmdir(dst) == 0 ? 0 : uv_translate_sys_error(_doserrno);
|
||||
switch (result)
|
||||
{
|
||||
case 0:
|
||||
case UV_ENOENT:
|
||||
/* Folder removed or did not exist at all. */
|
||||
try_rmdir = 0;
|
||||
break;
|
||||
case UV_ENOTEMPTY:
|
||||
/* Non-empty target folder, fail instantly. */
|
||||
SET_REQ_RESULT(req, -1);
|
||||
return;
|
||||
default:
|
||||
/* All other errors - try to move file anyway and handle the error
|
||||
* there, retrying folder deletion next time around.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (MoveFileExW(src, dst, MOVEFILE_REPLACE_EXISTING) != 0) {
|
||||
SET_REQ_RESULT(req, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
sys_errno = GetLastError();
|
||||
result = uv_translate_sys_error(sys_errno);
|
||||
if (result != UV_EBUSY && result != UV_EPERM && result != UV_EACCES)
|
||||
break;
|
||||
}
|
||||
req->sys_errno_ = sys_errno;
|
||||
req->result = result;
|
||||
}
|
||||
|
||||
|
||||
|
14
deps/uv/src/win/getaddrinfo.c
vendored
14
deps/uv/src/win/getaddrinfo.c
vendored
@ -24,6 +24,7 @@
|
||||
#include "uv.h"
|
||||
#include "internal.h"
|
||||
#include "req-inl.h"
|
||||
#include "idna.h"
|
||||
|
||||
/* EAI_* constants. */
|
||||
#include <winsock2.h>
|
||||
@ -259,11 +260,13 @@ int uv_getaddrinfo(uv_loop_t* loop,
|
||||
const char* node,
|
||||
const char* service,
|
||||
const struct addrinfo* hints) {
|
||||
char hostname_ascii[256];
|
||||
int nodesize = 0;
|
||||
int servicesize = 0;
|
||||
int hintssize = 0;
|
||||
char* alloc_ptr = NULL;
|
||||
int err;
|
||||
long rc;
|
||||
|
||||
if (req == NULL || (node == NULL && service == NULL)) {
|
||||
return UV_EINVAL;
|
||||
@ -277,12 +280,19 @@ int uv_getaddrinfo(uv_loop_t* loop,
|
||||
|
||||
/* calculate required memory size for all input values */
|
||||
if (node != NULL) {
|
||||
nodesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, node, -1, NULL, 0) *
|
||||
sizeof(WCHAR));
|
||||
rc = uv__idna_toascii(node,
|
||||
node + strlen(node),
|
||||
hostname_ascii,
|
||||
hostname_ascii + sizeof(hostname_ascii));
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
nodesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, hostname_ascii,
|
||||
-1, NULL, 0) * sizeof(WCHAR));
|
||||
if (nodesize == 0) {
|
||||
err = GetLastError();
|
||||
goto error;
|
||||
}
|
||||
node = hostname_ascii;
|
||||
}
|
||||
|
||||
if (service != NULL) {
|
||||
|
9
deps/uv/src/win/process.c
vendored
9
deps/uv/src/win/process.c
vendored
@ -964,6 +964,8 @@ int uv_spawn(uv_loop_t* loop,
|
||||
UV_PROCESS_SETGID |
|
||||
UV_PROCESS_SETUID |
|
||||
UV_PROCESS_WINDOWS_HIDE |
|
||||
UV_PROCESS_WINDOWS_HIDE_CONSOLE |
|
||||
UV_PROCESS_WINDOWS_HIDE_GUI |
|
||||
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS)));
|
||||
|
||||
err = uv_utf8_to_utf16_alloc(options->file, &application);
|
||||
@ -1065,7 +1067,8 @@ int uv_spawn(uv_loop_t* loop,
|
||||
|
||||
process_flags = CREATE_UNICODE_ENVIRONMENT;
|
||||
|
||||
if (options->flags & UV_PROCESS_WINDOWS_HIDE) {
|
||||
if ((options->flags & UV_PROCESS_WINDOWS_HIDE_CONSOLE) ||
|
||||
(options->flags & UV_PROCESS_WINDOWS_HIDE)) {
|
||||
/* Avoid creating console window if stdio is not inherited. */
|
||||
for (i = 0; i < options->stdio_count; i++) {
|
||||
if (options->stdio[i].flags & UV_INHERIT_FD)
|
||||
@ -1073,7 +1076,9 @@ int uv_spawn(uv_loop_t* loop,
|
||||
if (i == options->stdio_count - 1)
|
||||
process_flags |= CREATE_NO_WINDOW;
|
||||
}
|
||||
|
||||
}
|
||||
if ((options->flags & UV_PROCESS_WINDOWS_HIDE_GUI) ||
|
||||
(options->flags & UV_PROCESS_WINDOWS_HIDE)) {
|
||||
/* Use SW_HIDE to avoid any potential process window. */
|
||||
startup.wShowWindow = SW_HIDE;
|
||||
} else {
|
||||
|
2
deps/uv/src/win/signal.c
vendored
2
deps/uv/src/win/signal.c
vendored
@ -190,7 +190,7 @@ int uv__signal_start(uv_signal_t* handle,
|
||||
int signum,
|
||||
int oneshot) {
|
||||
/* Test for invalid signal values. */
|
||||
if (signum != SIGWINCH && (signum <= 0 || signum >= NSIG))
|
||||
if (signum <= 0 || signum >= NSIG)
|
||||
return UV_EINVAL;
|
||||
|
||||
/* Short circuit: if the signal watcher is already watching {signum} don't go
|
||||
|
4
deps/uv/src/win/tcp.c
vendored
4
deps/uv/src/win/tcp.c
vendored
@ -945,6 +945,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
uv_req_t* req) {
|
||||
DWORD bytes, flags, err;
|
||||
uv_buf_t buf;
|
||||
int count;
|
||||
|
||||
assert(handle->type == UV_TCP);
|
||||
|
||||
@ -999,7 +1000,8 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
}
|
||||
|
||||
/* Do nonblocking reads until the buffer is empty */
|
||||
while (handle->flags & UV_HANDLE_READING) {
|
||||
count = 32;
|
||||
while ((handle->flags & UV_HANDLE_READING) && (count-- > 0)) {
|
||||
buf = uv_buf_init(NULL, 0);
|
||||
handle->alloc_cb((uv_handle_t*) handle, 65536, &buf);
|
||||
if (buf.base == NULL || buf.len == 0) {
|
||||
|
11
deps/uv/src/win/tty.c
vendored
11
deps/uv/src/win/tty.c
vendored
@ -941,20 +941,15 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
handle->read_cb((uv_stream_t*) handle,
|
||||
uv_translate_sys_error(GET_REQ_ERROR(req)),
|
||||
&buf);
|
||||
} else {
|
||||
/* The read was cancelled, or whatever we don't care */
|
||||
handle->read_cb((uv_stream_t*) handle, 0, &buf);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) {
|
||||
if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING) &&
|
||||
req->u.io.overlapped.InternalHigh != 0) {
|
||||
/* Read successful. TODO: read unicode, convert to utf-8 */
|
||||
DWORD bytes = req->u.io.overlapped.InternalHigh;
|
||||
handle->read_cb((uv_stream_t*) handle, bytes, &buf);
|
||||
} else {
|
||||
handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING;
|
||||
handle->read_cb((uv_stream_t*) handle, 0, &buf);
|
||||
}
|
||||
handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING;
|
||||
}
|
||||
|
||||
/* Wait for more input events. */
|
||||
|
3
deps/uv/src/win/util.c
vendored
3
deps/uv/src/win/util.c
vendored
@ -816,6 +816,9 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
|
||||
int is_vista_or_greater;
|
||||
ULONG flags;
|
||||
|
||||
*addresses_ptr = NULL;
|
||||
*count_ptr = 0;
|
||||
|
||||
is_vista_or_greater = is_windows_version_or_greater(6, 0, 0, 0);
|
||||
if (is_vista_or_greater) {
|
||||
flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST |
|
||||
|
4
deps/uv/test/echo-server.c
vendored
4
deps/uv/test/echo-server.c
vendored
@ -340,6 +340,7 @@ HELPER_IMPL(tcp4_echo_server) {
|
||||
if (tcp4_echo_start(TEST_PORT))
|
||||
return 1;
|
||||
|
||||
notify_parent_process();
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
return 0;
|
||||
}
|
||||
@ -351,6 +352,7 @@ HELPER_IMPL(tcp6_echo_server) {
|
||||
if (tcp6_echo_start(TEST_PORT))
|
||||
return 1;
|
||||
|
||||
notify_parent_process();
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
return 0;
|
||||
}
|
||||
@ -362,6 +364,7 @@ HELPER_IMPL(pipe_echo_server) {
|
||||
if (pipe_echo_start(TEST_PIPENAME))
|
||||
return 1;
|
||||
|
||||
notify_parent_process();
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
return 0;
|
||||
}
|
||||
@ -373,6 +376,7 @@ HELPER_IMPL(udp4_echo_server) {
|
||||
if (udp4_echo_start(TEST_PORT))
|
||||
return 1;
|
||||
|
||||
notify_parent_process();
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
return 0;
|
||||
}
|
||||
|
15
deps/uv/test/run-tests.c
vendored
15
deps/uv/test/run-tests.c
vendored
@ -109,20 +109,24 @@ static int maybe_run_test(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "spawn_helper1") == 0) {
|
||||
notify_parent_process();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "spawn_helper2") == 0) {
|
||||
notify_parent_process();
|
||||
printf("hello world\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "spawn_tcp_server_helper") == 0) {
|
||||
notify_parent_process();
|
||||
return spawn_tcp_server_helper();
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "spawn_helper3") == 0) {
|
||||
char buffer[256];
|
||||
notify_parent_process();
|
||||
ASSERT(buffer == fgets(buffer, sizeof(buffer) - 1, stdin));
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
fputs(buffer, stdout);
|
||||
@ -130,12 +134,14 @@ static int maybe_run_test(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "spawn_helper4") == 0) {
|
||||
notify_parent_process();
|
||||
/* Never surrender, never return! */
|
||||
while (1) uv_sleep(10000);
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "spawn_helper5") == 0) {
|
||||
const char out[] = "fourth stdio!\n";
|
||||
notify_parent_process();
|
||||
#ifdef _WIN32
|
||||
DWORD bytes;
|
||||
WriteFile((HANDLE) _get_osfhandle(3), out, sizeof(out) - 1, &bytes, NULL);
|
||||
@ -156,6 +162,8 @@ static int maybe_run_test(int argc, char **argv) {
|
||||
if (strcmp(argv[1], "spawn_helper6") == 0) {
|
||||
int r;
|
||||
|
||||
notify_parent_process();
|
||||
|
||||
r = fprintf(stdout, "hello world\n");
|
||||
ASSERT(r > 0);
|
||||
|
||||
@ -168,6 +176,9 @@ static int maybe_run_test(int argc, char **argv) {
|
||||
if (strcmp(argv[1], "spawn_helper7") == 0) {
|
||||
int r;
|
||||
char *test;
|
||||
|
||||
notify_parent_process();
|
||||
|
||||
/* Test if the test value from the parent is still set */
|
||||
test = getenv("ENV_TEST");
|
||||
ASSERT(test != NULL);
|
||||
@ -181,6 +192,8 @@ static int maybe_run_test(int argc, char **argv) {
|
||||
#ifndef _WIN32
|
||||
if (strcmp(argv[1], "spawn_helper8") == 0) {
|
||||
int fd;
|
||||
|
||||
notify_parent_process();
|
||||
ASSERT(sizeof(fd) == read(0, &fd, sizeof(fd)));
|
||||
ASSERT(fd > 2);
|
||||
ASSERT(-1 == write(fd, "x", 1));
|
||||
@ -190,6 +203,7 @@ static int maybe_run_test(int argc, char **argv) {
|
||||
#endif /* !_WIN32 */
|
||||
|
||||
if (strcmp(argv[1], "spawn_helper9") == 0) {
|
||||
notify_parent_process();
|
||||
return spawn_stdin_stdout();
|
||||
}
|
||||
|
||||
@ -200,6 +214,7 @@ static int maybe_run_test(int argc, char **argv) {
|
||||
|
||||
ASSERT(uid == getuid());
|
||||
ASSERT(gid == getgid());
|
||||
notify_parent_process();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
107
deps/uv/test/runner-unix.c
vendored
107
deps/uv/test/runner-unix.c
vendored
@ -40,6 +40,31 @@
|
||||
#include <sys/time.h>
|
||||
#include <pthread.h>
|
||||
|
||||
extern char** environ;
|
||||
|
||||
static void closefd(int fd) {
|
||||
if (close(fd) == 0 || errno == EINTR || errno == EINPROGRESS)
|
||||
return;
|
||||
|
||||
perror("close");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
void notify_parent_process(void) {
|
||||
char* arg;
|
||||
int fd;
|
||||
|
||||
arg = getenv("UV_TEST_RUNNER_FD");
|
||||
if (arg == NULL)
|
||||
return;
|
||||
|
||||
fd = atoi(arg);
|
||||
assert(fd > STDERR_FILENO);
|
||||
unsetenv("UV_TEST_RUNNER_FD");
|
||||
closefd(fd);
|
||||
}
|
||||
|
||||
|
||||
/* Do platform-specific initialization. */
|
||||
int platform_init(int argc, char **argv) {
|
||||
@ -64,9 +89,31 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) {
|
||||
int stdout_fd;
|
||||
const char* arg;
|
||||
char* args[16];
|
||||
int pipefd[2];
|
||||
char fdstr[8];
|
||||
ssize_t rc;
|
||||
int n;
|
||||
pid_t pid;
|
||||
|
||||
arg = getenv("UV_USE_VALGRIND");
|
||||
n = 0;
|
||||
|
||||
/* Disable valgrind for helpers, it complains about helpers leaking memory.
|
||||
* They're killed after the test and as such never get a chance to clean up.
|
||||
*/
|
||||
if (is_helper == 0 && arg != NULL && atoi(arg) != 0) {
|
||||
args[n++] = "valgrind";
|
||||
args[n++] = "--quiet";
|
||||
args[n++] = "--leak-check=full";
|
||||
args[n++] = "--show-reachable=yes";
|
||||
args[n++] = "--error-exitcode=125";
|
||||
}
|
||||
|
||||
args[n++] = executable_path;
|
||||
args[n++] = name;
|
||||
args[n++] = part;
|
||||
args[n++] = NULL;
|
||||
|
||||
stdout_file = tmpfile();
|
||||
stdout_fd = fileno(stdout_file);
|
||||
if (!stdout_file) {
|
||||
@ -74,6 +121,19 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_helper) {
|
||||
if (pipe(pipefd)) {
|
||||
perror("pipe");
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(fdstr, sizeof(fdstr), "%d", pipefd[1]);
|
||||
if (setenv("UV_TEST_RUNNER_FD", fdstr, /* overwrite */ 1)) {
|
||||
perror("setenv");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
p->terminated = 0;
|
||||
p->status = 0;
|
||||
|
||||
@ -86,29 +146,12 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) {
|
||||
|
||||
if (pid == 0) {
|
||||
/* child */
|
||||
arg = getenv("UV_USE_VALGRIND");
|
||||
n = 0;
|
||||
|
||||
/* Disable valgrind for helpers, it complains about helpers leaking memory.
|
||||
* They're killed after the test and as such never get a chance to clean up.
|
||||
*/
|
||||
if (is_helper == 0 && arg != NULL && atoi(arg) != 0) {
|
||||
args[n++] = "valgrind";
|
||||
args[n++] = "--quiet";
|
||||
args[n++] = "--leak-check=full";
|
||||
args[n++] = "--show-reachable=yes";
|
||||
args[n++] = "--error-exitcode=125";
|
||||
}
|
||||
|
||||
args[n++] = executable_path;
|
||||
args[n++] = name;
|
||||
args[n++] = part;
|
||||
args[n++] = NULL;
|
||||
|
||||
if (is_helper)
|
||||
closefd(pipefd[0]);
|
||||
dup2(stdout_fd, STDOUT_FILENO);
|
||||
dup2(stdout_fd, STDERR_FILENO);
|
||||
execvp(args[0], args);
|
||||
perror("execvp()");
|
||||
execve(args[0], args, environ);
|
||||
perror("execve()");
|
||||
_exit(127);
|
||||
}
|
||||
|
||||
@ -117,6 +160,28 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) {
|
||||
p->name = strdup(name);
|
||||
p->stdout_file = stdout_file;
|
||||
|
||||
if (!is_helper)
|
||||
return 0;
|
||||
|
||||
closefd(pipefd[1]);
|
||||
unsetenv("UV_TEST_RUNNER_FD");
|
||||
|
||||
do
|
||||
rc = read(pipefd[0], &n, 1);
|
||||
while (rc == -1 && errno == EINTR);
|
||||
|
||||
closefd(pipefd[0]);
|
||||
|
||||
if (rc == -1) {
|
||||
perror("read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rc > 0) {
|
||||
fprintf(stderr, "EOF expected but got data.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
5
deps/uv/test/runner-win.c
vendored
5
deps/uv/test/runner-win.c
vendored
@ -76,6 +76,11 @@ int process_start(char *name, char *part, process_info_t *p, int is_helper) {
|
||||
PROCESS_INFORMATION pi;
|
||||
DWORD result;
|
||||
|
||||
if (!is_helper) {
|
||||
/* Give the helpers time to settle. Race-y, fix this. */
|
||||
uv_sleep(250);
|
||||
}
|
||||
|
||||
if (GetTempPathW(sizeof(path) / sizeof(WCHAR), (WCHAR*)&path) == 0)
|
||||
goto error;
|
||||
if (GetTempFileNameW((WCHAR*)&path, L"uv", 0, (WCHAR*)&filename) == 0)
|
||||
|
3
deps/uv/test/runner.c
vendored
3
deps/uv/test/runner.c
vendored
@ -215,9 +215,6 @@ int run_test(const char* test,
|
||||
process_count++;
|
||||
}
|
||||
|
||||
/* Give the helpers time to settle. Race-y, fix this. */
|
||||
uv_sleep(250);
|
||||
|
||||
/* Now start the test itself. */
|
||||
for (task = TASKS; task->main; task++) {
|
||||
if (strcmp(test, task->task_name) != 0) {
|
||||
|
6
deps/uv/test/task.h
vendored
6
deps/uv/test/task.h
vendored
@ -181,6 +181,12 @@ extern int snprintf(char*, size_t, const char*, ...);
|
||||
# define UNUSED
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define notify_parent_process() ((void) 0)
|
||||
#else
|
||||
extern void notify_parent_process(void);
|
||||
#endif
|
||||
|
||||
/* Fully close a loop */
|
||||
static void close_walk_cb(uv_handle_t* handle, void* arg) {
|
||||
if (!uv_is_closing(handle))
|
||||
|
54
deps/uv/test/test-fs.c
vendored
54
deps/uv/test/test-fs.c
vendored
@ -3037,6 +3037,60 @@ TEST_IMPL(fs_write_alotof_bufs_with_offset) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_IMPL(fs_read_dir) {
|
||||
int r;
|
||||
char buf[2];
|
||||
loop = uv_default_loop();
|
||||
|
||||
/* Setup */
|
||||
rmdir("test_dir");
|
||||
r = uv_fs_mkdir(loop, &mkdir_req, "test_dir", 0755, mkdir_cb);
|
||||
ASSERT(r == 0);
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
ASSERT(mkdir_cb_count == 1);
|
||||
/* Setup Done Here */
|
||||
|
||||
/* Get a file descriptor for the directory */
|
||||
r = uv_fs_open(loop,
|
||||
&open_req1,
|
||||
"test_dir",
|
||||
UV_FS_O_RDONLY | UV_FS_O_DIRECTORY,
|
||||
S_IWUSR | S_IRUSR,
|
||||
NULL);
|
||||
ASSERT(r >= 0);
|
||||
uv_fs_req_cleanup(&open_req1);
|
||||
|
||||
/* Try to read data from the directory */
|
||||
iov = uv_buf_init(buf, sizeof(buf));
|
||||
r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, 0, NULL);
|
||||
#if defined(__FreeBSD__) || \
|
||||
defined(__OpenBSD__) || \
|
||||
defined(__NetBSD__) || \
|
||||
defined(__DragonFly__) || \
|
||||
defined(_AIX) || \
|
||||
defined(__sun) || \
|
||||
defined(__MVS__)
|
||||
/*
|
||||
* As of now, these operating systems support reading from a directory,
|
||||
* that too depends on the filesystem this temporary test directory is
|
||||
* created on. That is why this assertion is a bit lenient.
|
||||
*/
|
||||
ASSERT((r >= 0) || (r == UV_EISDIR));
|
||||
#else
|
||||
ASSERT(r == UV_EISDIR);
|
||||
#endif
|
||||
uv_fs_req_cleanup(&read_req);
|
||||
|
||||
r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
|
||||
ASSERT(r == 0);
|
||||
uv_fs_req_cleanup(&close_req);
|
||||
|
||||
/* Cleanup */
|
||||
rmdir("test_dir");
|
||||
|
||||
MAKE_VALGRIND_HAPPY();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
|
195
deps/uv/test/test-idna.c
vendored
Normal file
195
deps/uv/test/test-idna.c
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
/* Copyright The libuv project and contributors. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "task.h"
|
||||
#include "../src/idna.c"
|
||||
#include <string.h>
|
||||
|
||||
TEST_IMPL(utf8_decode1) {
|
||||
const char* p;
|
||||
char b[32];
|
||||
int i;
|
||||
|
||||
/* ASCII. */
|
||||
p = b;
|
||||
snprintf(b, sizeof(b), "%c\x7F", 0x00);
|
||||
ASSERT(0 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 1);
|
||||
ASSERT(127 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 2);
|
||||
|
||||
/* Two-byte sequences. */
|
||||
p = b;
|
||||
snprintf(b, sizeof(b), "\xC2\x80\xDF\xBF");
|
||||
ASSERT(128 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 2);
|
||||
ASSERT(0x7FF == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 4);
|
||||
|
||||
/* Three-byte sequences. */
|
||||
p = b;
|
||||
snprintf(b, sizeof(b), "\xE0\xA0\x80\xEF\xBF\xBF");
|
||||
ASSERT(0x800 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 3);
|
||||
ASSERT(0xFFFF == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 6);
|
||||
|
||||
/* Four-byte sequences. */
|
||||
p = b;
|
||||
snprintf(b, sizeof(b), "\xF0\x90\x80\x80\xF4\x8F\xBF\xBF");
|
||||
ASSERT(0x10000 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 4);
|
||||
ASSERT(0x10FFFF == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 8);
|
||||
|
||||
/* Four-byte sequences > U+10FFFF; disallowed. */
|
||||
p = b;
|
||||
snprintf(b, sizeof(b), "\xF4\x90\xC0\xC0\xF7\xBF\xBF\xBF");
|
||||
ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 4);
|
||||
ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 8);
|
||||
|
||||
/* Overlong; disallowed. */
|
||||
p = b;
|
||||
snprintf(b, sizeof(b), "\xC0\x80\xC1\x80");
|
||||
ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 2);
|
||||
ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 4);
|
||||
|
||||
/* Surrogate pairs; disallowed. */
|
||||
p = b;
|
||||
snprintf(b, sizeof(b), "\xED\xA0\x80\xED\xA3\xBF");
|
||||
ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 3);
|
||||
ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + 6);
|
||||
|
||||
/* Simply illegal. */
|
||||
p = b;
|
||||
snprintf(b, sizeof(b), "\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
|
||||
|
||||
for (i = 1; i <= 8; i++) {
|
||||
ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b)));
|
||||
ASSERT(p == b + i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Doesn't work on z/OS because that platform uses EBCDIC, not ASCII. */
|
||||
#ifndef __MVS__
|
||||
|
||||
#define F(input, err) \
|
||||
do { \
|
||||
char d[256] = {0}; \
|
||||
static const char s[] = "" input ""; \
|
||||
ASSERT(err == uv__idna_toascii(s, s + sizeof(s) - 1, d, d + sizeof(d))); \
|
||||
} while (0)
|
||||
|
||||
#define T(input, expected) \
|
||||
do { \
|
||||
long n; \
|
||||
char d1[256] = {0}; \
|
||||
char d2[256] = {0}; \
|
||||
static const char s[] = "" input ""; \
|
||||
n = uv__idna_toascii(s, s + sizeof(s) - 1, d1, d1 + sizeof(d1)); \
|
||||
ASSERT(n == sizeof(expected)); \
|
||||
ASSERT(0 == memcmp(d1, expected, n)); \
|
||||
/* Sanity check: encoding twice should not change the output. */ \
|
||||
n = uv__idna_toascii(d1, d1 + strlen(d1), d2, d2 + sizeof(d2)); \
|
||||
ASSERT(n == sizeof(expected)); \
|
||||
ASSERT(0 == memcmp(d2, expected, n)); \
|
||||
ASSERT(0 == memcmp(d1, d2, sizeof(d2))); \
|
||||
} while (0)
|
||||
|
||||
TEST_IMPL(idna_toascii) {
|
||||
/* Illegal inputs. */
|
||||
F("\xC0\x80\xC1\x80", UV_EINVAL); /* Overlong UTF-8 sequence. */
|
||||
F("\xC0\x80\xC1\x80.com", UV_EINVAL); /* Overlong UTF-8 sequence. */
|
||||
/* No conversion. */
|
||||
T("", "");
|
||||
T(".", ".");
|
||||
T(".com", ".com");
|
||||
T("example", "example");
|
||||
T("example-", "example-");
|
||||
T("straße.de", "xn--strae-oqa.de");
|
||||
/* Test cases adapted from punycode.js. Most are from RFC 3492. */
|
||||
T("foo.bar", "foo.bar");
|
||||
T("mañana.com", "xn--maana-pta.com");
|
||||
T("example.com.", "example.com.");
|
||||
T("bücher.com", "xn--bcher-kva.com");
|
||||
T("café.com", "xn--caf-dma.com");
|
||||
T("café.café.com", "xn--caf-dma.xn--caf-dma.com");
|
||||
T("☃-⌘.com", "xn----dqo34k.com");
|
||||
T("퐀☃-⌘.com", "xn----dqo34kn65z.com");
|
||||
T("💩.la", "xn--ls8h.la");
|
||||
T("mañana.com", "xn--maana-pta.com");
|
||||
T("mañana。com", "xn--maana-pta.com");
|
||||
T("mañana.com", "xn--maana-pta.com");
|
||||
T("mañana。com", "xn--maana-pta.com");
|
||||
T("ü", "xn--tda");
|
||||
T(".ü", ".xn--tda");
|
||||
T("ü.ü", "xn--tda.xn--tda");
|
||||
T("ü.ü.", "xn--tda.xn--tda.");
|
||||
T("üëäö♥", "xn--4can8av2009b");
|
||||
T("Willst du die Blüthe des frühen, die Früchte des späteren Jahres",
|
||||
"xn--Willst du die Blthe des frhen, "
|
||||
"die Frchte des spteren Jahres-x9e96lkal");
|
||||
T("ليهمابتكلموشعربي؟", "xn--egbpdaj6bu4bxfgehfvwxn");
|
||||
T("他们为什么不说中文", "xn--ihqwcrb4cv8a8dqg056pqjye");
|
||||
T("他們爲什麽不說中文", "xn--ihqwctvzc91f659drss3x8bo0yb");
|
||||
T("Pročprostěnemluvíčesky", "xn--Proprostnemluvesky-uyb24dma41a");
|
||||
T("למההםפשוטלאמדבריםעברית", "xn--4dbcagdahymbxekheh6e0a7fei0b");
|
||||
T("यहलोगहिन्दीक्योंनहींबोलसकतेहैं",
|
||||
"xn--i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd");
|
||||
T("なぜみんな日本語を話してくれないのか",
|
||||
"xn--n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa");
|
||||
T("세계의모든사람들이한국어를이해한다면얼마나좋을까",
|
||||
"xn--989aomsvi5e83db1d2a355cv1e0vak1d"
|
||||
"wrv93d5xbh15a0dt30a5jpsd879ccm6fea98c");
|
||||
T("почемужеонинеговорятпорусски", "xn--b1abfaaepdrnnbgefbadotcwatmq2g4l");
|
||||
T("PorquénopuedensimplementehablarenEspañol",
|
||||
"xn--PorqunopuedensimplementehablarenEspaol-fmd56a");
|
||||
T("TạisaohọkhôngthểchỉnóitiếngViệt",
|
||||
"xn--TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g");
|
||||
T("3年B組金八先生", "xn--3B-ww4c5e180e575a65lsy2b");
|
||||
T("安室奈美恵-with-SUPER-MONKEYS",
|
||||
"xn---with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n");
|
||||
T("Hello-Another-Way-それぞれの場所",
|
||||
"xn--Hello-Another-Way--fc4qua05auwb3674vfr0b");
|
||||
T("ひとつ屋根の下2", "xn--2-u9tlzr9756bt3uc0v");
|
||||
T("MajiでKoiする5秒前", "xn--MajiKoi5-783gue6qz075azm5e");
|
||||
T("パフィーdeルンバ", "xn--de-jg4avhby1noc0d");
|
||||
T("そのスピードで", "xn--d9juau41awczczp");
|
||||
T("-> $1.00 <-", "-> $1.00 <-");
|
||||
/* Test cases from https://unicode.org/reports/tr46/ */
|
||||
T("faß.de", "xn--fa-hia.de");
|
||||
T("βόλος.com", "xn--nxasmm1c.com");
|
||||
T("ශ්රී.com", "xn--10cl1a0b660p.com");
|
||||
T("نامهای.com", "xn--mgba3gch31f060k.com");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef T
|
||||
|
||||
#endif /* __MVS__ */
|
@ -150,6 +150,7 @@ int ipc_helper_heavy_traffic_deadlock_bug(void) {
|
||||
r = uv_pipe_open(&pipe, 0);
|
||||
ASSERT(r == 0);
|
||||
|
||||
notify_parent_process();
|
||||
do_writes_and_reads((uv_stream_t*) &pipe);
|
||||
uv_sleep(100);
|
||||
|
||||
|
1
deps/uv/test/test-ipc-send-recv.c
vendored
1
deps/uv/test/test-ipc-send-recv.c
vendored
@ -397,6 +397,7 @@ int run_ipc_send_recv_helper(uv_loop_t* loop, int inprocess) {
|
||||
send_recv_start();
|
||||
}
|
||||
|
||||
notify_parent_process();
|
||||
r = uv_run(loop, UV_RUN_DEFAULT);
|
||||
ASSERT(r == 0);
|
||||
|
||||
|
1
deps/uv/test/test-ipc.c
vendored
1
deps/uv/test/test-ipc.c
vendored
@ -724,6 +724,7 @@ int ipc_helper(int listen_after_write) {
|
||||
ASSERT(r == 0);
|
||||
}
|
||||
|
||||
notify_parent_process();
|
||||
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
ASSERT(r == 0);
|
||||
|
||||
|
12
deps/uv/test/test-list.h
vendored
12
deps/uv/test/test-list.h
vendored
@ -346,6 +346,7 @@ TEST_DECLARE (fs_partial_read)
|
||||
TEST_DECLARE (fs_partial_write)
|
||||
TEST_DECLARE (fs_file_pos_after_op_with_offset)
|
||||
TEST_DECLARE (fs_null_req)
|
||||
TEST_DECLARE (fs_read_dir)
|
||||
#ifdef _WIN32
|
||||
TEST_DECLARE (fs_exclusive_sharing_mode)
|
||||
TEST_DECLARE (fs_open_readonly_acl)
|
||||
@ -441,6 +442,9 @@ TEST_DECLARE (fork_threadpool_queue_work_simple)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TEST_DECLARE (idna_toascii)
|
||||
TEST_DECLARE (utf8_decode1)
|
||||
|
||||
TASK_LIST_START
|
||||
TEST_ENTRY_CUSTOM (platform_output, 0, 1, 5000)
|
||||
|
||||
@ -897,6 +901,7 @@ TASK_LIST_START
|
||||
TEST_ENTRY (fs_read_write_null_arguments)
|
||||
TEST_ENTRY (fs_file_pos_after_op_with_offset)
|
||||
TEST_ENTRY (fs_null_req)
|
||||
TEST_ENTRY (fs_read_dir)
|
||||
#ifdef _WIN32
|
||||
TEST_ENTRY (fs_exclusive_sharing_mode)
|
||||
TEST_ENTRY (fs_open_readonly_acl)
|
||||
@ -944,6 +949,13 @@ TASK_LIST_START
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TEST_ENTRY (utf8_decode1)
|
||||
|
||||
/* Doesn't work on z/OS because that platform uses EBCDIC, not ASCII. */
|
||||
#ifndef __MVS__
|
||||
TEST_ENTRY (idna_toascii)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* These are for testing the test runner. */
|
||||
TEST_ENTRY (fail_always)
|
||||
|
6
deps/uv/test/test-process-title-threadsafe.c
vendored
6
deps/uv/test/test-process-title-threadsafe.c
vendored
@ -25,11 +25,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define NUM_ITERATIONS 10
|
||||
#else
|
||||
# define NUM_ITERATIONS 50
|
||||
#endif
|
||||
#define NUM_ITERATIONS 50
|
||||
|
||||
static const char* titles[] = {
|
||||
"8L2NY0Kdj0XyNFZnmUZigIOfcWjyNr0SkMmUhKw99VLUsZFrvCQQC3XIRfNR8pjyMjXObllled",
|
||||
|
1
deps/uv/test/test-spawn.c
vendored
1
deps/uv/test/test-spawn.c
vendored
@ -1172,6 +1172,7 @@ TEST_IMPL(argument_escaping) {
|
||||
for (i = 0; i < count; ++i) {
|
||||
free(test_output[i]);
|
||||
}
|
||||
free(test_output);
|
||||
|
||||
result = make_program_args(verbatim, 1, &verbatim_output);
|
||||
ASSERT(result == 0);
|
||||
|
1
deps/uv/test/test-stdio-over-pipes.c
vendored
1
deps/uv/test/test-stdio-over-pipes.c
vendored
@ -232,6 +232,7 @@ int stdio_over_pipes_helper(void) {
|
||||
ASSERT(r == 0);
|
||||
}
|
||||
|
||||
notify_parent_process();
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
|
||||
ASSERT(after_write_called == 7);
|
||||
|
1
deps/uv/test/test.gyp
vendored
1
deps/uv/test/test.gyp
vendored
@ -46,6 +46,7 @@
|
||||
'test-homedir.c',
|
||||
'test-hrtime.c',
|
||||
'test-idle.c',
|
||||
'test-idna.c',
|
||||
'test-ip6-addr.c',
|
||||
'test-ipc-heavy-traffic-deadlock-bug.c',
|
||||
'test-ipc-send-recv.c',
|
||||
|
7
deps/uv/uv.gyp
vendored
7
deps/uv/uv.gyp
vendored
@ -70,6 +70,8 @@
|
||||
'include/uv/version.h',
|
||||
'src/fs-poll.c',
|
||||
'src/heap-inl.h',
|
||||
'src/idna.c',
|
||||
'src/idna.h',
|
||||
'src/inet.c',
|
||||
'src/queue.h',
|
||||
'src/threadpool.c',
|
||||
@ -326,7 +328,10 @@
|
||||
'sources': [ 'src/unix/netbsd.c' ],
|
||||
}],
|
||||
[ 'OS in "freebsd dragonflybsd openbsd netbsd".split()', {
|
||||
'sources': [ 'src/unix/posix-hrtime.c' ],
|
||||
'sources': [
|
||||
'src/unix/posix-hrtime.c',
|
||||
'src/unix/bsd-proctitle.c'
|
||||
],
|
||||
}],
|
||||
[ 'OS in "ios mac freebsd dragonflybsd openbsd netbsd".split()', {
|
||||
'sources': [
|
||||
|
Loading…
x
Reference in New Issue
Block a user