History log of /libuv/src/unix/async.c (Results 1 – 25 of 43)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 1b01b786 24-May-2023 Ben Noordhuis

unix,win: replace QUEUE with struct uv__queue (#4022)

Recent versions of gcc have started emitting warnings about the liberal
type casting inside the QUEUE macros. Although the warnings

unix,win: replace QUEUE with struct uv__queue (#4022)

Recent versions of gcc have started emitting warnings about the liberal
type casting inside the QUEUE macros. Although the warnings are false
positives, let's use them as the impetus to switch to a type-safer and
arguably cleaner approach.

Fixes: https://github.com/libuv/libuv/issues/4019

show more ...


# fe7ee4a6 19-Jan-2023 Jameson Nash

unix: remove busy loop from uv_async_send (#3879)

The current fix (libuv#2231) was found to be slow in certain cases. This
change should improve scalabaility a bit by only incurring the

unix: remove busy loop from uv_async_send (#3879)

The current fix (libuv#2231) was found to be slow in certain cases. This
change should improve scalabaility a bit by only incurring the spin loop
delay while closing an UV_ASYNC. It also is intended to slightly improve
the behavior after uv_loop_close is called, by parking all of the
pending flags as set, so that it will not access the loop at all (until
the uv_async_t memory is freed, which we leave still to the
responsibility of the user).

Note that this bug appears to still exist on Win32, though it's harder
to address without the refactoring done to this code on libuv master.

Takes some inspiration from https://github.com/libuv/libuv/pull/2654
Takes some inspiration from https://github.com/libuv/libuv/pull/2656
Refs: https://github.com/libuv/libuv/pull/2231

show more ...


# ac5180e2 19-Jul-2022 Ben Noordhuis

unix: switch to c11 atomics (#3688)

Fixes: https://github.com/libuv/libuv/issues/3683


Revision tags: v1.41.0
# 4ddc2927 10-Nov-2020 Jameson Nash

stream: add uv_pipe and uv_socketpair to the API

Equivalents of `pipe` and `socketpair` for cross-platform use.

PR-URL: https://github.com/libuv/libuv/pull/2953
Reviewed-By: San

stream: add uv_pipe and uv_socketpair to the API

Equivalents of `pipe` and `socketpair` for cross-platform use.

PR-URL: https://github.com/libuv/libuv/pull/2953
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>

show more ...


Revision tags: v1.40.0, v1.39.0, v1.38.1, v1.38.0
# a9d9d4ea 22-Apr-2020 Ben Noordhuis

unix: yield cpu when spinlocking on async handle

Fixes: https://github.com/libuv/libuv/issues/2769
PR-URL: https://github.com/libuv/libuv/pull/2772
Reviewed-By: Anna Henningsen <anna

unix: yield cpu when spinlocking on async handle

Fixes: https://github.com/libuv/libuv/issues/2769
PR-URL: https://github.com/libuv/libuv/pull/2772
Reviewed-By: Anna Henningsen <anna@addaleax.net>

show more ...


Revision tags: v1.37.0, v1.36.0, v1.35.0
# dfd64933 04-Feb-2020 Ben Noordhuis

linux: simplify uv__async_eventfd()

Assume the presence of the eventfd2() system call on Linux. It was added
in 2.6.27 and our baseline is 2.6.32.

PR-URL: https://github.com/lib

linux: simplify uv__async_eventfd()

Assume the presence of the eventfd2() system call on Linux. It was added
in 2.6.27 and our baseline is 2.6.32.

PR-URL: https://github.com/libuv/libuv/pull/2665
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>

show more ...

Revision tags: v1.34.2, v1.34.1, v1.34.0, v1.33.1, v1.33.0, v1.32.0, v1.31.0, v1.30.1, v1.30.0, v1.29.1, v1.29.0, v1.28.0
# 37042a5b 26-Mar-2019 Ben Noordhuis

unix: fix race condition in uv_async_send()

After inspection of the code, it seems like there is a race window
between the cmpxchgi() and uv__async_send() calls.

If the event lo

unix: fix race condition in uv_async_send()

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>

show more ...

Revision tags: v1.27.0, v1.26.0, v1.25.0, v1.24.1, v1.24.0, v1.23.2, v1.23.1, v1.23.0, v1.22.0, v1.21.0, v1.20.3, v1.20.2, v1.20.1, v1.20.0, v1.19.2, v1.19.1
# 89cbbc89 19-Jan-2018 Mason X

include,src: introduce UV__ERR() macro

Using -errno, -E**, and -pthread_function() can be
error prone, and breaks compatibility with some operating
systems that already negate errno'

include,src: introduce UV__ERR() macro

Using -errno, -E**, and -pthread_function() can be
error prone, and breaks compatibility with some operating
systems that already negate errno's (e.g. Haiku).

This commit adds a UV__ERR() macro that ensures libuv
errors are negative.

Fixes: https://github.com/libuv/help/issues/39
PR-URL: https://github.com/libuv/libuv/pull/1687
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>

show more ...

Revision tags: v1.19.0, v1.18.0, v1.17.0, v1.16.1, v1.16.0, v1.15.0, v1.14.1, v1.14.0, v1.13.1, v1.13.0, v1.12.0
# fd39cec4 27-Apr-2017 Jameson Nash

build: add -Wstrict-prototypes

Fixes: https://github.com/libuv/libuv/pull/1320
PR-URL: https://github.com/libuv/libuv/pull/1326
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Revie

build: add -Wstrict-prototypes

Fixes: https://github.com/libuv/libuv/pull/1320
PR-URL: https://github.com/libuv/libuv/pull/1326
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>

show more ...

Revision tags: v1.11.0, v1.10.2, v1.10.1, v1.10.0, v0.10.37, v1.9.1
# fd7ce57f 22-Apr-2016 Jason Madden

unix: make loops and watchers usable after fork()

Added the uv_loop_fork() API that must be called in a child process to
continue using an existing loop. Internally this calls a uv__io_f

unix: make loops and watchers usable after fork()

Added the uv_loop_fork() API that must be called in a child process to
continue using an existing loop. Internally this calls a uv__io_fork
function for each supported platform, similar to the way
uv__platform_loop_init works.

After this call, existing and new IO, async and signal watchers will
contiue working as before on all platforms, as will the
threadpool (although any threads it was using are of course gone).

On Linux and BSDs that use kqueue, existing and new fsevent watchers
will also continue to work as expected. On OS X, though, directory
fsevents will not be able to use the optimized CoreFoundation path if
they had already been used in the parent process, instead falling back
to the kqueue path used on other BSDs.

Existing fsevent watchers will not function on AIX or SunOS. This
could be relatively easily fixed by someone with AIX knowledge in the
future, but SunOS will require some additional work to keep track if
the watchers.

A new test file, test/test-fork.c, was added to contain fork-related
tests to verify functionality in the child process.

PR-URL: https://github.com/libuv/libuv/pull/846
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>

show more ...

# 5fc8aecd 14-Mar-2017 Ben Noordhuis

unix: simplify async watcher dispatch logic

Remove the unused `nevents` parameter from `uv__async_event()`
and remove the indirection of having a separate `uv__async`
type. There is

unix: simplify async watcher dispatch logic

Remove the unused `nevents` parameter from `uv__async_event()`
and remove the indirection of having a separate `uv__async`
type. There is only one instance per event loop these days.

This incidentally removes the `assert(n == sizeof(val))` in a
Linux-specific code path that some users seem to hit from time
to time. The cause is not well-understood and I've never been
able to reproduce it myself. Presumably libuv gets an EAGAIN
when trying to read from the eventfd but when and why that
happens is unclear.

Since the byte count is unused, removing the assert seems safe.
Worst case, libuv sometimes iterates over the async watcher list
when it doesn't have to.

Fixes: https://github.com/libuv/libuv/issues/1171
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Supersedes: https://github.com/libuv/libuv/pull/1214

show more ...

# 375ba2d7 09-Apr-2016 Ben Noordhuis

unix: use POLL{IN,OUT,etc} constants directly

Remove the UV__POLL defines and use POLL{IN,OUT,etc} directly.
On Linux, we lean on the fact that the POLL constants correspond
one-to-o

unix: use POLL{IN,OUT,etc} constants directly

Remove the UV__POLL defines and use POLL{IN,OUT,etc} directly.
On Linux, we lean on the fact that the POLL constants correspond
one-to-one to their EPOLL counterparts.

Fixes: https://github.com/libuv/libuv/issues/816
PR-URL: https://github.com/libuv/libuv/pull/817
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>

show more ...

Revision tags: v1.9.0, v1.8.0
# 442b8a5a 08-Oct-2015 Ben Noordhuis

unix: use QUEUE_MOVE when iterating over lists

Replace uses of QUEUE_FOREACH when the list can get modified while
iterating over it, in particular when a callback is made into the
us

unix: use QUEUE_MOVE when iterating over lists

Replace uses of QUEUE_FOREACH when the list can get modified while
iterating over it, in particular when a callback is made into the
user's code. This should fix a number of spurious failures that
people have been reporting.

PR-URL: https://github.com/libuv/libuv/pull/565
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>

show more ...

Revision tags: v1.7.5, v1.7.4, v1.7.3, v1.7.2, v1.7.1, v1.7.0, v1.6.1, v1.6.0, v1.5.0, v0.10.36, v1.4.2, v0.10.35, v1.4.1, v0.10.34
# 4ed23727 18-Feb-2015 Michael Penick

unix: fix for uv_async data race

There's a data race in the consuming side of uv_async. The "pending"
flag could be trampled by producing thread causing an async send
event to be mis

unix: fix for uv_async data race

There's a data race in the consuming side of uv_async. The "pending"
flag could be trampled by producing thread causing an async send
event to be missed.

PR-URL: https://github.com/libuv/libuv/pull/189
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>

show more ...

Revision tags: v1.4.0, v1.3.0, v0.10.33, v1.2.1, v1.2.0, v0.10.32, v1.1.0, v0.10.31, v1.0.2, v0.10.30, v1.0.1, v1.0.0, v0.10.29, v1.0.0-rc2, v1.0.0-rc1, v0.11.29, v0.11.28, v0.11.27, v0.10.28, v0.11.26
# 4ce5470f 12-May-2014 Saúl Ibarra Corretgé

unix: fix uv__open_cloexec usage

It returns the fd or the negated errno.

Revision tags: v0.10.27, v0.11.25, v0.11.24
# 86831fe9 09-Apr-2014 Ben Noordhuis

linux: reduce file descriptor count of async pipe

Reopen one of the pipe descriptors as read/write through the procfs.
Allows us to close the original pipe file descriptors, saving a fil

linux: reduce file descriptor count of async pipe

Reopen one of the pipe descriptors as read/write through the procfs.
Allows us to close the original pipe file descriptors, saving a file
descriptor on kernels that don't support eventfd(2).

show more ...

Revision tags: v0.11.23, v0.10.26, v0.11.22
# db2a9072 10-Mar-2014 Saúl Ibarra Corretgé

unix, windows: removed unused status parameter

async, timer, prepare, idle and check handles don't need the status
parameter.

Revision tags: v0.11.21, v0.11.20, v0.10.25, v0.11.19, v0.10.24, v0.11.18, v0.10.23, v0.10.22, v0.11.17, v0.10.21, v0.11.16, v0.10.20, v0.11.15, v0.10.19, v0.11.14, v0.10.18
# 359d6678 01-Oct-2013 Ben Noordhuis

unix: sanity-check fds before closing

Ensure that close() system calls don't close stdio file descriptors
because that is almost never the intention.

This is also a partial work

unix: sanity-check fds before closing

Ensure that close() system calls don't close stdio file descriptors
because that is almost never the intention.

This is also a partial workaround for a kernel bug that seems to affect
all Linux kernels when stdin is a pipe that gets closed: fd 0 keeps
signalling EPOLLHUP but a subsequent call to epoll_ctl(EPOLL_CTL_DEL)
fails with EBADF. See joyent/node#6271 for details and a test case.

show more ...

Revision tags: v0.10.17, v0.10.16, v0.11.13, v0.11.12, v0.11.11, v0.11.10, v0.10.15, v0.11.9, v0.10.14, v0.11.8
# 1510ce81 12-Aug-2013 Ben Noordhuis

unix, windows: allow NULL async callback

Allow a NULL callback so the user doesn't have to provide a dummy when
the actual event is processed by e.g. a check handle callback.

Revision tags: v0.11.7, v0.10.13, v0.11.6, v0.10.12, v0.11.5, v0.10.11
# 3ee4d3f1 06-Jun-2013 Ben Noordhuis

unix, windows: return error codes directly

This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like

unix, windows: return error codes directly

This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like this one:

if (uv_foo(loop) < 0) {
uv_err_t err = uv_last_error(loop);
fprintf(stderr, "%s\n", uv_strerror(err));
}

Should be rewritten like this:

int err = uv_foo(loop);
if (err < 0)
fprintf(stderr, "%s\n", uv_strerror(err));

The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.

show more ...

Revision tags: v0.10.10, v0.11.4, v0.10.9, v0.10.8, v0.11.3, v0.10.7, v0.10.6, v0.11.2, v0.10.5, v0.10.4, v0.11.1, node-v0.11.0
# 0635e297 26-Mar-2013 Ben Noordhuis

unix, windows: remove ngx-queue.h

Avoids an extra #include in public headers and stops the ngx_queue_*
types and macros from leaking into user code.

Revision tags: v0.10.2, node-v0.7.3, node-v0.7.7, node-v0.7.5, node-v0.5.3, node-v0.10.1, node-v0.10.0, node-v0.9.12, node-v0.9.11
# b04fc33e 25-Feb-2013 Ben Noordhuis

linux: use eventfds for async handles

Use eventfds to drive async handles, fall back to regular pipes on older
kernels (pre-2.6.22).

Gives a nice boost on the async handle bench

linux: use eventfds for async handles

Use eventfds to drive async handles, fall back to regular pipes on older
kernels (pre-2.6.22).

Gives a nice boost on the async handle benchmarks. Before:

12,516,113 async events in 5.0 seconds (2,503,222/s, 1,048,576 unique
async1: 11.95 sec (83,701/sec)
async2: 11.65 sec (85,862/sec)
async4: 5.20 sec (192,154/sec)
async8: 9.97 sec (100,315/sec)
async_pummel_1: 1,000,000 callbacks in 2.56 seconds (389,919/sec)
async_pummel_2: 1,000,000 callbacks in 2.65 seconds (377,205/sec)
async_pummel_4: 1,000,000 callbacks in 2.18 seconds (457,704/sec)
async_pummel_8: 1,000,000 callbacks in 4.19 seconds (238,632/sec)

After:

16,168,081 async events in 5.0 seconds (3,233,616/s, 1,048,576 unique
async1: 11.08 sec (90,213/sec)
async2: 10.17 sec (98,297/sec)
async4: 4.81 sec (207,789/sec)
async8: 8.98 sec (111,419/sec)
async_pummel_1: 1,000,000 callbacks in 1.16 seconds (863,296/sec)
async_pummel_2: 1,000,000 callbacks in 1.45 seconds (691,459/sec)
async_pummel_4: 1,000,000 callbacks in 0.66 seconds (1,514,770/sec)
async_pummel_8: 1,000,000 callbacks in 1.42 seconds (704,549/sec)

That's a speedup from anywhere between 10% to 330%.

show more ...

# 92151658 25-Feb-2013 Ben Noordhuis

unix: abstract away async pipe infrastructure

This commit lays the groundwork for the switch to eventfds on Linux.

Revision tags: node-v0.8.21, node-v0.8.19, node-v0.9.10, node-v0.9.7, node-v0.9.6
# cb3c448d 07-Jan-2013 Ben Noordhuis

unix: fix GNU-ism introduced in edd1007

Don't use features.h, it's only available on GNU/glibc systems.

# edd10071 06-Jan-2013 Ben Noordhuis

unix: fix up #if defined checks

`#if FOO` (where FOO is undefined) is a legal construct in C89 and C99
but gcc, clang and sparse complain loudly about it at higher warning
levels.

unix: fix up #if defined checks

`#if FOO` (where FOO is undefined) is a legal construct in C89 and C99
but gcc, clang and sparse complain loudly about it at higher warning
levels.

Squelch those warnings. Makes the code more consistent as well.

show more ...

12