forked from cory/tildefriends
libuv 1.47.0.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4615 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
4
deps/libuv/src/unix/darwin.c
vendored
4
deps/libuv/src/unix/darwin.c
vendored
@ -209,7 +209,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
|
||||
if (cpuspeed == 0)
|
||||
/* If sysctl hw.cputype == CPU_TYPE_ARM64, the correct value is unavailable
|
||||
* from Apple, but we can hard-code it here to a plausible value. */
|
||||
cpuspeed = 2400000000;
|
||||
cpuspeed = 2400000000U;
|
||||
|
||||
if (host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &numcpus,
|
||||
(processor_info_array_t*)&info,
|
||||
@ -235,7 +235,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
|
||||
cpu_info->cpu_times.irq = 0;
|
||||
|
||||
cpu_info->model = uv__strdup(model);
|
||||
cpu_info->speed = cpuspeed/1000000;
|
||||
cpu_info->speed = (int)(cpuspeed / 1000000);
|
||||
}
|
||||
vm_deallocate(mach_task_self(), (vm_address_t)info, msg_type);
|
||||
|
||||
|
240
deps/libuv/src/unix/fs.c
vendored
240
deps/libuv/src/unix/fs.c
vendored
@ -41,25 +41,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/uio.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
|
||||
#if defined(__DragonFly__) || \
|
||||
defined(__FreeBSD__) || \
|
||||
defined(__OpenBSD__) || \
|
||||
defined(__NetBSD__)
|
||||
# define HAVE_PREADV 1
|
||||
#else
|
||||
# define HAVE_PREADV 0
|
||||
#endif
|
||||
|
||||
/* preadv() and pwritev() were added in Android N (level 24) */
|
||||
#if defined(__linux__) && !(defined(__ANDROID__) && __ANDROID_API__ < 24)
|
||||
# define TRY_PREADV 1
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
# include <sys/sendfile.h>
|
||||
#endif
|
||||
@ -97,6 +82,15 @@
|
||||
# include <sys/statfs.h>
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__) || \
|
||||
(defined(__HAIKU__) && B_HAIKU_VERSION < B_HAIKU_VERSION_1_PRE_BETA_5) || \
|
||||
(defined(__sun) && !defined(__illumos__))
|
||||
#define preadv(fd, bufs, nbufs, off) \
|
||||
pread(fd, (bufs)->iov_base, (bufs)->iov_len, off)
|
||||
#define pwritev(fd, bufs, nbufs, off) \
|
||||
pwrite(fd, (bufs)->iov_base, (bufs)->iov_len, off)
|
||||
#endif
|
||||
|
||||
#if defined(_AIX) && _XOPEN_SOURCE <= 600
|
||||
extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
|
||||
#endif
|
||||
@ -410,123 +404,57 @@ static ssize_t uv__fs_open(uv_fs_t* req) {
|
||||
}
|
||||
|
||||
|
||||
#if !HAVE_PREADV
|
||||
static ssize_t uv__fs_preadv(uv_file fd,
|
||||
uv_buf_t* bufs,
|
||||
unsigned int nbufs,
|
||||
off_t off) {
|
||||
uv_buf_t* buf;
|
||||
uv_buf_t* end;
|
||||
ssize_t result;
|
||||
ssize_t rc;
|
||||
size_t pos;
|
||||
|
||||
assert(nbufs > 0);
|
||||
|
||||
result = 0;
|
||||
pos = 0;
|
||||
buf = bufs + 0;
|
||||
end = bufs + nbufs;
|
||||
|
||||
for (;;) {
|
||||
do
|
||||
rc = pread(fd, buf->base + pos, buf->len - pos, off + result);
|
||||
while (rc == -1 && errno == EINTR);
|
||||
|
||||
if (rc == 0)
|
||||
break;
|
||||
|
||||
if (rc == -1 && result == 0)
|
||||
return UV__ERR(errno);
|
||||
|
||||
if (rc == -1)
|
||||
break; /* We read some data so return that, ignore the error. */
|
||||
|
||||
pos += rc;
|
||||
result += rc;
|
||||
|
||||
if (pos < buf->len)
|
||||
continue;
|
||||
|
||||
pos = 0;
|
||||
buf += 1;
|
||||
|
||||
if (buf == end)
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static ssize_t uv__fs_read(uv_fs_t* req) {
|
||||
#if TRY_PREADV
|
||||
static _Atomic int no_preadv;
|
||||
#endif
|
||||
const struct iovec* bufs;
|
||||
unsigned int iovmax;
|
||||
ssize_t result;
|
||||
size_t nbufs;
|
||||
ssize_t r;
|
||||
off_t off;
|
||||
int fd;
|
||||
|
||||
fd = req->file;
|
||||
off = req->off;
|
||||
bufs = (const struct iovec*) req->bufs;
|
||||
nbufs = req->nbufs;
|
||||
|
||||
iovmax = uv__getiovmax();
|
||||
if (req->nbufs > iovmax)
|
||||
req->nbufs = iovmax;
|
||||
if (nbufs > iovmax)
|
||||
nbufs = iovmax;
|
||||
|
||||
if (req->off < 0) {
|
||||
if (req->nbufs == 1)
|
||||
result = read(req->file, req->bufs[0].base, req->bufs[0].len);
|
||||
else
|
||||
result = readv(req->file, (struct iovec*) req->bufs, req->nbufs);
|
||||
r = 0;
|
||||
if (off < 0) {
|
||||
if (nbufs == 1)
|
||||
r = read(fd, bufs->iov_base, bufs->iov_len);
|
||||
else if (nbufs > 1)
|
||||
r = readv(fd, bufs, nbufs);
|
||||
} else {
|
||||
if (req->nbufs == 1) {
|
||||
result = pread(req->file, req->bufs[0].base, req->bufs[0].len, req->off);
|
||||
goto done;
|
||||
}
|
||||
|
||||
#if HAVE_PREADV
|
||||
result = preadv(req->file, (struct iovec*) req->bufs, req->nbufs, req->off);
|
||||
#else
|
||||
# if TRY_PREADV
|
||||
if (atomic_load_explicit(&no_preadv, memory_order_relaxed)) retry:
|
||||
# endif
|
||||
{
|
||||
result = uv__fs_preadv(req->file, req->bufs, req->nbufs, req->off);
|
||||
}
|
||||
# if TRY_PREADV
|
||||
else {
|
||||
result = preadv(req->file,
|
||||
(struct iovec*) req->bufs,
|
||||
req->nbufs,
|
||||
req->off);
|
||||
if (result == -1 && errno == ENOSYS) {
|
||||
atomic_store_explicit(&no_preadv, 1, memory_order_relaxed);
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
if (nbufs == 1)
|
||||
r = pread(fd, bufs->iov_base, bufs->iov_len, off);
|
||||
else if (nbufs > 1)
|
||||
r = preadv(fd, bufs, nbufs, off);
|
||||
}
|
||||
|
||||
done:
|
||||
/* Early cleanup of bufs allocation, since we're done with it. */
|
||||
if (req->bufs != req->bufsml)
|
||||
uv__free(req->bufs);
|
||||
|
||||
req->bufs = NULL;
|
||||
req->nbufs = 0;
|
||||
|
||||
#ifdef __PASE__
|
||||
/* PASE returns EOPNOTSUPP when reading a directory, convert to EISDIR */
|
||||
if (result == -1 && errno == EOPNOTSUPP) {
|
||||
if (r == -1 && errno == EOPNOTSUPP) {
|
||||
struct stat buf;
|
||||
ssize_t rc;
|
||||
rc = uv__fstat(req->file, &buf);
|
||||
rc = uv__fstat(fd, &buf);
|
||||
if (rc == 0 && S_ISDIR(buf.st_mode)) {
|
||||
errno = EISDIR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
/* We don't own the buffer list in the synchronous case. */
|
||||
if (req->cb != NULL)
|
||||
if (req->bufs != req->bufsml)
|
||||
uv__free(req->bufs);
|
||||
|
||||
req->bufs = NULL;
|
||||
req->nbufs = 0;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@ -1161,65 +1089,34 @@ static ssize_t uv__fs_lutime(uv_fs_t* req) {
|
||||
|
||||
|
||||
static ssize_t uv__fs_write(uv_fs_t* req) {
|
||||
#if TRY_PREADV
|
||||
static _Atomic int no_pwritev;
|
||||
#endif
|
||||
const struct iovec* bufs;
|
||||
size_t nbufs;
|
||||
ssize_t r;
|
||||
off_t off;
|
||||
int fd;
|
||||
|
||||
/* Serialize writes on OS X, concurrent write() and pwrite() calls result in
|
||||
* data loss. We can't use a per-file descriptor lock, the descriptor may be
|
||||
* a dup().
|
||||
*/
|
||||
#if defined(__APPLE__)
|
||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
fd = req->file;
|
||||
off = req->off;
|
||||
bufs = (const struct iovec*) req->bufs;
|
||||
nbufs = req->nbufs;
|
||||
|
||||
if (pthread_mutex_lock(&lock))
|
||||
abort();
|
||||
#endif
|
||||
|
||||
if (req->off < 0) {
|
||||
if (req->nbufs == 1)
|
||||
r = write(req->file, req->bufs[0].base, req->bufs[0].len);
|
||||
else
|
||||
r = writev(req->file, (struct iovec*) req->bufs, req->nbufs);
|
||||
r = 0;
|
||||
if (off < 0) {
|
||||
if (nbufs == 1)
|
||||
r = write(fd, bufs->iov_base, bufs->iov_len);
|
||||
else if (nbufs > 1)
|
||||
r = writev(fd, bufs, nbufs);
|
||||
} else {
|
||||
if (req->nbufs == 1) {
|
||||
r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off);
|
||||
goto done;
|
||||
}
|
||||
#if HAVE_PREADV
|
||||
r = pwritev(req->file, (struct iovec*) req->bufs, req->nbufs, req->off);
|
||||
#else
|
||||
# if TRY_PREADV
|
||||
if (atomic_load_explicit(&no_pwritev, memory_order_relaxed)) retry:
|
||||
# endif
|
||||
{
|
||||
r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off);
|
||||
}
|
||||
# if TRY_PREADV
|
||||
else {
|
||||
r = pwritev(req->file,
|
||||
(struct iovec*) req->bufs,
|
||||
req->nbufs,
|
||||
req->off);
|
||||
if (r == -1 && errno == ENOSYS) {
|
||||
atomic_store_explicit(&no_pwritev, 1, memory_order_relaxed);
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
if (nbufs == 1)
|
||||
r = pwrite(fd, bufs->iov_base, bufs->iov_len, off);
|
||||
else if (nbufs > 1)
|
||||
r = pwritev(fd, bufs, nbufs, off);
|
||||
}
|
||||
|
||||
done:
|
||||
#if defined(__APPLE__)
|
||||
if (pthread_mutex_unlock(&lock))
|
||||
abort();
|
||||
#endif
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
static ssize_t uv__fs_copyfile(uv_fs_t* req) {
|
||||
uv_fs_t fs_req;
|
||||
uv_file srcfd;
|
||||
@ -1979,9 +1876,14 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req,
|
||||
if (bufs == NULL || nbufs == 0)
|
||||
return UV_EINVAL;
|
||||
|
||||
req->off = off;
|
||||
req->file = file;
|
||||
|
||||
req->bufs = (uv_buf_t*) bufs; /* Safe, doesn't mutate |bufs| */
|
||||
req->nbufs = nbufs;
|
||||
|
||||
if (cb == NULL)
|
||||
goto post;
|
||||
|
||||
req->bufs = req->bufsml;
|
||||
if (nbufs > ARRAY_SIZE(req->bufsml))
|
||||
req->bufs = uv__malloc(nbufs * sizeof(*bufs));
|
||||
@ -1991,12 +1893,10 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req,
|
||||
|
||||
memcpy(req->bufs, bufs, nbufs * sizeof(*bufs));
|
||||
|
||||
req->off = off;
|
||||
|
||||
if (cb != NULL)
|
||||
if (uv__iou_fs_read_or_write(loop, req, /* is_read */ 1))
|
||||
return 0;
|
||||
if (uv__iou_fs_read_or_write(loop, req, /* is_read */ 1))
|
||||
return 0;
|
||||
|
||||
post:
|
||||
POST;
|
||||
}
|
||||
|
||||
|
18
deps/libuv/src/unix/kqueue.c
vendored
18
deps/libuv/src/unix/kqueue.c
vendored
@ -30,6 +30,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/event.h>
|
||||
#include <sys/time.h>
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/user.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
@ -262,6 +265,9 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
||||
|
||||
if (nfds == -1)
|
||||
assert(errno == EINTR);
|
||||
else if (nfds == 0)
|
||||
/* Unlimited timeout should only return with events or signal. */
|
||||
assert(timeout != -1);
|
||||
|
||||
if (pset != NULL)
|
||||
pthread_sigmask(SIG_UNBLOCK, pset, NULL);
|
||||
@ -286,8 +292,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
||||
timeout = user_timeout;
|
||||
reset_timeout = 0;
|
||||
} else if (nfds == 0) {
|
||||
/* Reached the user timeout value. */
|
||||
assert(timeout != -1);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -479,6 +483,16 @@ static void uv__fs_event(uv_loop_t* loop, uv__io_t* w, unsigned int fflags) {
|
||||
*/
|
||||
if (fcntl(handle->event_watcher.fd, F_GETPATH, pathbuf) == 0)
|
||||
path = uv__basename_r(pathbuf);
|
||||
#elif defined(F_KINFO)
|
||||
/* We try to get the file info reference from the file descriptor.
|
||||
* the struct's kf_structsize must be initialised beforehand
|
||||
* whether with the KINFO_FILE_SIZE constant or this way.
|
||||
*/
|
||||
struct kinfo_file kf;
|
||||
kf.kf_structsize = sizeof(kf);
|
||||
|
||||
if (fcntl(handle->event_watcher.fd, F_KINFO, &kf) == 0)
|
||||
path = uv__basename_r(kf.kf_path);
|
||||
#endif
|
||||
handle->cb(handle, path, events, 0);
|
||||
|
||||
|
121
deps/libuv/src/unix/linux.c
vendored
121
deps/libuv/src/unix/linux.c
vendored
@ -79,6 +79,8 @@
|
||||
# define __NR_copy_file_range 379
|
||||
# elif defined(__arc__)
|
||||
# define __NR_copy_file_range 285
|
||||
# elif defined(__riscv)
|
||||
# define __NR_copy_file_range 285
|
||||
# endif
|
||||
#endif /* __NR_copy_file_range */
|
||||
|
||||
@ -95,6 +97,8 @@
|
||||
# define __NR_statx 383
|
||||
# elif defined(__s390__)
|
||||
# define __NR_statx 379
|
||||
# elif defined(__riscv)
|
||||
# define __NR_statx 291
|
||||
# endif
|
||||
#endif /* __NR_statx */
|
||||
|
||||
@ -111,6 +115,8 @@
|
||||
# define __NR_getrandom 359
|
||||
# elif defined(__s390__)
|
||||
# define __NR_getrandom 349
|
||||
# elif defined(__riscv)
|
||||
# define __NR_getrandom 278
|
||||
# endif
|
||||
#endif /* __NR_getrandom */
|
||||
|
||||
@ -317,17 +323,64 @@ unsigned uv__kernel_version(void) {
|
||||
unsigned major;
|
||||
unsigned minor;
|
||||
unsigned patch;
|
||||
char v_sig[256];
|
||||
char* needle;
|
||||
|
||||
version = atomic_load_explicit(&cached_version, memory_order_relaxed);
|
||||
if (version != 0)
|
||||
return version;
|
||||
|
||||
/* Check /proc/version_signature first as it's the way to get the mainline
|
||||
* kernel version in Ubuntu. The format is:
|
||||
* Ubuntu ubuntu_kernel_version mainline_kernel_version
|
||||
* For example:
|
||||
* Ubuntu 5.15.0-79.86-generic 5.15.111
|
||||
*/
|
||||
if (0 == uv__slurp("/proc/version_signature", v_sig, sizeof(v_sig)))
|
||||
if (3 == sscanf(v_sig, "Ubuntu %*s %u.%u.%u", &major, &minor, &patch))
|
||||
goto calculate_version;
|
||||
|
||||
if (-1 == uname(&u))
|
||||
return 0;
|
||||
|
||||
/* In Debian we need to check `version` instead of `release` to extract the
|
||||
* mainline kernel version. This is an example of how it looks like:
|
||||
* #1 SMP Debian 5.10.46-4 (2021-08-03)
|
||||
*/
|
||||
needle = strstr(u.version, "Debian ");
|
||||
if (needle != NULL)
|
||||
if (3 == sscanf(needle, "Debian %u.%u.%u", &major, &minor, &patch))
|
||||
goto calculate_version;
|
||||
|
||||
if (3 != sscanf(u.release, "%u.%u.%u", &major, &minor, &patch))
|
||||
return 0;
|
||||
|
||||
/* Handle it when the process runs under the UNAME26 personality:
|
||||
*
|
||||
* - kernels >= 3.x identify as 2.6.40+x
|
||||
* - kernels >= 4.x identify as 2.6.60+x
|
||||
*
|
||||
* UNAME26 is a poorly conceived hack that doesn't let us distinguish
|
||||
* between 4.x kernels and 5.x/6.x kernels so we conservatively assume
|
||||
* that 2.6.60+x means 4.x.
|
||||
*
|
||||
* Fun fact of the day: it's technically possible to observe the actual
|
||||
* kernel version for a brief moment because uname() first copies out the
|
||||
* real release string before overwriting it with the backcompat string.
|
||||
*/
|
||||
if (major == 2 && minor == 6) {
|
||||
if (patch >= 60) {
|
||||
major = 4;
|
||||
minor = patch - 60;
|
||||
patch = 0;
|
||||
} else if (patch >= 40) {
|
||||
major = 3;
|
||||
minor = patch - 40;
|
||||
patch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
calculate_version:
|
||||
version = major * 65536 + minor * 256 + patch;
|
||||
atomic_store_explicit(&cached_version, version, memory_order_relaxed);
|
||||
|
||||
@ -422,6 +475,9 @@ int uv__io_uring_register(int fd, unsigned opcode, void* arg, unsigned nargs) {
|
||||
static int uv__use_io_uring(void) {
|
||||
#if defined(__ANDROID_API__)
|
||||
return 0; /* Possibly available but blocked by seccomp. */
|
||||
#elif defined(__arm__) && __SIZEOF_POINTER__ == 4
|
||||
/* See https://github.com/libuv/libuv/issues/4158. */
|
||||
return 0; /* All 32 bits kernels appear buggy. */
|
||||
#else
|
||||
/* Ternary: unknown=0, yes=1, no=-1 */
|
||||
static _Atomic int use_io_uring;
|
||||
@ -431,8 +487,14 @@ static int uv__use_io_uring(void) {
|
||||
use = atomic_load_explicit(&use_io_uring, memory_order_relaxed);
|
||||
|
||||
if (use == 0) {
|
||||
/* Older kernels have a bug where the sqpoll thread uses 100% CPU. */
|
||||
use = uv__kernel_version() >= /* 5.10.186 */ 0x050ABA ? 1 : -1;
|
||||
|
||||
/* But users can still enable it if they so desire. */
|
||||
val = getenv("UV_USE_IO_URING");
|
||||
use = val == NULL || atoi(val) ? 1 : -1;
|
||||
if (val != NULL)
|
||||
use = atoi(val) ? 1 : -1;
|
||||
|
||||
atomic_store_explicit(&use_io_uring, use, memory_order_relaxed);
|
||||
}
|
||||
|
||||
@ -756,7 +818,9 @@ static void uv__iou_submit(struct uv__iou* iou) {
|
||||
int uv__iou_fs_close(uv_loop_t* loop, uv_fs_t* req) {
|
||||
struct uv__io_uring_sqe* sqe;
|
||||
struct uv__iou* iou;
|
||||
int kv;
|
||||
|
||||
kv = uv__kernel_version();
|
||||
/* Work around a poorly understood bug in older kernels where closing a file
|
||||
* descriptor pointing to /foo/bar results in ETXTBSY errors when trying to
|
||||
* execve("/foo/bar") later on. The bug seems to have been fixed somewhere
|
||||
@ -764,10 +828,17 @@ int uv__iou_fs_close(uv_loop_t* loop, uv_fs_t* req) {
|
||||
* but good candidates are the several data race fixes. Interestingly, it
|
||||
* seems to manifest only when running under Docker so the possibility of
|
||||
* a Docker bug can't be completely ruled out either. Yay, computers.
|
||||
* Also, disable on non-longterm versions between 5.16.0 (non-longterm) and
|
||||
* 6.1.0 (longterm). Starting with longterm 6.1.x, the issue seems to be
|
||||
* solved.
|
||||
*/
|
||||
if (uv__kernel_version() < /* 5.15.90 */ 0x050F5A)
|
||||
if (kv < /* 5.15.90 */ 0x050F5A)
|
||||
return 0;
|
||||
|
||||
if (kv >= /* 5.16.0 */ 0x050A00 && kv < /* 6.1.0 */ 0x060100)
|
||||
return 0;
|
||||
|
||||
|
||||
iou = &uv__get_internal_fields(loop)->iou;
|
||||
|
||||
sqe = uv__iou_get_sqe(iou, loop, req);
|
||||
@ -1364,41 +1435,20 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
||||
*/
|
||||
SAVE_ERRNO(uv__update_time(loop));
|
||||
|
||||
if (nfds == 0) {
|
||||
if (nfds == -1)
|
||||
assert(errno == EINTR);
|
||||
else if (nfds == 0)
|
||||
/* Unlimited timeout should only return with events or signal. */
|
||||
assert(timeout != -1);
|
||||
|
||||
if (nfds == 0 || nfds == -1) {
|
||||
if (reset_timeout != 0) {
|
||||
timeout = user_timeout;
|
||||
reset_timeout = 0;
|
||||
} else if (nfds == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (timeout == -1)
|
||||
continue;
|
||||
|
||||
if (timeout == 0)
|
||||
break;
|
||||
|
||||
/* We may have been inside the system call for longer than |timeout|
|
||||
* milliseconds so we need to update the timestamp to avoid drift.
|
||||
*/
|
||||
goto update_timeout;
|
||||
}
|
||||
|
||||
if (nfds == -1) {
|
||||
if (errno != EINTR)
|
||||
abort();
|
||||
|
||||
if (reset_timeout != 0) {
|
||||
timeout = user_timeout;
|
||||
reset_timeout = 0;
|
||||
}
|
||||
|
||||
if (timeout == -1)
|
||||
continue;
|
||||
|
||||
if (timeout == 0)
|
||||
break;
|
||||
|
||||
/* Interrupted by a signal. Update timeout and poll again. */
|
||||
goto update_timeout;
|
||||
}
|
||||
@ -1509,13 +1559,13 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
||||
break;
|
||||
}
|
||||
|
||||
update_timeout:
|
||||
if (timeout == 0)
|
||||
break;
|
||||
|
||||
if (timeout == -1)
|
||||
continue;
|
||||
|
||||
update_timeout:
|
||||
assert(timeout > 0);
|
||||
|
||||
real_timeout -= (loop->time - base);
|
||||
@ -1718,7 +1768,8 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) {
|
||||
return UV__ERR(errno);
|
||||
}
|
||||
|
||||
fgets(buf, sizeof(buf), fp); /* Skip first line. */
|
||||
if (NULL == fgets(buf, sizeof(buf), fp))
|
||||
abort();
|
||||
|
||||
for (;;) {
|
||||
memset(&t, 0, sizeof(t));
|
||||
@ -1729,7 +1780,8 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) {
|
||||
if (n != 7)
|
||||
break;
|
||||
|
||||
fgets(buf, sizeof(buf), fp); /* Skip rest of line. */
|
||||
if (NULL == fgets(buf, sizeof(buf), fp))
|
||||
abort();
|
||||
|
||||
if (cpu >= ARRAY_SIZE(*cpus))
|
||||
continue;
|
||||
@ -1809,7 +1861,8 @@ nocpuinfo:
|
||||
if (fp == NULL)
|
||||
continue;
|
||||
|
||||
fscanf(fp, "%llu", &(*cpus)[cpu].freq);
|
||||
if (1 != fscanf(fp, "%llu", &(*cpus)[cpu].freq))
|
||||
abort();
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
}
|
||||
|
14
deps/libuv/src/unix/os390.c
vendored
14
deps/libuv/src/unix/os390.c
vendored
@ -19,6 +19,7 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "uv.h"
|
||||
#include "internal.h"
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
@ -30,6 +31,7 @@
|
||||
#include <sys/msg.h>
|
||||
#include <sys/resource.h>
|
||||
#include "zos-base.h"
|
||||
#include "zos-sys-info.h"
|
||||
#if defined(__clang__)
|
||||
#include "csrsic.h"
|
||||
#else
|
||||
@ -66,9 +68,6 @@
|
||||
/* Total number of frames currently on all available frame queues. */
|
||||
#define RCEAFC_OFFSET 0x088
|
||||
|
||||
/* CPC model length from the CSRSI Service. */
|
||||
#define CPCMODEL_LENGTH 16
|
||||
|
||||
/* Pointer to the home (current) ASCB. */
|
||||
#define PSAAOLD 0x224
|
||||
|
||||
@ -258,9 +257,12 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
|
||||
idx = 0;
|
||||
while (idx < *count) {
|
||||
cpu_info->speed = *(int*)(info.siv1v2si22v1.si22v1cpucapability);
|
||||
cpu_info->model = uv__malloc(CPCMODEL_LENGTH + 1);
|
||||
memset(cpu_info->model, '\0', CPCMODEL_LENGTH + 1);
|
||||
memcpy(cpu_info->model, info.siv1v2si11v1.si11v1cpcmodel, CPCMODEL_LENGTH);
|
||||
cpu_info->model = uv__malloc(ZOSCPU_MODEL_LENGTH + 1);
|
||||
if (cpu_info->model == NULL) {
|
||||
uv_free_cpu_info(*cpu_infos, idx);
|
||||
return UV_ENOMEM;
|
||||
}
|
||||
__get_cpu_model(cpu_info->model, ZOSCPU_MODEL_LENGTH + 1);
|
||||
cpu_info->cpu_times.user = cpu_usage_avg;
|
||||
/* TODO: implement the following */
|
||||
cpu_info->cpu_times.sys = 0;
|
||||
|
15
deps/libuv/src/unix/signal.c
vendored
15
deps/libuv/src/unix/signal.c
vendored
@ -279,6 +279,8 @@ static int uv__signal_loop_once_init(uv_loop_t* loop) {
|
||||
|
||||
|
||||
int uv__signal_loop_fork(uv_loop_t* loop) {
|
||||
struct uv__queue* q;
|
||||
|
||||
if (loop->signal_pipefd[0] == -1)
|
||||
return 0;
|
||||
uv__io_stop(loop, &loop->signal_io_watcher, POLLIN);
|
||||
@ -286,6 +288,19 @@ int uv__signal_loop_fork(uv_loop_t* loop) {
|
||||
uv__close(loop->signal_pipefd[1]);
|
||||
loop->signal_pipefd[0] = -1;
|
||||
loop->signal_pipefd[1] = -1;
|
||||
|
||||
uv__queue_foreach(q, &loop->handle_queue) {
|
||||
uv_handle_t* handle = uv__queue_data(q, uv_handle_t, handle_queue);
|
||||
uv_signal_t* sh;
|
||||
|
||||
if (handle->type != UV_SIGNAL)
|
||||
continue;
|
||||
|
||||
sh = (uv_signal_t*) handle;
|
||||
sh->caught_signals = 0;
|
||||
sh->dispatched_signals = 0;
|
||||
}
|
||||
|
||||
return uv__signal_loop_once_init(loop);
|
||||
}
|
||||
|
||||
|
101
deps/libuv/src/unix/tcp.c
vendored
101
deps/libuv/src/unix/tcp.c
vendored
@ -27,6 +27,17 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#if defined(__PASE__)
|
||||
#include <as400_protos.h>
|
||||
#define ifaddrs ifaddrs_pase
|
||||
#define getifaddrs Qp2getifaddrs
|
||||
#define freeifaddrs Qp2freeifaddrs
|
||||
#else
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
static int maybe_bind_socket(int fd) {
|
||||
union uv__sockaddr s;
|
||||
@ -198,11 +209,50 @@ int uv__tcp_bind(uv_tcp_t* tcp,
|
||||
}
|
||||
|
||||
|
||||
static int uv__is_ipv6_link_local(const struct sockaddr* addr) {
|
||||
const struct sockaddr_in6* a6;
|
||||
uint8_t b[2];
|
||||
|
||||
if (addr->sa_family != AF_INET6)
|
||||
return 0;
|
||||
|
||||
a6 = (const struct sockaddr_in6*) addr;
|
||||
memcpy(b, &a6->sin6_addr, sizeof(b));
|
||||
|
||||
return b[0] == 0xFE && b[1] == 0x80;
|
||||
}
|
||||
|
||||
|
||||
static int uv__ipv6_link_local_scope_id(void) {
|
||||
struct sockaddr_in6* a6;
|
||||
struct ifaddrs* ifa;
|
||||
struct ifaddrs* p;
|
||||
int rv;
|
||||
|
||||
if (getifaddrs(&ifa))
|
||||
return 0;
|
||||
|
||||
for (p = ifa; p != NULL; p = p->ifa_next)
|
||||
if (uv__is_ipv6_link_local(p->ifa_addr))
|
||||
break;
|
||||
|
||||
rv = 0;
|
||||
if (p != NULL) {
|
||||
a6 = (struct sockaddr_in6*) p->ifa_addr;
|
||||
rv = a6->sin6_scope_id;
|
||||
}
|
||||
|
||||
freeifaddrs(ifa);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int uv__tcp_connect(uv_connect_t* req,
|
||||
uv_tcp_t* handle,
|
||||
const struct sockaddr* addr,
|
||||
unsigned int addrlen,
|
||||
uv_connect_cb cb) {
|
||||
struct sockaddr_in6 tmp6;
|
||||
int err;
|
||||
int r;
|
||||
|
||||
@ -220,6 +270,14 @@ int uv__tcp_connect(uv_connect_t* req,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (uv__is_ipv6_link_local(addr)) {
|
||||
memcpy(&tmp6, addr, sizeof(tmp6));
|
||||
if (tmp6.sin6_scope_id == 0) {
|
||||
tmp6.sin6_scope_id = uv__ipv6_link_local_scope_id();
|
||||
addr = (void*) &tmp6;
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
errno = 0;
|
||||
r = connect(uv__stream_fd(handle), addr, addrlen);
|
||||
@ -374,28 +432,39 @@ int uv__tcp_nodelay(int fd, int on) {
|
||||
|
||||
|
||||
int uv__tcp_keepalive(int fd, int on, unsigned int delay) {
|
||||
int intvl;
|
||||
int cnt;
|
||||
|
||||
(void) &intvl;
|
||||
(void) &cnt;
|
||||
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)))
|
||||
return UV__ERR(errno);
|
||||
|
||||
if (!on)
|
||||
return 0;
|
||||
|
||||
#ifdef TCP_KEEPIDLE
|
||||
if (on) {
|
||||
int intvl = 1; /* 1 second; same as default on Win32 */
|
||||
int cnt = 10; /* 10 retries; same as hardcoded on Win32 */
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay)))
|
||||
return UV__ERR(errno);
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl)))
|
||||
return UV__ERR(errno);
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt)))
|
||||
return UV__ERR(errno);
|
||||
}
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay)))
|
||||
return UV__ERR(errno);
|
||||
/* Solaris/SmartOS, if you don't support keep-alive,
|
||||
* then don't advertise it in your system headers...
|
||||
*/
|
||||
/* FIXME(bnoordhuis) That's possibly because sizeof(delay) should be 1. */
|
||||
#elif defined(TCP_KEEPALIVE) && !defined(__sun)
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &delay, sizeof(delay)))
|
||||
return UV__ERR(errno);
|
||||
#endif
|
||||
|
||||
/* Solaris/SmartOS, if you don't support keep-alive,
|
||||
* then don't advertise it in your system headers...
|
||||
*/
|
||||
/* FIXME(bnoordhuis) That's possibly because sizeof(delay) should be 1. */
|
||||
#if defined(TCP_KEEPALIVE) && !defined(__sun)
|
||||
if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &delay, sizeof(delay)))
|
||||
#ifdef TCP_KEEPINTVL
|
||||
intvl = 1; /* 1 second; same as default on Win32 */
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl)))
|
||||
return UV__ERR(errno);
|
||||
#endif
|
||||
|
||||
#ifdef TCP_KEEPCNT
|
||||
cnt = 10; /* 10 retries; same as hardcoded on Win32 */
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt)))
|
||||
return UV__ERR(errno);
|
||||
#endif
|
||||
|
||||
|
22
deps/libuv/src/unix/thread.c
vendored
22
deps/libuv/src/unix/thread.c
vendored
@ -789,11 +789,33 @@ void uv_cond_broadcast(uv_cond_t* cond) {
|
||||
abort();
|
||||
}
|
||||
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
|
||||
void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
|
||||
int r;
|
||||
|
||||
errno = 0;
|
||||
r = pthread_cond_wait(cond, mutex);
|
||||
|
||||
/* Workaround for a bug in OS X at least up to 13.6
|
||||
* See https://github.com/libuv/libuv/issues/4165
|
||||
*/
|
||||
if (r == EINVAL)
|
||||
if (errno == EBUSY)
|
||||
return;
|
||||
|
||||
if (r)
|
||||
abort();
|
||||
}
|
||||
|
||||
#else /* !(defined(__APPLE__) && defined(__MACH__)) */
|
||||
|
||||
void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
|
||||
if (pthread_cond_wait(cond, mutex))
|
||||
abort();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
|
||||
int r;
|
||||
|
Reference in New Issue
Block a user