The fallback for systems that lack preadv() only filled the first
buffer.
This commit rectifies that to fill all (or at least as many as possible)
buffers.
Fixes: https://github.com/libuv/libuv/issues/2332
PR-URL: https://github.com/libuv/libuv/pull/2338
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Make uv_cwd() do what the documentation says it did when the destination
buffer is too small: report UV_ENOBUFS and set the `size` in/out param
to the size of the path including the trailing nul byte.
Fixes: https://github.com/libuv/libuv/issues/2333
PR-URL: https://github.com/libuv/libuv/pull/2335
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
F_BARRIERFSYNC isn't defined when building on that platform.
PR-URL: https://github.com/libuv/libuv/pull/2334
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
So far, for some (?) errors, `uv_try_write()` returns `EAGAIN`
regardless of the actual error, so `ECONNRESET` and `EPIPE` errors
can be swallowed here.
This commit changes `uv_try_write()` so that it prefers to return
the actual error it has seen.
PR-URL: https://github.com/libuv/libuv/pull/2321
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
uv_thread_create() inspects min(PTHREAD_STACK_MIN, RLIMIT_STACK) to
find out the minimum allowed stack size. After spelunking through
kernel and libc code, I came to the conclusion that allowing such
small stacks does not mix well with signals.
Musl's PTHREAD_STACK_MIN is 2 KB but signal handlers on many
architectures need at least 1 KB to store the signal context,
making it almost impossible to do anything on the thread without
signal delivery overflowing the stack.
Therefore, increase the lower bound to 8 KB. That corresponds to
PTHREAD_STACK_MIN + MINSIGSTKSZ on arm64, which has the largest
MINSIGSTKSZ of the architectures that musl supports.
PR-URL: https://github.com/libuv/libuv/pull/2310
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit add support for Haiku, an open-source operating system
inspired by BeOS.
PR-URL: https://github.com/libuv/libuv/pull/2301
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
The link symbol for close$NOCANCEL is slightly different for 32 bit
builds.
PR-URL: https://github.com/libuv/libuv/pull/2309
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Fall back to F_BARRIERFSYNC if F_FULLFSYNC is not supported by the file
system, only fall back to fsync() if both fcntls fail.
F_BARRIERFSYNC should be at least as safe as fsync() because it's fsync
coupled with a barrier.
PR-URL: https://github.com/libuv/libuv/pull/2317
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Use `"%" PRIu64` and uint64_t for sscanf-ing large values, not `"%lu"`
and unsigned long. The latter can overflow when libuv is a 32 bits
application running on a 64 bits machine.
Fixes: https://github.com/libuv/libuv/issues/2297
PR-URL: https://github.com/libuv/libuv/pull/2305
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
The test threadpool_multiple_event_loops has been timing
out consistently on FreeBSD in the CI. This commit attempts
to mitigate the problem by extending the test timeout.
PR-URL: https://github.com/libuv/libuv/pull/2304
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit includes uv/posix.h in one #elif instead of four.
PR-URL: https://github.com/libuv/libuv/pull/2302
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Same as the previous commit but this time for Linux.
Specifically, the glibc close() wrapper is a cancellation point;
the thread is unwound when close() is called when the thread is
in the "cancel" state.
That's according to spec and therefore arguably less severe than
MacOS's "EINTR without actually closing" behavior but we can avoid
the file descriptor leak altogether by sidestepping glibc and
making the system call directly.
Musl libc is unaffected, its close() wrapper doesn't check
the cancel state.
PR-URL: https://github.com/libuv/libuv/pull/2291
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
The close() system call tests for thread cancellation first. That has
the unfortunate side effect of aborting the sytem call with EINTR
without actually closing the file descriptor when the thread is in
the "cancel" state. Work around that by calling close$NOCANCEL().
This might well qualify as an academic bug because approximately no one
uses thread cancellation but let's aim for correctness anyway.
PR-URL: https://github.com/libuv/libuv/pull/2291
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Newer macOS systems (10.7+) use fsevents() for the fs_event backend,
but older macOS systems don't have full functionality for this in
the macOS fsevents() API. Fall back to kqueue for these systems.
PR-URL: https://github.com/libuv/libuv/pull/2290
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
When building libuv with clang scan-build, an "Assigned value is
garbage or undefined" warning is emitted unless the return value
of open() is verified to be >= 0. This commit fixes the warning.
PR-URL: https://github.com/libuv/libuv/pull/2140
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
app.info() was deprecated on Jan 4, 2017 (sphinx-doc/sphinx#3267),
and removed as of Sphinx 2.0.0. This commit removes the usage of
app.info().
PR-URL: https://github.com/libuv/libuv/pull/2265
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
If uv__calloc returns NULL, the function jumps to the error label and
attempts to access array elements of cpu_infos (which is NULL).
PR-URL: https://github.com/libuv/libuv/pull/2264
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
IP-alias format is the interface name followed by a colon and a string
(usually a number). Set the physical address to the one in the 'base'
interface.
PR-URL: https://github.com/libuv/libuv/pull/2248
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
UV_PROCESS_WINDOWS_HIDE_CONSOLE and UV_PROCESS_WINDOWS_HIDE_GUI were
whitelisted on Windows but not Unices. Now they are.
Bug introduced in commit 4c2dcca27 ("win: support more fine-grained
windows hiding") which I reviewed but where I failed to spot it. Mea
culpa.
Fixes: https://github.com/libuv/libuv/issues/2266
PR-URL: https://github.com/libuv/libuv/pull/2278
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Kyle Edwards <kyle.edwards@kitware.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This was reported as a bug in November 2018 but it appears to be working
now. Add a regression test to ensure it stays that way.
Fixes: https://github.com/libuv/libuv/issues/2076
PR-URL: https://github.com/libuv/libuv/pull/2279
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
It was reported that uv_get_free_memory() and uv_get_total_memory()
report the wrong values inside an lxc container.
Libuv calls sysinfo(2) but that isn't intercepted by lxc. /proc/meminfo
however is because /proc is a FUSE fs inside the container.
This commit makes libuv try /proc/meminfo first and fall back to
sysinfo(2) in case /proc isn't mounted.
Fixes: https://github.com/libuv/libuv/issues/2249
PR-URL: https://github.com/libuv/libuv/pull/2258
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Explicitly initialize uv_stat_t fields st_flags and st_gen when using
statx as uv__to_stat does when statx is not available. This makes
valgrind happier.
PR-URL: https://github.com/libuv/libuv/pull/2263
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
After inspection of the code, it seems like there is a race window
between the cmpxchgi() and uv__async_send() calls.
If the event loop thread is already busy looping over the async handles,
it can invoke the callback - which in turn can close the handle - before
the other thread reaches the uv__async_send() call. That's bad because
it accesses the handle that at that point might not be valid anymore.
Fix that by introducing an ad hoc spinlock that blocks the event loop
thread until the sending thread is done. It's not pretty or elegant
but it fixes the immediate bug and appears to have no measurable
impact on the async handle benchmarks.
Fixes: https://github.com/libuv/libuv/issues/2226
PR-URL: https://github.com/libuv/libuv/pull/2231
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
PTHREAD_STACK_MIN is an optional part of the POSIX spec and
NetBSD deliberately does not implement it as it's a variable
value in runtime.
PR-URL: https://github.com/libuv/libuv/pull/2252
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
close() is interruptible, meaning that a signal delivered when the
close() system call is executing, can result in a return value of
-1 with errno set to EINTR or EINPROGRESS. A survey of supported
Unices suggests the file descriptor is in fact closed and so there
is nothing to do except ignore the error.
Libuv already handled it correctly for internal file descriptors
throug uv__close() and uv__close_nocheckstdio() but uv_fs_close()
did not until now.
PR-URL: https://github.com/libuv/libuv/pull/2236
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
PR-URL: https://github.com/libuv/libuv/pull/2224
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Yury Selivanov <yury@magic.io>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>