aboutsummaryrefslogtreecommitdiff
path: root/src/unix
Commit message (Collapse)AuthorAge
* unix: deduplicate uv_free_interface_addresses (#4818)Juan José13 days
| | | Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
* unix: handle possible `ENOMEM` in `uv__pipe_listen` (#4817)Juan José2025-07-03
| | | | Refs: https://github.com/libuv/libuv/issues/4755 Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
* qnx: add qnx 8 support (#4801)Deep C2025-06-30
| | | Fixes: https://github.com/libuv/libuv/issues/4710
* unix: handle possible `ENOMEM` in `uv__tcp_listen`Juan José Arboleda2025-06-24
| | | | | Refs: https://github.com/libuv/libuv/issues/4755 Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
* linux: fix -Wformat-truncation warning (#4793)Ben Noordhuis2025-05-29
|
* tcp: support customizing TCP_KEEPINTVL and TCP_KEEPCNTAndy Pan2025-05-21
| | | | | Implement `uv_tcp_keepalive_ex` function that extends `uv_tcp_keepalive` to support `TCP_KEEPINTVL` and `TCP_KEEPCN` socket options in addition to TCP_KEEPIDLE.
* unix: fix uv_thread_{get,set}priority error codes (#4782)Ryan Liptak2025-05-15
| | | | | | | | | pthread_getschedparam and pthread_setschedparam do not use errno but instead return the error code directly. https://pubs.opengroup.org/onlinepubs/9799919799/functions/pthread_getschedparam.html Also include a fix to return UV_ESRCH instead of UV_EBADF on Windows, like Unix systems do.
* sunos: improve fs event watcher OOM handling (#4759)Juan José2025-04-23
| | | | | Propagate errors from uv__io_init_start() back to the caller. Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
* kqueue: improve fs event watcher OOM handling (#4758)Juan José2025-04-23
| | | | | Propagate errors from uv__io_init_start() back to the caller. Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
* linux: align CPU quota calculation with Rust (#4746)Juan José2025-04-22
| | | | | | Align CPU quota calculation with Rust's cgroup heuristics. Fixes: https://github.com/libuv/libuv/issues/4740 Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
* unix: improve uv_loop_init OOM handling (#4757)Ben Noordhuis2025-04-18
| | | | | | | | | | Handle out-of-memory conditions in uv_loop_init better, albeit still not perfect: bubble up the error instead of aborting. Also fixes a file descriptor leak on Linux (and likely other platforms) that the new test caught; the backend epoll fd was being leaked in the error path. Fixes: https://github.com/libuv/libuv/issues/4755
* haiku: use uint32 instead of uint32_t (#4754)AE10202025-04-16
| | | | | | | | | | | | Haiku has parallel types to stdint.h, and their APIs use these types. In the Haiku-specific haiku.h file, it is passing an address of a uint32_t to get_cpu_topology_info(), that expects the other uint32: https://github.com/haiku/haiku/blob/648fa5897c28d5a4c8a5b4992dbf9b9d410434c8/src/system/libroot/os/system_info.cpp#L187 You get an "incompatible-pointer-types" warning in gcc if the warnings are turned up. But if you pass the pointer to Haiku's notion of uint32, then the warning goes away.
* unix: use pipe_fname if getsockname returns nothing (#4748)crupest2025-04-08
| | | | | | On some platforms (like GNU/Hurd), `getsockname` returns an empty string for sockets in the UNIX domain. However, we do have stored the path info in `pipe_fname` of `uv_pipe_t`, so we can try with it if `getsockname` returns an empty string.
* unix: remove TOCTOU issues from uv_pipe_chmod (#4749)Ben Noordhuis2025-04-07
| | | | | | | | | Use fchmod() on platforms that support it on UNIX sockets. Only fall back to chmod() on platforms that don't (macOS and the BSDs.) Remove the stat + chmod dance from the fallback and just call chmod directly, because that's another source of TOCTOU issues. Fixes: https://github.com/libuv/libuv/issues/2040
* sunos: use pipe2 on solaris and illumos (#4747)Andy Pan2025-04-07
| | | | | | | | Solaris implemented pipe2 in 11.4 and illumos have had it since 2013. Ref: https://docs.oracle.com/cd/E88353_01/html/E37841/pipe2-2.html https://illumos.org/man/2/pipe2 https://www.illumos.org/issues/3714
* linux: allow nul bytes in abstract socket address (#4737)Itay Bookstein2025-03-27
| | | | | | | Documentation on Linux explains that nul bytes have no special significance in abstract namespace socket names. Avoid precluding such addresses. Signed-off-by: Itay Bookstein <ibookstein@gmail.com>
* unix,sunos: prefer SO_REUSEPORT for load balancing (#4733)Stacey Marshall2025-03-07
| | | | | | | | | | | | | | | | | | Solaris 11.4 has Load Balancing for SO_REUSEPORT, but setting SO_REUSEADDR disables load balancing. As per comments in test/test-udp-reuseport.c prefer SO_REUSEPORT when available. With these changes in place udp-reuseport testing passes. BIND (named), which uses routing sockets which cause ENOPROTOOPT to be returned when SO_REUSEPORT is requested, also continues to work with the change. Notes: - The use of getsockopt() to query if SO_REUSEPORT was available was erroneous. - Selectively limiting SO_REUSEPORT setting to specific types of socket was considered but not entertained. - Oracle will investigate if the setting of SO_REUSEADDR was intentionally meant to prevent load balancing. - Adding a test for routing sockets is left for future work.
* aix,ibmi: fix undeclared identifiers (#4730)Richard Lau2025-03-03
| | | Refs: https://github.com/libuv/libuv/pull/4724
* openbsd: do not error out if cpuspeed is not available (#4727)Robert Nagy2025-03-03
| | | | | | On OpenBSD we do not know the cpuspeed in same cases (mostly arm64) and the HW_CPUSPEED sysctl will return EOPNOTSUPP in that case, which can be ignored because we still need the rest of the CPU information.
* unix: handle out of memory in iface name copy (#4724)Ben Noordhuis2025-02-27
| | | | | | Allocate storage upfront, that way we can never run out of memory halfway through processing the interface list. Fixes: https://github.com/libuv/libuv/issues/4723
* unix,sunos: enable use of sendmmsg on Solaris and Illumos (#4717)Stacey Marshall2025-02-27
| | | | | | | | Solaris provides sendmmsg() as of 11.3.32. It was added at the same time as MSG_WAITFORONE. The same is seen in Illumos guarded by __BSD_VISIBLE Fixes: https://github.com/libuv/libuv/issues/4715
* win: add ENABLE_VIRTUAL_TERMINAL_INPUT raw tty mode (#4688)Anna Henningsen2025-02-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Windows provides the `ENABLE_VIRTUAL_TERMINAL_INPUT` flag for TTY input streams as a companion flag to `ENABLE_VIRTUAL_TERMINAL_PROCESSING`, which libuv is already setting for TTY output streams. Setting this flag lets the terminal emulator perform some of the processing that libuv already currently does for input events, but most notably enables receiving control sequences that are otherwise entirely unavailable, e.g. for bracketed paste (which the Node.js readline implementation added basic support for in https://github.com/nodejs/node/commit/87af913b66eab78088acfd). libuv currently already provides translations for key events to control sequences, i.e. what this mode is intended to provide, but libuv does not and cannot translate all such events. Since the control sequences differ from the ones that Windows has chosen to standardize on, and applications may not be expecting this change, this is opt-in for now (but ideally will be the default behavior starting in libuv v2.x, should that ever happen). Another downside of this change is that not all shells reset this mode when an application exits. For example, when running a Node.js program with this flag enabled inside of PowerShell in Windows terminal, if the application exits while in raw TTY input mode, neither the shell nor the terminal emulator reset this flag, rendering the input stream unusable. While there's general awareness of the problem that console state is global state rather than per-process (same as on UNIX platforms), it seems that applications like PowerShell aren't expecting to need to unset this flag on the input stream, only its output counterpart (e.g. https://github.com/PowerShell/PowerShell/blob/4e7942135f998ab40fd3ae298b020e161a76d4ef/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs#L1156). Hence, `uv_tty_reset_mode()` is extended to reset the terminal to its original state if the new mode is being used. Refs: https://github.com/nodejs/node/commit/87af913b66eab78088acfd7f3b57d35e22c5f1ba Refs: https://github.com/microsoft/terminal/issues/4954
* unix,win: accept NAN/INFINITY as file timestamps (#4702)Ben Noordhuis2025-02-21
| | | | | | | | | | | | Extend uv_fs_utime, uv_fs_futime and uv_fs_lutime to accept NAN and INFINITY, with NAN meaning "don't touch the timestamp" and INFINITY meaning "set to the current timestamp." Ugly, but it avoids having to add uv_fs_utime2, etc. UV_FS_UTIME_NOW and UV_FS_UTIME_OMIT constants have been added to make it more palatable. Fixes: https://github.com/libuv/libuv/issues/4665
* unix: enable getrusage for SunOS (#4707)Paolo Insogna2025-02-21
| | | Fixes: https://github.com/libuv/libuv/issues/4706
* unix: add thread affinity support on openharmony (#4705)rainlow2025-02-21
|
* unix: remove unnecessary errno.h include in poll.cJuan José Arboleda2025-02-17
| | | | Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
* macos: increase child process stdio buffer size (#4694)Jinho Jang2025-02-10
| | | | | | | | | | | On macOS, when calling `spawn`, the child process's stdio buffer size is 8192 bytes. This is due to the AF_UNIX socket buffer size being 8192 bytes in the XNU kernel. When large amounts of data are transferred through the child process's stdio, this buffer size can cause performance issues. To mitigate this, the buffer size has been increased to 65536 bytes, aligning it with the behavior on Linux.
* macos,bsd: handle missing /dev/null in chroot env (#4689)Andrey2025-02-04
| | | Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
* linux: try preadv64/pwritev64 before preadv/pwritev (#4683)Ben Noordhuis2025-01-28
| | | | Fixes: https://github.com/libuv/libuv/issues/4678 Refs: https://github.com/libuv/libuv/issues/4532
* misc: implement uv_getrusage_thread (#4666)Juan José2025-01-14
| | | | | | Refs: https://github.com/libuv/libuv/issues/3119 Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com> Co-authored-by: James M Snell <jasnell@gmail.com>
* unix,win: add uv_udp_try_send2Ben Noordhuis2024-12-13
| | | | | | | | | Add a version of uv_udp_try_send that can send multiple datagrams. Uses sendmmsg(2) on platforms that support it (Linux, FreeBSD, macOS), falls back to a regular sendmsg(2) loop elsewhere. This work was sponsored by ISC, the Internet Systems Consortium.
* unix: refactor udp sendmsg codeBen Noordhuis2024-12-13
| | | | | | | Shuffle around and DRY the sendmsg logic in preparation for uv_udp_try_send2(). NFC barring bugs. This work was sponsored by ISC, the Internet Systems Consortium.
* unix,win: handle nbufs=0 in uv_udp_try_send (#4641)Ben Noordhuis2024-12-09
|
* linux: always use io_uring for epoll batching (#4638)Ben Noordhuis2024-12-06
| | | | | | | | | | | | io_uring support was default-disabled because of numerous kernel bugs but those are all in the sqpoll (file i/o) parts of io_uring. Batching of epoll_ctl calls through io_uring works fine, is a nice optimization, and is therefore unconditionally enabled again. The UV_USE_IO_URING environment variable now only affects sqpoll, and only when the UV_LOOP_ENABLE_IO_URING_SQPOLL event loop flag is set. Fixes: https://github.com/libuv/libuv/issues/4616
* linux: fix uv_cpu_info() arm cpu model detection (#4633)Ben Noordhuis2024-12-03
| | | | | | | Libuv looks for "Processor" in /proc/cpuinfo but it's been reported that on at least some Raspberry Pi models, it's called "model name". Look for both. Fixes: https://github.com/nodejs/node/issues/56105
* src: add uv_thread_set/getname() methods (#4599)Santiago Gimeno2024-11-27
| | | | | | | | | | | | | `uv_thread_setname()` sets the name of the current thread. Different platforms define different limits on the max number of characters a thread name can be: Linux, IBMi (16), macOS (64), Windows (32767), and NetBSD (32), etc. `uv_thread_setname()` will truncate it in case `name` is larger than the limit of the platform. `uv_thread_getname()` gets the name of the thread specified by `tid`. The thread name is copied into the buffer pointed to by `name`. The `size` parameter specifies the size of the buffer pointed to by `name`. The buffer should be large enough to hold the name of the thread plus the trailing NUL, or it will be truncated to fit.
* Revert "kqueue: change EV_OOBAND to EVFILT_EXCEPT+NOTE_OOB (#4597)" (#4623)Ben Noordhuis2024-11-26
| | | | | Unsupported on FreeBSD, breaking the build. This reverts commit b1d30f9489771a295c1d9b06402e49a77b3e91e6.
* unix,win: add support for detached threads (#4621)Juan José2024-11-26
| | | | | | This commit introduces the `uv_thread_detach` for thread detaching, allowing threads to be detached state on both UNIX and Windows platforms. Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
* kqueue: change EV_OOBAND to EVFILT_EXCEPT+NOTE_OOB (#4597)Juan José2024-11-25
| | | | Fixes: https://github.com/libuv/libuv/issues/3947 Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
* unix,win: harmonize buffer checkingSaúl Ibarra Corretgé2024-11-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For any API that takes a buffer and size pointer, check both pointers and the pointed-to size and return UV_EINVAL in case of error. Example: ``` int uv_foo(char* buffer, size_t* size) { if (buffer == NULL || size == NULL || *size == 0) return UV_EINVAL; ... } ``` In order to "peek" the necessary size for dynamic allocation, the following pattern can be used: ``` char *buf; char scratch[1]; size_t len = sizeof(scratch); int r; r = uv_foo(scratch, &len); assert(r == UV_ENOBUFS); buf = malloc(len); r = uv_foo(buf, &len); ... ```
* unix,pipe: fix handling null buffer in uv_pipe_get{sock,peer}nameSaúl Ibarra Corretgé2024-11-22
| | | | Fixes: https://github.com/libuv/libuv/issues/4610
* kqueue: lower overhead in uv__io_check_fd (#4617)Andy Pan2024-11-20
| | | | | Merge kevent calls along with the improvement of code simplicity. Signed-off-by: Andy Pan <i@andypan.me>
* unix: fix build breakage on haiku, openbsd, etc (#4618)Jeffrey H. Johnson2024-11-20
| | | | | | | | The compile-time detection check from commit 7b75935 ("kqueue: use EVFILT_USER for async if available") was not being used, breaking numerous operating systems. This commit hopefully unbreaks them. Fixes; https://github.com/libuv/libuv/issues/4608 Signed-off-by: Jeffrey H. Johnson <trnsz@pobox.com>
* kqueue: use EVFILT_USER for async if available (#4588)Jameson Nash2024-11-18
| | | | | | | | | Establishes a user event for kqueue to eliminate the overhead of the pipe and the system call read(2) per wakeup event. Relands commit 27134547ff using VSCode merge, since it shows the conflict is just on the order of #ifdef calls. Co-authored-by: Andy Pan <panjf2000@gmail.com>
* Revert "linux: eliminate a read on eventfd per wakeup (#4400)" (#4585)Ben Noordhuis2024-10-17
| | | | | | | | | | | | This reverts commit e5cb1d3d3d4ab3178ac567fb6a7f0f4b5eef3083. Reason: bisecting says it breaks dnstap. Also revert commit 27134547ff ("kqueue: use EVFILT_USER for async if available") because otherwise the first commit doesn't revert cleanly, with enough conflicts in src/unix/async.c that I'm not comfortable fixing those up manually. Fixes: https://github.com/libuv/libuv/issues/4584
* unix: fix uv_getrusage ru_maxrss on solaris (#4572)Poul T Lomholt2024-10-10
|
* unix: fix uv_tcp_keepalive in smartOS (#4570)Santiago Gimeno2024-10-09
| | | | | | | | | Make sure `UV__SOLARIS_11_4` is not set for `smartOS`/`illumOS`. In our codebase is used only twice: - Detect correct implementation of `SO_REUSEPORT`, which is not even implemented on `illumOS`. - Detect the time unit used for the TCP keepalive options. If set to `0`, which was the case for `illumOS`, it chose milliseconds, which is not correct for `illumOS` either as it uses seconds.
* unix: work around arm-linux-gnueabihf-gcc bug (#4565)Ben Noordhuis2024-10-08
| | | | | | | Both gcc 11 and 12 emit wrong code for a function call pointer in one very specific context. Fixes: https://github.com/libuv/libuv/issues/4532
* unix: workaround gcc bug on armv7 (#4564)Santiago Gimeno2024-10-07
| | | | | | Disable optimization on `uv__preadv_or_pwritev`. Fixes: https://github.com/libuv/libuv/issues/4532 Fixes: https://github.com/libuv/libuv/issues/4550
* netbsd: fix buildAdam2024-10-04
|