Commit Graph

3166 Commits

Author SHA1 Message Date
reito
2baab70a48 test: bad name 2025-02-04 16:39:48 +08:00
reito
32f3e0dbae src: add comments 2025-02-04 16:39:48 +08:00
reito
2d64fe4a40 test: optimize code 2025-02-04 16:39:48 +08:00
reito
b1fbc5dbb2 test: add test for win uds 2025-02-04 16:39:48 +08:00
reito
3c56c48a2d test: add test for win uds 2025-02-04 16:39:48 +08:00
reito
a514c513e4 src: fix socket extension, uv_pipe_init_ex 2025-02-04 16:39:48 +08:00
reito
d9df97725a src: remove cond macro for should use uds pipe 2025-02-04 16:39:48 +08:00
reito
404d3787b5 src: acceptex/connectex get once at init, code review 2 2025-02-04 16:39:48 +08:00
reito
801b2476b8 src: code review 2025-02-04 16:39:48 +08:00
reito
61dd2b5b13 src: use positive words for uds. 2025-02-04 16:39:48 +08:00
reito
823a33b734 src: fix mingw 2025-02-04 16:39:48 +08:00
reito
a74298d8b6 src: refine comments 2025-02-04 16:39:48 +08:00
reito
281cf049fb src: fix mingw 2025-02-04 16:39:48 +08:00
reito
2254687ad4 src: cond disable on mingw. 2025-02-04 16:39:48 +08:00
reito
ca541f6799 src: getpeername getsockname 2025-02-04 16:39:48 +08:00
reito
260f51cb67 src: fix connectex with iocp bugm, implement end of uds stream 2025-02-04 16:39:48 +08:00
reito
c9ad1f5dee src: rename uds pipe flag. 2025-02-04 16:39:48 +08:00
reito
e75db5839f src: handle remote connection reset correctly. 2025-02-04 16:39:48 +08:00
reito
c4694e63e1 src: win pipe add unix domain socket support 2025-02-04 16:39:48 +08: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
Ben Noordhuis
e8969bff6c unix,win: add uv_udp_try_send2
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.
2024-12-13 21:52:59 +01:00
Ben Noordhuis
7b4cf04a91 unix: refactor udp sendmsg code
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.
2024-12-13 21:52:59 +01:00
amcgoogan
88201044ed
win: plug uv_fs_event_start memory leak (#4647)
Co-authored-by: Andrew McGoogan <amcgoogan@cribl.io>
Fixes: https://github.com/nodejs/node/issues/52769
2024-12-13 00:23:36 +01:00
Jameson Nash
72d9abccd7
win,fs: get (most) fstat when no permission (#4566)
Replaces: https://github.com/libuv/libuv/pull/4504
Fixes: https://github.com/libuv/libuv/issues/1980
Fixes: https://github.com/libuv/libuv/issues/3267

Co-authored-by: Hüseyin Açacak <huseyin@janeasystems.com>
2024-12-12 15:05:53 -05:00
Saúl Ibarra Corretgé
16e6e84dcc
win: drop support for the legacy MinGW (#4645)
The OG MinGW has been dead for years, MinGW-w64 has taken its place.
2024-12-12 15:59:30 +01:00
Saúl Ibarra Corretgé
88baee1a35 fixup! 2024-12-12 15:55:16 +01:00
Saúl Ibarra Corretgé
264bb335af win: enable uv_thread_{get,set}name on MinGW
It supports the API: 93f3505a75/mingw-w64-headers/include/processthreadsapi.h (L358)
2024-12-12 15:55:16 +01:00
Saúl Ibarra Corretgé
6af08fb527 win: use GetQueuedCompletionStatusEx directly
It was introduced in Vista, so we can assume it's always there now.
2024-12-10 23:44:29 +01:00
Ben Noordhuis
2494c088f0
unix,win: handle nbufs=0 in uv_udp_try_send (#4641) 2024-12-09 21:14:01 +01:00
Ben Noordhuis
69bad8201b
linux: always use io_uring for epoll batching (#4638)
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
2024-12-06 00:11:05 +01:00
Ben Noordhuis
c431bc39c3
linux: fix uv_cpu_info() arm cpu model detection (#4633)
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
2024-12-03 00:31:06 +01:00
Santiago Gimeno
61c966cf0b
src: add uv_thread_set/getname() methods (#4599)
`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.
2024-11-27 12:52:18 +01:00
Ben Noordhuis
b7d07d78e9
Revert "kqueue: change EV_OOBAND to EVFILT_EXCEPT+NOTE_OOB (#4597)" (#4623)
Unsupported on FreeBSD, breaking the build.

This reverts commit b1d30f9489.
2024-11-26 18:58:45 +01:00
Juan José
556a0f1f0f
unix,win: add support for detached threads (#4621)
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>
2024-11-26 08:44:38 -05:00
Juan José
b1d30f9489
kqueue: change EV_OOBAND to EVFILT_EXCEPT+NOTE_OOB (#4597)
Fixes: https://github.com/libuv/libuv/issues/3947
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-11-25 22:42:38 +01:00
Saúl Ibarra Corretgé
c6d43bea09
unix,win: harmonize buffer checking
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);
...
```
2024-11-25 15:10:47 +01:00
Saúl Ibarra Corretgé
31ea3411cc unix,pipe: fix handling null buffer in uv_pipe_get{sock,peer}name
Fixes: https://github.com/libuv/libuv/issues/4610
2024-11-22 08:57:45 +01:00
Andy Pan
5dcef22c62
kqueue: lower overhead in uv__io_check_fd (#4617)
Merge kevent calls along with the improvement of code simplicity.

Signed-off-by: Andy Pan <i@andypan.me>
2024-11-20 14:30:14 +01:00
Jeffrey H. Johnson
15e3f84678
unix: fix build breakage on haiku, openbsd, etc (#4618)
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>
2024-11-20 14:24:20 +01:00
Ben Noordhuis
c6b67af390
unix,win: fix off-by-one in uv_wtf8_to_utf16() (#4609)
uv_wtf8_length_as_utf16() checks if codepoints are > 0xFFFF (to see if
it should be encoded as a surrogate pair), therefore uv_wtf8_to_utf16()
should too. Instead it checked > 0x1000. Harmonize the checks.

Fixes: https://github.com/nodejs/node/issues/55914
2024-11-19 19:09:03 +01:00
Jameson Nash
7b75935b00
kqueue: use EVFILT_USER for async if available (#4588)
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>
2024-11-18 16:13:28 -05:00
Jameson Nash
058c49b7ba
win,fs: match trailing slash presence in junctions to user input (#4590)
Refs: #4582
2024-10-18 21:01:07 +02:00
Jameson Nash
7e6590f31d
win: remap ERROR_NOACCESS and ERROR_BUFFER_OVERFLOW (#4567)
It seemed incorrect to map a segfault to EACCES, since posix would typically
map this to EFAULT. The ERROR_BUFFER_OVERFLOW is literally "the filename is too
long", and is not typically an invalid parameter in posix.

Test originally added in #1060 to test the API, not the value.
2024-10-17 15:37:00 -04:00
Thad House
9cf0710d71
win: fix compilation against Windows 24H2 SDK (#4576)
Compilation against the 24H2 SDK is broken by #4327.

Fix that issue by only conditionally defining the new values.

Closes #4575
2024-10-17 15:36:45 -04:00