Commit Graph

3190 Commits

Author SHA1 Message Date
Ben Noordhuis
0070322ef2
win: move uv__insert_pending_req to core.c (#4828)
Large-ish functions with many call sites in different translation units
should not be `static inline`, that just results in lots of code
duplication which the linker may or may not deduplicate. When it does,
the linker has to do extra work; when it doesn't, binaries get bigger.

Refs: https://github.com/libuv/libuv/issues/4819
2025-07-08 16:33:02 +02:00
Ben Noordhuis
b36dc711e6
win: move uv__process_endgames to core.c (#4827)
Refs: https://github.com/libuv/libuv/issues/4819
2025-07-07 22:08:11 +02:00
Ben Noordhuis
dc117c7dec
win: dissolve atomicops-inl.h (#4826)
Commit 7fb43d3c from August 2012 moved uv__atomic_exchange_set from
async.c into a header file but in all those years, nothing except
async.c has ever used it. Move the function back again and remove
the header file.

I removed the superfluous uses of inline/INLINE but this is otherwise
a non-functional change.

Refs: https://github.com/libuv/libuv/issues/4819
2025-07-07 22:07:56 +02:00
Ben Noordhuis
3d12a590c1
win: remove unnecessary inlining from header file (#4824)
Refs: https://github.com/libuv/libuv/issues/4819
2025-07-06 16:19:36 +02:00
Ben Noordhuis
d67ef2e393
win: move uv__process_reqs to core.c (#4821)
Refs: https://github.com/libuv/libuv/issues/4819
2025-07-06 16:19:18 +02:00
Ben Noordhuis
25f6f84286
win: remove unnecessary inlining from fs.c (#4822)
Refs: https://github.com/libuv/libuv/issues/4819
2025-07-06 15:55:33 +02:00
Juan José
55f5fce1cc
unix: deduplicate uv_free_interface_addresses (#4818)
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-07-05 13:05:46 +02:00
Juan José
db3d0ff33a
unix: handle possible ENOMEM in uv__pipe_listen (#4817)
Refs: https://github.com/libuv/libuv/issues/4755
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-07-03 21:04:46 +02:00
Ben Noordhuis
8e51d38ab6
win: remove obsolete comment (#4816)
Refs: https://github.com/libuv/libuv/security/advisories/GHSA-qf6p-jg38-9f4x#advisory-comment-131127
2025-07-02 13:58:41 +02:00
Deep C
04fc1580d4
qnx: add qnx 8 support (#4801)
Fixes: https://github.com/libuv/libuv/issues/4710
2025-06-30 08:26:11 +02:00
chemodax
2545ffe74c
win: replace GetModuleHandleA with GetModuleHandleW (#4812) 2025-06-29 20:32:14 +02:00
Juan José Arboleda
513751e2fc unix: handle possible ENOMEM in uv__tcp_listen
Refs: https://github.com/libuv/libuv/issues/4755
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-06-24 10:50:34 +02:00
chemodax
5f3c0d3d08
win: use WSA_FLAG_NO_HANDLE_INHERIT in WSASocketW (#4810)
Resolves a potential race condition when a child process has been
created between WSASocketW() and SendHandleInformationW().
2025-06-22 23:26:24 +02:00
Ben Noordhuis
0d4f54f0f6
win: handle empty string in uv_get_process_title (#4807)
Distinguish between errors and "the console title is the empty string"
when calling GetConsoleTitle. Both are signified by a return value of
zero.

No test because I couldn't think of a succinct way to programmatically
create a new console window with an empty title.

Fixes: https://github.com/nodejs/node/issues/58695
2025-06-15 13:37:15 +02:00
jhnh204
6a0945b333
src: fix nullptr dereference in uv__print_handles (#4805) 2025-06-14 22:16:20 +02:00
Ben Noordhuis
b00c5d1a09
linux: fix -Wformat-truncation warning (#4793) 2025-05-29 22:11:40 +02:00
Andy Pan
3a9a6e3e6b
tcp: support customizing TCP_KEEPINTVL and TCP_KEEPCNT
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.
2025-05-21 08:43:53 +02:00
Ryan Liptak
2b76a4fafa
unix: fix uv_thread_{get,set}priority error codes (#4782)
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.
2025-05-15 09:16:25 +02:00
Juan José
a1692f7646
src: remove unused include of <assert.h> in timer.c (#4774)
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-05-02 10:13:07 +02:00
Juan José
e6c0007fae
sunos: improve fs event watcher OOM handling (#4759)
Propagate errors from uv__io_init_start() back to the caller.

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-04-23 23:24:52 +02:00
Juan José
414a5e7333
kqueue: improve fs event watcher OOM handling (#4758)
Propagate errors from uv__io_init_start() back to the caller.

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-04-23 23:21:37 +02:00
Juan José
69d2dfec14
linux: align CPU quota calculation with Rust (#4746)
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>
2025-04-22 22:12:30 +02:00
Ben Noordhuis
942e1418ea
unix: improve uv_loop_init OOM handling (#4757)
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
2025-04-18 16:23:51 +02:00
AE1020
bf6c8870dc
haiku: use uint32 instead of uint32_t (#4754)
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:

  648fa5897c/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.
2025-04-16 14:47:07 +02:00
crupest
bcc799a16e
unix: use pipe_fname if getsockname returns nothing (#4748)
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.
2025-04-08 10:49:34 +02:00
Ben Noordhuis
fc29c125d4
unix: remove TOCTOU issues from uv_pipe_chmod (#4749)
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
2025-04-07 22:34:23 +02:00
Andy Pan
745c68d4ea
sunos: use pipe2 on solaris and illumos (#4747)
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
2025-04-07 09:03:26 +02:00
Itay Bookstein
c1a9f01f22
linux: allow nul bytes in abstract socket address (#4737)
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>
2025-03-27 08:48:56 +01:00
Mohammed Keyvanzadeh
ea1cf034be style: rename parameter to match definition
Rename the `handle` parameter of `timer_close_cb`'s declaration
to `timer` to match the definition.
2025-03-17 22:32:21 +01:00
Stacey Marshall
98a4bab92a
unix,sunos: prefer SO_REUSEPORT for load balancing (#4733)
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.
2025-03-07 22:22:48 +01:00
Richard Lau
352d992916
aix,ibmi: fix undeclared identifiers (#4730)
Refs: https://github.com/libuv/libuv/pull/4724
2025-03-03 21:08:09 +01:00
Robert Nagy
545ecf515f
openbsd: do not error out if cpuspeed is not available (#4727)
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.
2025-03-03 09:13:29 +01:00
Ben Noordhuis
16d6a0b49d
unix: handle out of memory in iface name copy (#4724)
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
2025-02-27 23:30:29 +01:00
Stacey Marshall
436c04048e
unix,sunos: enable use of sendmmsg on Solaris and Illumos (#4717)
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
2025-02-27 12:24:40 -05:00
Anna Henningsen
843b64faf5
win: add ENABLE_VIRTUAL_TERMINAL_INPUT raw tty mode (#4688)
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. 4e7942135f/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: 87af913b66
Refs: https://github.com/microsoft/terminal/issues/4954
2025-02-21 23:34:53 +01:00
Ben Noordhuis
85b526f56a
unix,win: accept NAN/INFINITY as file timestamps (#4702)
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
2025-02-21 23:08:15 +01:00
Paolo Insogna
8a94b7b2ec
unix: enable getrusage for SunOS (#4707)
Fixes: https://github.com/libuv/libuv/issues/4706
2025-02-21 22:02:18 +01:00
rainlow
b807450e98
unix: add thread affinity support on openharmony (#4705) 2025-02-21 22:01:16 +01:00
Hüseyin Açacak
82cdfb75ff win: fix the inconsistency in volume serial number 2025-02-17 08:35:37 +01:00
Juan José Arboleda
dcace2a393 unix: remove unnecessary errno.h include in poll.c
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-02-17 07:51:25 +01:00
Jinho Jang
7894072528
macos: increase child process stdio buffer size (#4694)
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.
2025-02-10 10:07:50 -05:00
Hüseyin Açacak
abe59d6319 win: fix order of FILE_STAT_BASIC_INFORMATION struct fields 2025-02-10 12:32:57 +01:00
Andrey
51477bc711
macos,bsd: handle missing /dev/null in chroot env (#4689)
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
2025-02-04 21:43:18 +01:00
Morten Engelhardt Olsen
23632e9104
win: check cwd length before spawning a child process
The CreateProcess API on Windows is still not longPathAware,
even if the process itself is. So, if the cwd used for CreateProcess
is too long, then the call fails with a 'INVALID_DIRECTORY' error.

To deal with this, check the length of the cwd and shorten it if it
is longer than MAX_PATH.
2025-01-29 22:51:06 +01:00
Ben Noordhuis
a6ddf41edf
linux: try preadv64/pwritev64 before preadv/pwritev (#4683)
Fixes: https://github.com/libuv/libuv/issues/4678
Refs: https://github.com/libuv/libuv/issues/4532
2025-01-28 09:27:58 +01:00
Ben Noordhuis
82351168b3
win: lazy-load [GS]etThreadDescription symbols (#4679)
Said symbols are not by default available on Windows Server 2016 but
libuv can still use them when
api-ms-win-core-processthreads-l1-1-3.dll is present.

Fixes: https://github.com/libuv/libuv/issues/4677
2025-01-24 21:53:22 +01:00
Saúl Ibarra Corretgé
f15c602bd0 win: fix leak in uv_os_tmpdir
Fixes: https://github.com/libuv/libuv/issues/4680
2025-01-24 11:46:16 +01:00
Juan José
be8eec8c5a
misc: implement uv_getrusage_thread (#4666)
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>
2025-01-14 14:50:26 +01:00
Rafael Gonzaga
e59e2a9e49
src: set a default thread name for workers (#4664) 2025-01-08 13:58:28 +01:00
Saúl Ibarra Corretgé
ec5a4b54f7 win: fix leak processing fs event
Fixes: https://github.com/libuv/libuv/pull/4376#issuecomment-2544728609
2024-12-16 13:58:43 +01:00