Ensure that uv_barrier_wait returns positive only after all threads have
exited the barrier. If this value is returned too early and the barrier
is destroyed prematurely, then this test may see a crash.
PR-URL: https://github.com/libuv/libuv/pull/2019
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Libuv's own thread barrier implementation signaled completion to the
first waiter that saw the threshold being reached, contrary to what
some native pthreads barrier implementations do, which is to signal
it to the _last_ waiter.
Libuv's behavior is not strictly non-conforming but it's inconvenient
because it means this snippet (that appears in the libuv documentation)
has a race condition in it:
if (uv_barrier_wait(&barrier) > 0)
uv_barrier_destroy(&barrier); // can still have waiters
This issue was discovered and fixed by Ali Ijaz Sheikh, a.k.a @ofrobots,
but some refactoring introduced conflicts in his pull request and I
didn't have the heart to ask him to redo it from scratch. :-)
PR-URL: https://github.com/libuv/libuv/pull/2019
Refs: https://github.com/libuv/libuv/pull/2003
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
* dissolve include/uv/pthread-barrier.h
* use libuv mutexes and condition variables, not pthreads's
* drive-by cleanup and simplification enabled by the first two items
PR-URL: https://github.com/libuv/libuv/pull/2019
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Under some condition, uv_tty_close() would not stop console reads.
This fixes that issue by first stopping read, then closing the
handle.
Fixes: https://github.com/nodejs/node/issues/22999
PR-URL: https://github.com/libuv/libuv/pull/2005
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
New Windows version requires `EventType` to be set to something
meaningful, otherwise WriteConsoleInputW() will fail with
`ERROR_INVALID_PARAMETER`. This sets it to `FOCUS_EVENT` which
is ignored by `uv_process_tty_read_raw_req()`.
Fixes: https://github.com/nodejs/node/issues/21773
PR-URL: https://github.com/libuv/libuv/pull/1989
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Previously, we required the user to specify the expected read/write
flags for a pipe or tty. But we've already been asking the OS to tell us
what they actually are (fcntl F_GETFL), so we can hopefully just use
that information directly.
Fixes: https://github.com/libuv/libuv/issues/1936
PR-URL: https://github.com/libuv/libuv/pull/1964
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Not used anywhere or exported. Most of this code also cares which
direction handle is open too (Input or Output), so it's not particularly
useful.
PR-URL: https://github.com/libuv/libuv/pull/1964
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Problem:
Upper bound on thread wakeup was set to 1.5 * (requested timeout).
On MacOS wakeup delay factors of 1.75 have been reported.
Solution:
Increase the bound to 5 * (requested timeout).
Refs: https://github.com/libuv/libuv/issues/1910
PR-URL: https://github.com/libuv/libuv/pull/1990
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Problem:
libuv is compiled with -Wunused-result.
In two tests, read() is used for ordering and the
rc is ignored because it doesn't matter.
But -Wunused-result causes warnings in these cases.
Fix:
Provide a (very generous) check on the rc of read()
in these cases.
PR-URL: https://github.com/libuv/libuv/pull/1956
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Add compile options for Android arm64/x86/x86-64 and update the
instructions in README.md.
PR-URL: https://github.com/libuv/libuv/pull/1934
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This reverts commit fd8d212a80,
and thereby restores partial support for using libuv under Wine
(which does not implement GetQueuedCompletionStatusEx).
PR-URL: https://github.com/libuv/libuv/pull/1963
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Remove the support for kernels that don't support epoll_pwait()
now that the minimum requirements are kernel 2.6.32 + glibc 2.12.
PR-URL: https://github.com/libuv/libuv/pull/1372
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Remove the syscalls wrappers now that the minimum requirements are
kernel 2.6.32 + glibc 2.12.
This commit should fix the epoll_pwait()-related issues that have
been reported against mips/mipsel builds.
Fixes: https://github.com/libuv/libuv/issues/335
PR-URL: https://github.com/libuv/libuv/pull/1372
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This is now unnecessary as of the previous commit.
PR-URL: https://github.com/libuv/libuv/pull/1940
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Previously both uv_fs_utimes and uv_fs_futimes would fall back to utimes() if untimesat() wasn't supported.
Since utimesat() has been supported since linux kernel 2.6.22, and libuv supports at minimum 2.6.32, this code can be removed.
PR-URL: https://github.com/libuv/libuv/pull/1940
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
This should improve uv_fs_utime resolution and reliability, as
utime(2)'s precision is left more to the implementing platform than the
newer but well supported alternatives.
Related to https://github.com/nodejs/node/issues/22070
PR-URL: https://github.com/libuv/libuv/pull/1940
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
If `nthreads / 2` (rounded up) DNS calls are outstanding,
queue more work of that kind instead of letting it take over
more positions in the thread pool, blocking other work
such as the (usually much faster) file system I/O or
user-scheduled work.
Fixes: https://github.com/nodejs/node/issues/8436
PR-URL: https://github.com/libuv/libuv/pull/1845
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit sets the error returned by uv_loop_init() to
UV_ENOMEM in the case of a failed timer heap malloc.
PR-URL: https://github.com/libuv/libuv/pull/1944
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit adds error handling to the two WideCharToMultiByte()
calls in uv__getnameinfo_work() on Windows.
PR-URL: https://github.com/libuv/libuv/pull/1907
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
A file descriptor that can do multiple successful write completion
requests in a row will starve the loop because it will keep feeding
the write_completed_queue. This fix will only process items on the
write_completed_queue once per event loop (in uv__run_pending).
Any new items on the queue will be processed in the next loop.
PR-URL: https://github.com/libuv/libuv/pull/1787
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>