Commit Graph

5059 Commits

Author SHA1 Message Date
Jameson Nash
3300502231
darwin: use hw.cpufrequency again for frequency info (#3679)
This reverts commit 87f0765159 and
implements a work-around instead. This has been reported to be
unnecessary, and also returns the wrong answer (off by exactly 100x),
so it is not particularly useful.

This also reverts the bugfixes to the original PR:

Revert "darwin: fix iOS compilation and functionality"
This reverts commit 1addf9b88a.

Revert "macos: fix the cfdata length in uv__get_cpu_speed (#3356)"
This reverts commit 1e7074913e.

Revert "darwin: fix -Wsometimes-uninitialized warning"
This reverts commit 6085bcef8d.

Revert "macos: fix memleaks in uv__get_cpu_speed"
This reverts commit d2482ae121.

The expected behavior on failure to read this info is to report 0 (for
example
https://github.com/libuv/libuv/blob/8975c05d199558b0cc2e98f26ce33c6090d1
d7a1/src/unix/linux.c#L834), which is which was not the case before
this PR for macos.

However hw.cpufrequency sysctl seems to be missing on darwin/arm64
(Apple Silicon), so we instead hardcode a plausible value. This value
matches what the mach kernel will report when running Rosetta apps.

Fixes: https://github.com/libuv/libuv/issues/3642
Fixes: https://github.com/libuv/libuv/issues/2911
Refs: https://github.com/libuv/libuv/pull/2912
2022-11-08 12:40:17 -05:00
Ben Noordhuis
8975c05d19
doc: document 0 return value for free/total memory (#3817)
Refs: https://github.com/libuv/libuv/discussions/3809
2022-11-08 17:33:19 +01:00
twosee
07949ce2ae
win: fix an incompatible types warning (#3798) 2022-11-08 10:24:45 +01:00
ywave620
dff3f8ccab
win: optimize udp receive performance (#3807)
Do at most 32 nonblocking udp receive in a row.

Fixes: https://github.com/libuv/libuv/issues/3704
2022-11-08 10:23:40 +01:00
Qix
8a1f378f05
doc: mention close_cb can be NULL (#3810) 2022-11-08 09:57:54 +01:00
twosee
ec5130c3f9
unix,win: fix 'sprintf' is deprecated warning (#3813) 2022-11-08 09:56:14 +01:00
Saúl Ibarra Corretgé
a7b16bfb33 win: drop code checking for Windows XP / Server 2k3
Our minimum requirements are Windows 8 now.
2022-11-08 06:51:07 +01:00
Saúl Ibarra Corretgé
2b4b293ebb win,tcp,udp: remove "active streams" optimization
It has been disabled for 11 years, I guess it should remain that way.
2022-11-04 22:11:21 +01:00
Santiago Gimeno
c880de3004 build: remove bashism from autogen.sh 2022-11-04 10:34:57 +01:00
Ben Noordhuis
c83b9bd9c6
include: map ENODATA error code (#3802)
Fixes: https://github.com/libuv/libuv/issues/3795
2022-10-25 13:00:45 +02:00
daomingq
e900006642
thread: add support for affinity (#3774)
Backported thread affinity feature and related dependency commits
from master. It will add support for those APIs: uv_cpumask_size,
uv_thread_setaffinity, uv_thread_getaffinity.
The supported platforms are Linux, Freebsd, and Windows.
Empty implementations (returning UV_ENOTSUP) on non-supported platforms
(such as OS X and AIX).
2022-10-21 09:18:10 -04:00
number201724
357d28a256
win,pipe: improve method of obtaining pid for ipc (#3765)
In the old version of uv_pipe_open, the parent process ID is used
always. If the open pipe is used in the same process, the parent
process will be obtained incorrectly.

Now we first get the client pid and compare it with its own pid. If it
is the same, then get the server pid. If the two are the same, then the
pipe is from the same process.

Fixes: https://github.com/libuv/libuv/issues/3766
2022-10-21 09:14:48 -04:00
Jameson Nash
1de43a1a17
build: support AddressSanitizer on MSVC (#3692)
Fixes: https://github.com/libuv/libuv/issues/3682
2022-10-21 09:10:19 -04:00
jensbjorgensen
821b0ba8cb
doc: add uv_poll_cb status==UV_EBADF note (#3797) 2022-10-21 11:02:43 +02:00
Ben Noordhuis
acfe668ecb
build: add MemorySanitizer (MSAN) support (#3788)
- unpoison results from linux system call wrappers

- unpoison results from stat/fstat/lstat to pacify clang 14
  (fixed in later versions)

- add MSAN build option

- turn on MSAN CI build
2022-10-18 23:21:42 +02:00
Ben Noordhuis
73b0c1f947
unix,win: give thread pool threads an 8 MB stack (#3787)
Give the threads in the thread pool a stack size that is consistent
across platforms and architectures.

Fixes: https://github.com/libuv/libuv/issues/3786
2022-10-18 23:06:47 +02:00
ywave620
3e7d2a6492
stream: process more than one write req per loop tick (#3728)
Fixes: https://github.com/libuv/libuv/issues/3668
2022-10-08 10:23:01 +02:00
Ben Noordhuis
cd1a510d16
linux: merge files back into single file (#3778)
I split up linux.c around 2012 for no real reason and now I'm merging
it back together, again for no real reason.

I half-jest. I like the idea of having everything together because I
practically forgot linux-inotify.c existed. It also makes io_uring
experiments a little easier.

Last but not least, it removes about 100 lines of license boilerplate.
2022-10-02 14:09:42 +02:00
Ben Noordhuis
9a5a5140e5
linux: remove unused or obsolete syscall wrappers (#3777)
preadv, pwritev, dup3 and utimensat all exist in 2.6.32 kernels, libuv's
minimum supported kernel.

The wrapper for utimensat was already gone, only the define remained.
2022-10-02 13:34:12 +02:00
Christian Clason
f610339f74
build: add LIBUV_BUILD_SHARED cmake option (#3762)
Co-authored-by: Tim Tavlintsev <ttavlintsev@enttec.com>
Fixes: https://github.com/libuv/libuv/issues/3637
2022-10-01 19:51:09 +02:00
Ben Noordhuis
71a782b641
unix: simplify atomic op in uv_tty_reset_mode() (#3773)
Compare-and-exchange is only useful in a loop. Replace it with a simple
exchange.
2022-10-01 13:43:47 +02:00
Daniel
cdbba74d7a
doc: update LINKS.md (#3772) 2022-09-27 17:43:40 +02:00
number201724
81264cfcaf
win: fix uv__pipe_accept memory leak (#3767) 2022-09-26 11:35:23 +02:00
Ben Noordhuis
c798dd7ae5
build: restore qemu download logic (#3768)
I recently changed it to download a fixed .deb but seems it's updated
more frequently than I anticipated because the dfsg-7ubuntu1_package is
already gone, replaced with dfsg-7ubuntu2.

Bring back the downloader logic that fetches the filename from the
directory listing.
2022-09-26 11:29:50 +02:00
Ben Noordhuis
b00d1bd225
unix,win: fix memory leak in uv_fs_scandir() (#3760)
uv_fs_scandir() leaked an entry when you called it on a directory with
a single entry _and_ you didn't run the iterator until UV_EOF.

Fixes: https://github.com/libuv/libuv/issues/3748
2022-09-22 09:25:55 +02:00
Ben Noordhuis
47effc4bd3
unix: remove pre-macos 10.8 compatibility hack (#3759) 2022-09-22 09:25:35 +02:00
Ben Noordhuis
d651403b47 linux: move epoll.c back into linux-core.c
epoll.c is only used on Android and Linux after commit 5fe59726 ("sunos:
restore use of event ports") so move it back into linux-core.c

This commit removes a workaround for pre-2.6.27 kernels that don't have
the epoll_create1() system call.
2022-09-19 00:24:24 +02:00
Ben Noordhuis
48c90d3781 build: upgrade qemu-user-static package
4.2 is three years old by now. The linux/alpha emulator in that version
doesn't support the epoll_create1() system call.
2022-09-19 00:24:24 +02:00
Ben Noordhuis
d59b2905f9
linux: teach uv_get_constrained_memory() cgroupsv2 (#3744)
Fixes: https://github.com/libuv/libuv/issues/2315
2022-09-15 08:56:56 +02:00
Ben Noordhuis
0f478a7de7
kqueue: DRY file descriptor deletion logic (#3746)
Remove the TODO that says to batch up kevent(EV_DELETE) system calls.
It's unduly complicated in case of errors.

If you pass an out array to kevent(), it will store error records that
tell you which file descriptor caused the error but it also stores new
events in the array, complicating state management.

If you don't pass an out array, it simply doesn't tell you anything
except that _something_ failed. Optimistically trying batch deletion
and falling back to one-by-one deletion is probably possible but is
something of a deoptimization and also feels somewhat dangerous.

macOS has a mostly-undocumented kevent_qos() system call that accepts a
KEVENT_FLAG_ERROR_EVENTS flag that fixes the first problem but that of
course isn't portable.

Long story short, it seems like too much hassle for too little payoff.
Libuv has been doing one-by-one deletion for over a decade now and no
one complained about performance so far so let's just stick with that.
2022-09-12 22:59:43 +02:00
Ben Noordhuis
9d898acc56
test: fix musl libc.a dlerror() test expectation (#3735)
Dynamic loading with musl only works with libc.so because it is
is implemented in musl's dynamic linker, not in libc proper.

libc.a contains just a stub dlopen() that always fails with a "Dynamic
loading not supported" error message. Update the test to handle that.

Fix: https://github.com/libuv/libuv/issues/3706
2022-09-07 11:21:24 -04:00
Steven Schveighoffer
a855c74183
doc: add note about offset -1 in uv_fs_read/write (#3677) 2022-09-07 11:19:08 -04:00
Ben Noordhuis
fb76f210eb
unix: fix uv_getrusage() ru_maxrss reporting (#3721)
Most platforms report it in kilobytes but macOS and Solaris report it in
bytes and pages respectively.

Fixes: https://github.com/nodejs/node/issues/44332
2022-08-21 23:29:42 +02:00
Luan Devecchi
97dcdb1926
win: support Windows 11 in uv_os_uname() (#3718)
Fixes: https://github.com/libuv/libuv/issues/3381
Fixes: https://github.com/nodejs/node/issues/40862
2022-08-13 18:16:28 +02:00
Santiago Gimeno
7bccb562e4
unix,win: remove UV_HANDLE_SHUTTING flag (#3705)
Replace it with a `uv__is_stream_shutting()` macro that checks the
`shutdown_req` field.

It partially fixes: https://github.com/libuv/libuv/issues/3663.
2022-08-03 15:24:32 -04:00
Ben Noordhuis
4db0a9a6b7
win: fix thread race in uv_cwd() and uv_chdir() (#3708)
Another thread can change the working directory between calls to
GetCurrentDirectoryW().

The first call was used to determine the size of the buffer to use in
the second call. Retry if the reported size does not match the expected
size because the buffer's contents is undefined in that case.
2022-07-28 00:34:03 +02:00
Ben Noordhuis
850f002cb2
build: switch ci from macos-10.15 to macos-11 (#3707)
The former will be removed by GitHub in August.

Fixes: https://github.com/libuv/libuv/issues/3697
2022-07-27 22:53:28 +02:00
Ben Noordhuis
df0ac426f3
win: fix off-by-1 buffer overrun in uv_exepath() (#3695)
uv_exepath() wrote the nul byte *after* the end of the buffer. It's not
necessary to write said nul byte in the first place because that was a
workaround for a bug in the Windows XP version of GetModuleFileName().

Fix uv_cwd() in the same fashion, it doesn't need the nul byte either.

Fixes: https://github.com/libuv/libuv/issues/3691
2022-07-27 21:11:41 +02:00
Ben Noordhuis
6c692ad1cb
unix: don't accept() connections in a loop (#3696)
After analysis of many real-world programs I've come to conclude that
accepting in a loop is nearly always suboptimal.

1. 99.9% of the time the second accept() call fails with EAGAIN, meaning
   there are no additional connections to accept. Not super expensive
   in isolation but it adds up.

2. When there are more connections to accept but the listen socket is
   shared between multiple processes (ex. the Node.js cluster module),
   libuv's greedy behavior necessitated the UV_TCP_SINGLE_ACCEPT hack
   to slow it down in order to give other processes a chance.

Accepting a single connection and relying on level-triggered polling to
get notified on the next incoming connection both simplifies the code
and optimizes for the common case.
2022-07-20 12:42:50 +02:00
Ben Noordhuis
ac5180e29c
unix: switch to c11 atomics (#3688)
Fixes: https://github.com/libuv/libuv/issues/3683
2022-07-19 10:09:09 +02:00
自发对称破缺
fb85db1d3e
build: enable MSVC_RUNTIME_LIBRARY setting (#3624) 2022-07-18 15:49:17 -04:00
Ben Noordhuis
06948c6ee5
android: remove pthread-fixes.c (#3674)
This was a kludge for a bug in old versions (API level <= 16) of the
Android SDK.

The os390 port had a build dependency on the file but does not actually
use it so that too has been removed.
2022-07-15 11:18:38 +02:00
Ben Noordhuis
495ffca2c2
win: remove stdint-msvc2008.h (#3673)
Support for VS 2008 was removed two years ago in commit a779fccfd so
this file can safely be deleted.
2022-07-15 10:39:14 +02:00
Jameson Nash
e81cc74ca2 Now working on version 1.44.3
Fixes: https://github.com/libuv/libuv/issues/3586
2022-07-12 12:22:04 -04:00
Jameson Nash
57a9a7196f Add SHA to ChangeLog 2022-07-12 12:17:13 -04:00
Jameson Nash
0c1fa696aa 2022.07.12, Version 1.44.2 (Stable)
Changes since version 1.44.1:

* Add SHA to ChangeLog (Jameson Nash)

* aix, ibmi: handle server hang when remote sends TCP RST (V-for-Vasili)

* build: make CI a bit noisier (Jameson Nash)

* process: reset the signal mask if the fork fails (Jameson Nash)

* zos: implement cmpxchgi() using assembly (Shuowang (Wayne) Zhang)

* build: AC_SUBST for AM_CFLAGS (Claes Nästén)

* ibmi: Implement UDP disconnect (V-for-Vasili)

* doc: update active maintainers list (Ben Noordhuis)

* build: fix kFreeBSD build (James McCoy)

* build: remove Windows 2016 workflows (Darshan Sen)

* Revert "win,errors: remap ERROR_ACCESS_DENIED to UV_EACCES" (Darshan
  Sen)

* unix: simplify getpwuid call (Jameson Nash)

* build: filter CI by paths and branches (Jameson Nash)

* build: add iOS to macos CI (Jameson Nash)

* build: re-enable CI for windows changes (Jameson Nash)

* process,iOS: fix build breakage in process.c (Denny C. Dai)

* test: remove unused declarations in tcp_rst test (V-for-Vasili)

* core: add thread-safe strtok implementation (Guilherme Íscaro)

* win: fix incompatible-types warning (twosee)

* test: fix flaky file watcher test (Ben Noordhuis)

* build: fix AIX xlc autotools build (V-for-Vasili)

* unix,win: fix UV_RUN_ONCE + uv_idle_stop loop hang (Ben Noordhuis)

* win: fix unexpected ECONNRESET error on TCP socket (twosee)

* doc: make sample cross-platform build (gengjiawen)

* test: separate some static variables by test cases (Hannah Shi)

* sunos: fs-event callback can be called after uv_close() (Andy
  Fiddaman)

* uv: re-register interest in a file after change (Shuowang (Wayne)
  Zhang)

* uv: register UV_RENAME event for _RFIM_UNLINK (Shuowang (Wayne) Zhang)

* uv: register __rfim_event 156 as UV_RENAME (Shuowang (Wayne) Zhang)

* doc: remove smartos from supported platforms (Ben Noordhuis)

* macos: avoid posix_spawnp() cwd bug (Jameson Nash)

* release: check versions of autogen scripts are newer (Jameson Nash)

* test: rewrite embed test (Ben Noordhuis)

* openbsd: use utimensat instead of lutimes (tuftedocelot)

* doc: fix link to uvwget example main() function (blogdaren)

* unix: use MSG_CMSG_CLOEXEC where supported (Ben Noordhuis)

* test: remove disabled callback_order test (Ben Noordhuis)

* win,pipe: fix bugs with pipe resource lifetime management (Jameson
  Nash)

* loop: better align order-of-events behavior between platforms (Jameson
  Nash)

* aix,test: uv_backend_fd is not supported by poll (V-for-Vasili)

* kqueue: skip EVFILT_PROC when invalidating fds (chucksilvers)

* darwin: fix atomic-ops.h ppc64 build (Sergey Fedorov)

* zos: don't err when killing a zombie process (Shuowang (Wayne) Zhang)

* zos: avoid fs event callbacks after uv_close() (Shuowang (Wayne)
  Zhang)

* zos: correctly format interface addresses names (Shuowang (Wayne)
  Zhang)

* zos: add uv_interface_addresses() netmask support (Shuowang (Wayne)
  Zhang)

* zos: improve memory management of ip addresses (Shuowang (Wayne)
  Zhang)

* tcp,pipe: fail `bind` or `listen` after `close` (theanarkh)

* zos: implement uv_available_parallelism() (Shuowang (Wayne) Zhang)

* udp,win: fix UDP compiler warning (Jameson Nash)

* zos: fix early exit of epoll_wait() (Shuowang (Wayne) Zhang)

* unix,tcp: fix errno handling in uv__tcp_bind() (Samuel Cabrero)

* shutdown,unix: reduce code duplication (Jameson Nash)

* unix: fix c99 comments (Ben Noordhuis)

* unix: retry tcgetattr/tcsetattr() on EINTR (Ben Noordhuis)

* docs: update introduction.rst (Ikko Ashimine)

* unix,stream: optimize uv_shutdown() codepath (Jameson Nash)

* zos: delay signal handling until after normal i/o (Shuowang (Wayne)
  Zhang)

* stream: uv__drain() always needs to stop POLLOUT (Jameson Nash)

* unix,tcp: allow EINVAL errno from setsockopt in uv_tcp_close_reset()
  (Stacey Marshall)

* win,shutdown: improve how shutdown is dispatched (Jameson Nash)
2022-07-12 12:16:33 -04:00
Jameson Nash
ee970e38a6
win,shutdown: improve how shutdown is dispatched (#3649)
Split this off from endgame, so that it can be handled separately and
earlier, rather than trying to detect inside endgame which case we are
in. There appear to be some race conditions on the `handle` field still
however, which this does not yet attempt to address.
2022-07-11 12:30:20 -04:00
Stacey Marshall
f5e4d85cd2
unix,tcp: allow EINVAL errno from setsockopt in uv_tcp_close_reset() (#3662)
Some setsockopt() implememantations may return with errno of EINVAL
when the socket has been shut down already, as documented in the
Open Group Specifications Issue 7, 2018.

When this happens, reset errno and continue to mark the socket closed
and handle any callback.
2022-07-11 12:29:25 -04:00
Jameson Nash
47e95602c4
stream: uv__drain() always needs to stop POLLOUT (#3675)
Regression caused by 1a91b51976 mistake.

Refs: https://github.com/libuv/libuv/pull/3648
Fixes: https://github.com/libuv/libuv/pull/3648/3671
2022-07-11 12:24:49 -04:00
Wayne Zhang
c4d73c306b
zos: delay signal handling until after normal i/o (#3643)
Port the changes made to AIX and other unix systems in #611 to z/OS.

Defers the signal watcher that is used for process management until
after the dispatch of regular i/o watchers.

Refs: https://github.com/libuv/libuv/pull/611
Co-authored-by: Igor Todorovski <itodorov@ca.ibm.com>
2022-07-07 18:21:37 -04:00