Compare commits

...

890 Commits

Author SHA1 Message Date
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
Tobias Nießen
feddddb56b
doc: fix rendering of threading.html (#4716) 2025-02-25 19:03:07 -05:00
Colin Ihrig
f61f9c29d8
test: handle UV_ENOTSUP in platform_output (#4714)
Fixes: https://github.com/libuv/libuv/issues/4713
2025-02-25 13:22:10 -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
Velikiy Kirill
378edb28f4
doc: add C3 bindings to LINKS.md (#4699) 2025-02-15 11:11:35 -05: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
Julio Jordán
e399e00e78
doc: fix README link text (#4693) 2025-02-08 09:42:12 -05: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é
bc19beadbd docs: fix RTD build
Setting the configuration key is now mandatory: https://about.readthedocs.com/blog/2024/12/deprecate-config-files-without-sphinx-or-mkdocs-config/
2025-01-24 14:11:13 +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
Santiago Gimeno
0f31978c30
Now working on version 1.50.1 2025-01-15 19:11:00 +01:00
Santiago Gimeno
a2ba04f83f Add SHA to ChangeLog 2025-01-15 19:05:30 +01:00
Santiago Gimeno
8fb9cb9194 2025.01.15, Version 1.50.0 (Stable)
Changes since version 1.49.2:

* ci: run macOS and iOS tests also on macOS 14 (Saúl Ibarra Corretgé)

* unix,win: map ENOEXEC errno (Saúl Ibarra Corretgé)

* test: skip multicast join test on ENOEXEC (Saúl Ibarra Corretgé)

* ci: make sure the macOS firewall is disabled (Saúl Ibarra Corretgé)

* darwin,test: squelch EBUSY error on multicast join (Saúl Ibarra
  Corretgé)

* build: update minimum cmake to 3.10 (Ben Noordhuis)

* kqueue: use EVFILT_USER for async if available (Jameson Nash)

* unix,win: fix off-by-one in uv_wtf8_to_utf16() (Ben Noordhuis)

* doc: add scala-native-loop to LINKS.md (Julian A Avar C)

* unix: fix build breakage on haiku, openbsd, etc (Jeffrey H. Johnson)

* kqueue: lower overhead in uv__io_check_fd (Andy Pan)

* doc: move cjihrig back to active maintainers (cjihrig)

* build(deps): bump actions/checkout from 3 to 4 (dependabot[bot])

* unix,pipe: fix handling null buffer in uv_pipe_get{sock,peer}name
  (Saúl Ibarra Corretgé)

* unix,win: harmonize buffer checking (Saúl Ibarra Corretgé)

* unix,win: add support for detached threads (Juan José Arboleda)

* src: add uv_thread_set/getname() methods (Santiago Gimeno)

* build: fix qemu builds (Ben Noordhuis)

* win: drop support for windows 8 (Ben Noordhuis)

* linux: fix uv_cpu_info() arm cpu model detection (Ben Noordhuis)

* linux: always use io_uring for epoll batching (Ben Noordhuis)

* doc: clarify repeating timer behavior more (Ben Noordhuis)

* unix,win: handle nbufs=0 in uv_udp_try_send (Ben Noordhuis)

* win: use GetQueuedCompletionStatusEx directly (Saúl Ibarra Corretgé)

* win: enable uv_thread_{get,set}name on MinGW (Saúl Ibarra Corretgé)

* win: drop support for the legacy MinGW (Saúl Ibarra Corretgé)

* win,fs: get (most) fstat when no permission (Jameson Nash)

* win: plug uv_fs_event_start memory leak (amcgoogan)

* test: address FreeBSD kernel bug causing NULL path in fsevents (Juan
  José Arboleda)

* unix: refactor udp sendmsg code (Ben Noordhuis)

* unix,win: add uv_udp_try_send2 (Ben Noordhuis)

* test: fix flaky flaky udp_mmsg test (Juan José Arboleda)

* build: enable fdsan in Android (Juan José Arboleda)

* test: fix udp-multicast-join for FreeBSD (Juan José Arboleda)

* win: fix leak processing fs event (Saúl Ibarra Corretgé)

* src: set a default thread name for workers (Rafael Gonzaga)

* misc: implement uv_getrusage_thread (Juan José Arboleda)
2025-01-15 19:05:29 +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
Juan José
beebf02cf6
test: fix udp-multicast-join for FreeBSD (#4655)
Fixes: https://github.com/libuv/libuv/issues/4651

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-12-16 09:05:09 +01:00
Juan José Arboleda
a94f2ad2b7 build: enable fdsan in Android
This patch will update Android API in CI to 29 and will set up the fdsan
in the test runner.

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Fixes: https://github.com/libuv/libuv/issues/4369
2024-12-16 09:01:15 +01:00
Juan José
3d78d121f4
test: fix flaky flaky udp_mmsg test (#4652)
Replace comparison of `alloc_cb_called` with the total bytes
read (`bytes_read`) to validate the test's correctness.

Fixes: https://github.com/libuv/libuv/issues/4650
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-12-15 20:24:20 +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
Juan José
acebb97490
test: address FreeBSD kernel bug causing NULL path in fsevents (#4649)
This commit documents a FreeBSD kernel issue where uv_fs_event can
receive a NULL filename and updates test-fs-event.c to skip filename
assertions on FreeBSD.

* Bugzilla: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197695

Refs: https://github.com/libuv/libuv/issues/4606

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-12-13 15:30:17 -05: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é
7752218db2 fixup! 2024-12-12 15:55:16 +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
467859c2ba
doc: clarify repeating timer behavior more (#4640)
It was already documented but only in the uv_timer_set_repeat section.
Move it to the toplevel and flesh it out more.

Refs: https://github.com/libuv/libuv/issues/181
Refs: https://github.com/libuv/libuv/discussions/4639
2024-12-08 22:32:49 +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
Ben Noordhuis
14644080c8
win: drop support for windows 8 (#4624)
Fixes: https://github.com/libuv/libuv/issues/3889
2024-11-28 22:02:41 +01:00
Ben Noordhuis
3d0578e6eb
build: fix qemu builds (#4630)
Upgrade GHA image to Ubuntu 24.04 and use the distro-provided qemu.

It should not be necessary anymore to install qemu from .deb because
the stock qemu is new enough in 24.04.
2024-11-28 21:06:05 +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
dependabot[bot]
d05744e3ed
build(deps): bump actions/checkout from 3 to 4 (#4490)
Requires updating the android builder, since the arm emulator is
deprecated and unavailable now. Switch to using a Github Action plugin
instead of a container, so that hopefully future updates will be
delivered via that channel instead.

Changed the idna test since printf returns EILSEQ for some byte
sequences in the format on Android in glibc. We don't fully understand
the cause, but we can avoid that by not asking it to reencode the bytes
in the current locale settings.
2024-11-21 08:38:56 -05:00
Colin Ihrig
1b084f7bbe
doc: move cjihrig back to active maintainers (#4615) 2024-11-20 11:37:56 -05: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
Julian A Avar C
2907f6d69e
doc: add scala-native-loop to LINKS.md (#4613) 2024-11-19 19:47:51 +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
Ben Noordhuis
2d8371a06e
build: update minimum cmake to 3.10 (#4604)
Fixes a deprecation warning with new cmake versions.

Changing the minimum from 3.9 to 3.10 should be safe because there isn't
even a non-EoL'd distro left that ships 3.10, let alone 3.9.

Fixes: https://github.com/libuv/libuv/issues/4603
2024-11-15 18:48:13 +01:00
Saúl Ibarra Corretgé
d4ab6fbba4 darwin,test: squelch EBUSY error on multicast join
The firewall was suspected to be the culprit, but the test
intermittently fails in the CI, not locally.
2024-10-22 10:26:32 +02:00
Saúl Ibarra Corretgé
e129cd7fda ci: make sure the macOS firewall is disabled
It seems to be disabled by default, for now, but let's log its status
and disable it just in case.
2024-10-22 10:26:32 +02:00
Saúl Ibarra Corretgé
a3abfbcb08 test: skip multicast join test on ENOEXEC
It happens due to the default firewall configuration on macOS >= 13.

Note: GH action runners have their firewall disabled, and yet, the test
fails all the same. Oh well...

Closes: https://github.com/libuv/libuv/issues/4263
2024-10-22 10:26:32 +02:00
Saúl Ibarra Corretgé
64f4502b9b unix,win: map ENOEXEC errno 2024-10-22 10:26:32 +02:00
Saúl Ibarra Corretgé
0caf5bb876 ci: run macOS and iOS tests also on macOS 14
The macOS 14 runners are ARM64 (in the non "large" version) whereas
macOS 13 runners are still x64, so keep that one around too.
2024-10-22 10:26:32 +02:00
Santiago Gimeno
94e467ad93
Now working on version 1.49.3 2024-10-18 21:08:15 +02:00
Santiago Gimeno
078180e13d Add SHA to ChangeLog 2024-10-18 21:02:38 +02:00
Santiago Gimeno
e1095c7a43 2024.10.18, Version 1.49.2 (Stable)
Changes since version 1.49.1:

* win,fs: remove trailing slash in junctions (Hüseyin Açacak)

* Revert "linux: eliminate a read on eventfd per wakeup" (Ben Noordhuis)

* win: Fix linked list logic in getaddrinfo (Thad House)

* win: fix compilation against Windows 24H2 SDK (Thad House)

* win: remap ERROR_NOACCESS and ERROR_BUFFER_OVERFLOW (Jameson Nash)

* win,fs: match trailing slash presence in junctions to user input
  (Jameson Nash)
2024-10-18 21:02:38 +02: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
Thad House
52a9243317
win: Fix linked list logic in getaddrinfo (#4578)
The logic in #4254 is incorrect, and results in the addrinfo linked
list only having a single result. Fix this by correcting the logic.

Closes #4577
2024-10-17 15:36:07 -04:00
Ben Noordhuis
18d48bc13c
Revert "linux: eliminate a read on eventfd per wakeup (#4400)" (#4585)
This reverts commit e5cb1d3d3d.

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
2024-10-17 20:41:38 +02:00
Hüseyin Açacak
fbe2d85bd5 win,fs: remove trailing slash in junctions
Fixes: https://github.com/libuv/libuv/issues/3329
2024-10-15 09:48:27 +02:00
Santiago Gimeno
be0b00a80d
Now working on version 1.49.2 2024-10-11 09:21:05 +02:00
Santiago Gimeno
bfbd6db0d6 Add SHA to ChangeLog 2024-10-11 09:13:11 +02:00
Santiago Gimeno
8be336f4ee 2024.10.11, Version 1.49.1 (Stable)
Changes since version 1.49.0:

* build: add darwin-syscalls.h to release tarball (Ben Noordhuis)

* linux: use IORING_SETUP_NO_SQARRAY when available (Ben Noordhuis)

* linux: use IORING_OP_FTRUNCATE when available (Ben Noordhuis)

* win: fix pNtQueryDirectoryFile check (Rialbat)

* win: fix WriteFile() error translation (Santiago Gimeno)

* win,fs: uv_fs_rmdir() to return ENOENT on file (Santiago Gimeno)

* win,pipe: ipc code does not support async read (Jameson Nash)

* netbsd: fix build (Adam)

* win,fs: fix bug in fs__readdir (Hüseyin Açacak)

* unix: workaround gcc bug on armv7 (Santiago Gimeno)

* unix: work around arm-linux-gnueabihf-gcc bug (Ben Noordhuis)

* unix: fix uv_tcp_keepalive in smartOS (Santiago Gimeno)

* unix: fix uv_getrusage ru_maxrss on solaris (Poul T Lomholt)
2024-10-11 09:13:10 +02:00
Poul T Lomholt
7c3abfbf1e
unix: fix uv_getrusage ru_maxrss on solaris (#4572) 2024-10-10 17:04:11 +02:00
Santiago Gimeno
1f36b01ed0
unix: fix uv_tcp_keepalive in smartOS (#4570)
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.
2024-10-09 09:52:00 +02:00
Ben Noordhuis
8d957c56b3
unix: work around arm-linux-gnueabihf-gcc bug (#4565)
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
2024-10-08 08:57:22 +02:00
Santiago Gimeno
0be52c8251
unix: workaround gcc bug on armv7 (#4564)
Disable optimization on `uv__preadv_or_pwritev`.

Fixes: https://github.com/libuv/libuv/issues/4532
Fixes: https://github.com/libuv/libuv/issues/4550
2024-10-07 08:47:16 +02:00
Hüseyin Açacak
1cbffcbd5d win,fs: fix bug in fs__readdir 2024-10-04 13:33:22 +02:00
Adam
670e75ee7e
netbsd: fix build 2024-10-04 09:26:07 +02:00
Jameson Nash
f55efb2f38
win,pipe: ipc code does not support async read (#4555)
The implementation of IPC pipe in libuv on Windows does not properly support
async reading. This means we cannot set the more parameter without likely
causing hangs. Sorry this is yet another followup to #4511.

Fixes #4548
2024-10-03 22:12:22 +02:00
Santiago Gimeno
88b874e63c
win,fs: uv_fs_rmdir() to return ENOENT on file (#4563)
After commit 18266a6969, it changed to return `ENOTDIR`, which makes it
consistent with other platforms but it also can be considered a breaking
change.
2024-10-03 21:29:10 +02:00
Santiago Gimeno
473dafc593
win: fix WriteFile() error translation (#4562)
Translate `ERROR_BROKEN_PIPE` and `ERROR_NO_DATA` to `UV_EPIPE` instead
of their default translation, which will be used for the rest of cases.

Refs: https://github.com/libuv/libuv/issues/4548#issuecomment-2383998849
2024-10-03 18:53:39 +02:00
Rialbat
65e3735320 win: fix pNtQueryDirectoryFile check
Fixed incorrect verification of the pNtQueryDirectoryFile pointer.
2024-10-03 08:59:39 +02:00
Ben Noordhuis
f806be87d3
linux: use IORING_OP_FTRUNCATE when available (#4554)
Route ftruncate() system calls through io_uring instead of the thread
pool when the kernel is new enough to support it (linux >= 6.9).

This commit harmonizes how libuv checks if the kernel is new enough.
Some ops were checking against `uv__kernel_version()` directly while
others stored the result of the version check as a feature flag.

Because the kernel version is cached, and because it is more direct
than a feature flag, I opted for the former approach.
2024-09-30 21:55:34 +02:00
Ben Noordhuis
bcc6d1c1fc
linux: use IORING_SETUP_NO_SQARRAY when available (#4553)
Introduced in Linux 6.6, it tells the kernel to omit the sqarray from
the ring buffer.

Libuv initalizes the array once to an identity mapping and then forgets
about it, so not only does it save a little memory (ca. 1 KiB per ring)
but it also makes things more efficient kernel-side because it removes
a level of indirection.
2024-09-30 19:44:27 +02:00
Ben Noordhuis
675a5a5396
build: add darwin-syscalls.h to release tarball (#4546)
Overlooked in commit 1c778bd0 ("darwin: add udp mmsg support") from
earlier this month.

Fixes: https://github.com/libuv/libuv/issues/4544
2024-09-26 09:45:36 +02:00
Santiago Gimeno
5467ec969a
Now working on version 1.49.1 2024-09-25 10:37:04 +02:00
Santiago Gimeno
511e202e13 Add SHA to ChangeLog 2024-09-25 10:17:21 +02:00
Santiago Gimeno
d2e56a5e8d 2024.09.25, Version 1.49.0 (Stable)
Changes since version 1.48.0:

* test: fix -Wpointer-to-int-cast on 32 bits systems (Ben Noordhuis)

* build: add alias for libuv to CMakeLists.txt (Anthony Alayo)

* linux: create io_uring sqpoll ring lazily (Ben Noordhuis)

* misc: run sample CI when code changes (Jameson Nash)

* linux: fix uv_available_parallelism using cgroup (Thomas Walter)

* doc: fix tty example segfault (hiiizxf)

* udp,unix: fix sendmsg use-after-free (Geddy)

* cygwin: implement uv_resident_set_memory (Farzin Monsef)

* win: almost fix race detecting ESRCH in uv_kill (Santiago Gimeno)

* test: disable env var test under win32+asan (Ben Noordhuis)

* unix,fs: fix realpath calls that use the system allocator (Saúl Ibarra
  Corretgé)

* sunos: sync tcp keep-alive with other unices (Andy Pan)

* linux: fix /proc/self/stat executable name parsing (Farzin Monsef)

* test,ci: fix [AM]San, disable ASLR (Ben Noordhuis)

* win: remove _alloca usage (Ben Noordhuis)

* unix: reinstate preadv/pwritev fallback code (Ben Noordhuis)

* linux: don't delay EPOLL_CTL_DEL operations (Ben Noordhuis)

* doc: fix typos in ChangeLog (tgolang)

* unix,win: error on zero delay tcp keepalive (Saúl Ibarra Corretgé)

* win: simplify uv_once implementation (Saúl Ibarra Corretgé)

* doc: correct udp socket options documentation (Ben Noordhuis)

* linux: don't use sendmmsg() for single datagrams (Ben Noordhuis)

* unix: fix fd leaks in SCM_RIGHTS error path (Ben Noordhuis)

* win: robustify uv_os_getenv() error checking (Ben Noordhuis)

* test: use newer ASSERT_MEM_EQ macro (Ben Noordhuis)

* unix: de-duplicate conditions for using kqueue (Brad King)

* darwin: simplify uv_hrtime (Saúl Ibarra Corretgé)

* mailmap: update saghul's main email address (Saúl Ibarra Corretgé)

* win: remove no longer needed define (Saúl Ibarra Corretgé)

* doc: fix some typos (josedelinux)

* linux,darwin: make `uv_fs_copyfile` behaves like `cp -r` (Juan José
  Arboleda)

* dragonfly: disable SO_REUSEPORT for UDP socket bindings (Andy Pan)

* test: remove the obsolete HAVE_KQUEUE macro (Andy Pan)

* unix: use the presence of SOCK_* instead of OS macros for socketpair
  (Andy Pan)

* bsd: support pipe2() on *BSD (Andy Pan)

* unix: support SO_REUSEPORT with load balancing for TCP (Andy Pan)

* doc: add entries for extended getpw (Juan José Arboleda)

* test: fix the flaky test-tcp-reuseport (Andy Pan)

* aix,ibmi: fix compilation errors in fs_copyfile (Jeffrey H. Johnson)

* unix: support SO_REUSEPORT with load balancing for UDP (Andy Pan)

* tcpkeepalive: distinguish OS versions and use proper time units (Andy
  Pan)

* win: map ERROR_BAD_EXE_FORMAT to UV_EFTYPE (Hüseyin Açacak)

* doc: add instruction how to install with Conan (Uilian Ries)

* unix,win: remove unused req parameter from macros (Viacheslav
  Muravyev)

* build: fix android ci build (Ben Noordhuis)

* unix,win: export wtf8 functions properly (Ben Noordhuis)

* hurd: add includes and macro prerequisites (Olivier Valentin)

* hurd: stub uv_thread_setpriority() (Olivier Valentin)

* ci: use macOS 12 for macOS and iOS builds (Saúl Ibarra Corretgé)

* darwin: fix crash on iOS(arm64) (郑苏波 (Super Zheng))

* Create dependabot.yml for updating github-actions (Jameson Nash)

* doc: correct names of Win32 APIs in fs.rst (zeertzjq)

* ci: bump upload and download-artifact versions (dependabot[bot])

* ci: bump actions/setup-python from 4 to 5 (dependabot[bot])

* ci: bump KyleMayes/install-llvm-action from 1 to 2 (dependabot[bot])

* win,error: remap ERROR_NO_DATA to EAGAIN (Jameson Nash)

* test: handle zero-length udp datagram (Ben Noordhuis)

* misc: remove splay trees macros (Viacheslav Muravyev)

* test,openbsd: remove superfluous ifdef guard (Ben Noordhuis)

* win,fs: use posix delete semantics, if supported (Ian Butterworth)

* win: fix env var in uv_os_homedir and uv_os_tmpdir (Hüseyin Açacak)

* fsevents: detect watched directory removal (Santiago Gimeno)

* ci: bump actions/checkout to 4 (dependabot[bot])

* linux: eliminate a read on eventfd per wakeup (Andy Pan)

* test: pipe_overlong_path handle ENAMETOOLONG (Abdirahim Musse)

* win,fs: use the new Windows fast stat API (Hüseyin Açacak)

* win,pipe: fix race with concurrent readers (Jameson Nash)

* win,signal: fix data race dispatching SIGWINCH (Jameson Nash)

* build: ubsan fixes (Matheus Izvekov)

* linux: disable SQPOLL io_uring by default (Santiago Gimeno)

* win: fix fs.c ubsan failure (Matheus Izvekov)

* test: rmdir can return `EEXIST` or `ENOTEMPTY` (Richard Lau)

* test: check for `UV_CHANGE` or `UV_RENAME` event (Richard Lau)

* unix,fs: silence -Wunused-result warning (Santiago Gimeno)

* linux: support abstract unix socket autobinding (Ben Noordhuis)

* kqueue: use EVFILT_USER for async if available (Andy Pan)

* win: remove deprecated GetVersionExW call (Shelley Vohr)

* doc: document uv_loop_option (握猫猫)

* doc: fix the `uv_*_set_data` series of functions (握猫猫)

* doc: properly label enumerations and types (握猫猫)

* doc: document specific macOS fs_event behavior (Santiago Gimeno)

* win,pipe: restore fallback handling for blocking pipes (Jameson Nash)

* unix,win: remove unused rb-tree macro parameters (Viacheslav Muravyev)

* win: compute parallelism from process cpu affinity (Ben Noordhuis)

* win: use NtQueryInformationProcess in uv_os_getppid (Zuohui Yang)

* win,pipe: fix missing assignment to success (Jameson Nash)

* win: fix uv_available_parallelism on win32 (Ben Noordhuis)

* win,pipe: fix another missing assignment to success (Jameson Nash)

* kqueue: disallow ill-suited file descriptor kinds (Andy Pan)

* unix: restore tty attributes on handle close (Ben Noordhuis)

* test: delete test with invalid assumption (Ben Noordhuis)

* dragonflybsd: fix compilation failure (Jeffrey H. Johnson)

* test: run android tests on ci (Edigleysson Silva (Edy))

* darwin: add udp mmsg support (Raihaan Shouhell)

* unix: work around arm-linux-gnueabihf-gcc bug (Ben Noordhuis)

* unix: expand uv_available_parallelism() to support more platforms
  (Ondřej Surý)

* doc: add known issue in armv7 (Santiago Gimeno)
2024-09-25 10:17:20 +02:00
Santiago Gimeno
cc2e0aa3cf
doc: add known issue in armv7 (#4541)
Refs: https://github.com/libuv/libuv/issues/4532
2024-09-24 21:31:51 +02:00
Ondřej Surý
e1a5465255 unix: expand uv_available_parallelism() to support more platforms 2024-09-24 10:54:48 +02:00
Ben Noordhuis
32603fd5ff
unix: work around arm-linux-gnueabihf-gcc bug (#4537)
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
2024-09-19 19:53:19 +02:00
Raihaan Shouhell
1c778bd001
darwin: add udp mmsg support (#4527) 2024-09-17 23:15:37 +02:00
Edigleysson Silva (Edy)
5bb19f35ea
test: run android tests on ci (#4517) 2024-09-17 21:30:24 +02:00
Jeffrey H. Johnson
88af4a87d2
dragonflybsd: fix compilation failure (#4534)
Fixes: https://github.com/libuv/libuv/issues/4533
Signed-off-by: Jeffrey H. Johnson <trnsz@pobox.com>
2024-09-17 21:27:18 +02:00
Ben Noordhuis
9dddebab0d
test: delete test with invalid assumption (#4530)
Delete the fs_event_error_reporting test. It fails in different ways,
most frequently on the TSan sanitizer buildbot, due to running out of
file descriptors when that is not expected, or vice versa, *not*
running out of file descriptors when that *is* expected.

The test creates a large number of event loops and expects to,
eventually, hit EMFILE but it sometimes hits it too early, and
sometimes not at all.

I don't think TSan is really responsible here, it just makes the
invalid assumption in the test itself more visible.

Fixes: https://github.com/libuv/libuv/issues/4368
2024-09-12 22:19:10 +02:00
Ben Noordhuis
a49f264dff
unix: restore tty attributes on handle close (#4399)
Libuv stores the `struct termios` for use inside uv_tty_reset_mode().

Node.js uses said function to restore the tty to its original mode
on SIGINT or SIGTERM, when there is no opportunity to shut down the
process normally.

Track uv_tty_t handle closing, otherwise we might be trying to use a
stale termios.

The current solution is not ideal because there can be multiple handles
that refer to the same tty/pty and, for various reasons, we can't really
determine when we close the last handle. The last handle may not even be
inside the current process.

Still, all things considered, it's probably (hopefully!) an improvement
over the status quo.

Refs: https://github.com/libuv/libuv/issues/4398
2024-09-11 10:33:54 +02:00
Andy Pan
44e61dab7e
kqueue: disallow ill-suited file descriptor kinds (#4513)
Follows up on https://github.com/libuv/libuv/pull/659.

Signed-off-by: Andy Pan <i@andypan.me>
2024-09-09 20:22:15 +02:00
Jameson Nash
0a00e80c36
win,pipe: fix another missing assignment to success (#4523)
Yet another followup to #4511. The functional/legacy/increment_spec.lua
test failed most of the time without this, and passes consistently with
it. It seemed unexpected this code path gets reached (perhaps imply
that the user wrote zero bytes?), but good to fix of course.
2024-09-05 09:46:37 -04:00
Ben Noordhuis
5ff1fc724f
win: fix uv_available_parallelism on win32 (#4525)
Fixes commit 58dfb6c89b from a few days ago. DWORD_PTR is 32 bits on
x86 Windows. Use the right bit count when checking the population count.

Interestingly enough, it manifested itself as double counting online
processors, presumably because the compiler emits a ROR instead of SHR.

Fixes: https://github.com/libuv/libuv/issues/4524
2024-09-02 11:24:11 +02:00
Jameson Nash
f00d4b6775
win,pipe: fix missing assignment to success (#4515) 2024-08-28 19:59:46 -04:00
Zuohui Yang
5cbc82e369
win: use NtQueryInformationProcess in uv_os_getppid (#4514)
Get parent process ID using NtQueryInformationProcess, it's faster than
using CreateToolhelp32Snapshot.
2024-08-26 20:17:53 +02:00
Ben Noordhuis
58dfb6c89b
win: compute parallelism from process cpu affinity (#4521)
Use GetProcessAffinityMask() to estimate the available parallelism.
Before this commit, it simply used the number of available CPUs.

Fixes: https://github.com/libuv/libuv/issues/4520
2024-08-26 10:22:42 +02:00
Viacheslav Muravyev
b5eb41d882
unix,win: remove unused rb-tree macro parameters (#4518) 2024-08-25 22:54:09 +02:00
Jameson Nash
c869cd1d8a
win,pipe: restore fallback handling for blocking pipes (#4511)
In #4470, I accidentally copied the bug from unix, where calling
uv_stream_set_blocking can cause the whole process to hang on a read.
However, unlike unix, where libuv attempts to set the O_NONBLOCK flag in
uv_pipe_open (as long as the handle never gets passed to uv_spawn), the
NT kernel is not capable of enabling OVERLAPPED operation later (but
fortunately, it also cannot disable it later too).

This implementation might be good to copy to unix (using FIONREAD) to
address the same bug that happens there if the user has called uv_spawn
or uv_stream_set_non_blocking on this handle in the past.
2024-08-22 11:08:08 -04:00
Santiago Gimeno
5cc7175514
doc: document specific macOS fs_event behavior (#4503) 2024-08-17 13:44:37 +02:00
握猫猫
3e1733a053
doc: properly label enumerations and types (#4506) 2024-08-16 19:30:06 +02:00
握猫猫
8809d1df8d
doc: fix the uv_*_set_data series of functions
They have no return value.
2024-08-16 09:13:42 +02:00
握猫猫
1790abb3b2
doc: document uv_loop_option 2024-08-15 11:01:20 +02:00
Shelley Vohr
31d9165999
win: remove deprecated GetVersionExW call (#4486) 2024-08-15 00:47:57 +02:00
Andy Pan
27134547ff kqueue: use EVFILT_USER for async if available
Establishes a user event for kqueue to eliminate the overhead
of the pipe and the system call read(2) per wakeup event.

---------

Signed-off-by: Andy Pan <i@andypan.me>

Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2024-08-13 09:18:24 +02:00
Ben Noordhuis
1eac3310ad
linux: support abstract unix socket autobinding (#4499)
Autobinding is a feature that lets the kernel pick a name for the
abstract socket, instead of userspace having to provide one.

Two bugs that this change exposed are also fixed:

1. strlen(sa.sun_path) can read past the end if the file path is exactly
   sizeof(sa.sun_path) long (use memchr instead), and

2. don't return UV_ENOBUFS for abstract sockets when the buffer is
   exactly large enough to hold the result; per commit e5f4b79809,
   abstract socket names are not zero-terminated
2024-08-10 21:04:09 +02:00
Santiago Gimeno
a53e7877e4
unix,fs: silence -Wunused-result warning (#4496) 2024-08-10 11:08:39 +02:00
Richard Lau
c84a2dbe03 test: check for UV_CHANGE or UV_RENAME event
All other checks for `UV_RENAME` in `test-fs-event` also allow
`UV_CHANGE`.
2024-08-08 12:03:25 +01:00
Richard Lau
88ab6e78da test: rmdir can return EEXIST or ENOTEMPTY
POSIX allows `rmdir` to return `EEXIST` or `ENOTEMPTY` for a non-empty
directory, so the test needs to allow both.
2024-08-08 12:03:25 +01:00
Matheus Izvekov
5537d6a689
win: fix fs.c ubsan failure (#4491)
Refactor / cleanup arithmetic for unix -> win filetime conversion
in order to avoid multiplication overflow.

Fixes:
```
src/win/fs.c:106:48: runtime error: signed integer overflow: 1702781567 * 10 cannot be represented in type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/fs.c:106:48 in
```

Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2024-08-07 17:01:07 +02:00
Santiago Gimeno
e78e29c231
linux: disable SQPOLL io_uring by default (#4492)
The SQPOLL io_uring instance wasn't providing consistent behaviour to
users depending on kernel versions, load shape, ... creating issues
difficult to track and fix. Don't use this ring by default but allow
enabling it by calling `uv_loop_configure()` with
`UV_LOOP_ENABLE_IO_URING_SQPOLL`.
2024-08-06 22:10:13 +02:00
Matheus Izvekov
9b3b61f606
build: ubsan fixes (#4254)
MSVC does not actually support ubsan. There is a long-standing ticket
requesting this:
https://developercommunity.visualstudio.com/t/add-support-for-ubsan/840750

There are no known compilers that currently accept the
`/fsanitize=undefined` spelling. clang-cl accepts `-fsanitize...`,
same as regular clang.

Also passes no-sanitizer-recover so that tests actually fail.

Fix various ubsan-detected errors, including:

* win: fix req-inl.h ubsan failure

Don't use CONTAINING_RECORD macro from WinSDK, as it doesn't use the
right trick which avoids member access on null pointer.

Fixes:
```
src/win/req-inl.h:86:10: runtime error: member access within null pointer of type 'uv_req_t' (aka 'struct uv_req_s')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior D:/a/libuv/libuv/src/win/req-inl.h:86:10
```

* test: fix ubsan failure on udp_ref3

Don't call functions through different function type.

Fixes:
```
src/win/udp.c:537:5: runtime error: call to function req_cb through pointer to incorrect function type 'void (*)(struct uv_udp_send_s *, int)'
test\test-ref.c:66: note: req_cb defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/udp.c:537:5 in
```

* win: fix process-stdio.c ubsan failure

When accessing HANDLEs within the stdio buffer, use memcpy / memset in order to respect alignment.

Fixes:
```
src/win/process-stdio.c:197:5: runtime error: store to misaligned address 0x0230ee72d107 for type 'HANDLE' (aka 'void *'), which requires 8 byte alignment
0x0230ee72d107: note: pointer points here
  00 00 cd cd cd  cd cd cd cd cd cd cd cd  cd cd cd cd cd cd cd cd  cd cd cd cd cd cd cd fd  fd fd fd
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/process-stdio.c:197:5 in
```

* win: fix getaddrinfo.c ubsan failure

Reworks buffer alignment handling to respect requirements.

Fixes:
```
src/win/getaddrinfo.c:157:23: runtime error: member access within misaligned address 0x0290e4c6a17c for type 'struct addrinfo', which requires 8 byte alignment
0x0290e4c6a17c: note: pointer points here
  00 00 00 00 cd cd cd cd  cd cd cd cd cd cd cd cd  cd cd cd cd cd cd cd cd  cd cd cd cd cd cd cd cd
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/getaddrinfo.c:157:23 in
```

* win: fix pipe.c ubsan failure

Changes "random" representation from pointer to number.

Fixes:
```
src/win/pipe.c:234:11: runtime error: applying non-zero offset to non-null pointer 0xffffffffffffffff produced null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/pipe.c:234:11 in
```

* unix: fix stream.c ubsan failure

Avoids performing pointer arithmetic on null pointer.

Fixes:
```
src/unix/stream.c:701:15: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/runner/work/libuv/libuv/src/unix/stream.c:701:15 in
```
2024-08-05 17:15:53 -04:00
Jameson Nash
a6a987c0de
win,signal: fix data race dispatching SIGWINCH (#4488)
The Event should be reset before reading the value, or libuv might miss
an update that occurred too rapidly after the previously one.

Refs: https://github.com/libuv/libuv/pull/2381
Refs: https://github.com/libuv/libuv/discussions/4485
2024-08-05 16:32:31 -04:00
Jameson Nash
727ee7237e
win,pipe: fix race with concurrent readers (#4470)
This fixes a race condition if multiple threads are reading from the
same NamedPipe, which could previously lead to a deadlock situation. We
also substantially improve performance now also, since the PeekFile
call is unnecessary overhead with this change. This API was added in
Windows Vista.

Related to #4467, though doesn't address any of the problems there. I
believe that someone could now implement uv__pipe_try_write using
this same code pattern however.
2024-08-02 10:50:32 -04:00
Hüseyin Açacak
4e310d0f90
win,fs: use the new Windows fast stat API (#4327)
Windows added a new API for file information, which doesn't have to
open the file thus greatly improving performance:
https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getfileinformationbyname

The stat functions are already covered by tests, so no test was added
here. I considered comparing the result of old and new code, but that
would require exposing internal fs functions, and we would be testing
Windows functionality, not libuv.
2024-07-30 08:58:41 -04:00
Abdirahim Musse
f23037fe21
test: pipe_overlong_path handle ENAMETOOLONG 2024-07-30 08:07:52 +02:00
Andy Pan
e5cb1d3d3d
linux: eliminate a read on eventfd per wakeup (#4400)
Register the eventfd with EPOLLET to enable edge-triggered notification
where we're able to eliminate the overhead of reading the eventfd via
system call on each wakeup event.

When the eventfd counter reaches the maximum value of the unsigned 64-bit,
which may not happen for the entire lifetime of the process, we rewind the
counter and retry.

This optimization saves one system call on each event-loop wakeup,
eliminating the overhead of read(2) as well as the extra latency
for each epoll wakeup.
2024-07-29 19:59:41 -04:00
dependabot[bot]
63b22be083
ci: bump actions/checkout to 4 (#4474)
Held back one due to https://github.com/libuv/libuv/pull/4451
2024-07-29 19:54:23 -04:00
Santiago Gimeno
badecdca14
fsevents: detect watched directory removal (#4376)
Which was broken both in `windows` and `macos`.
2024-07-30 00:59:38 +02:00
Hüseyin Açacak
83306585ff
win: fix env var in uv_os_homedir and uv_os_tmpdir (#4464)
If the corresponding environment variables are empty, the
uv_us_homedir() and uv_os_tmpdir() return garbage values. The reason
for this situation is the Windows API which doesn't return an error
even if the path is empty.

This PR fixes this problem by checking the return value of the API
call. If it is not an error and the length of the value is less than 3,
uv_us_homedir() and uv_os_tmpdir() will return UV_ENOENT.

Fixes: https://github.com/libuv/libuv/issues/2328
2024-07-29 17:50:11 -04:00
Ian Butterworth
18266a6969
win,fs: use posix delete semantics, if supported (#4318)
Implements posix delete for files and dirs, with fallback to the old
method if not supported (e.g. Fat32 or Win8).

Fixes: #3839
2024-07-29 17:38:26 -04:00
Ben Noordhuis
0c36b16d1b
test,openbsd: remove superfluous ifdef guard (#4461)
The test is skipped in its entirety on OpenBSD so there is no point in
compiling out code on said platform later on, it's not run anyway.
2024-07-29 16:45:31 -04:00
Viacheslav Muravyev
e4d47c5357
misc: remove splay trees macros (#4469) 2024-07-29 16:45:12 -04:00
Ben Noordhuis
593aa3b2f6
test: handle zero-length udp datagram (#4344)
Under rare but benign circumstances (on XNU), incoming datagrams appear
to be dropped by the operating system after libuv has been notified of
their arrival but before libuv has had a chance to receive them.

Fixes: https://github.com/libuv/libuv/issues/4219
2024-07-29 16:30:08 -04:00
Jameson Nash
47c833675b
win,error: remap ERROR_NO_DATA to EAGAIN (#4471)
This was incorrectly mapped originally, which makes for confusing error
messages about an EPIPE if a program happens to (unwisely) set PIPE_WAIT
on the handle. It is unclear to me if libuv should try to handle this in
some meaningful way, and very unclear what that way would look like, but
at least expose this to the caller with the correct errno translation.
2024-07-29 16:16:49 -04:00
dependabot[bot]
372e4c645e
ci: bump KyleMayes/install-llvm-action from 1 to 2 (#4472) 2024-07-29 16:15:23 -04:00
dependabot[bot]
6ab153cf8e
ci: bump actions/setup-python from 4 to 5 (#4475) 2024-07-29 16:13:46 -04:00
dependabot[bot]
9678211c24
ci: bump upload and download-artifact versions (#4473) 2024-07-29 16:13:00 -04:00
zeertzjq
5d1ccc12c4
doc: correct names of Win32 APIs in fs.rst (#4408)
The docs there link to GetFinalPathNameByHandleA() and CreateFileA(),
but src/win/fs.c uses GetFinalPathNameByHandleW() and CreateFileW().
2024-07-25 12:29:01 -04:00
Jameson Nash
f56f21d7da
Create dependabot.yml for updating github-actions (#4450) 2024-07-25 12:22:22 -04:00
郑苏波 (Super Zheng)
ecc11611d3 darwin: fix crash on iOS(arm64)
Disable sendfile() on iOS with arm64 architecture
to avoid crashes caused by throwing SIGSYS signal.

Fixes: #3187
2024-07-25 12:52:35 +02:00
Saúl Ibarra Corretgé
f279d9e6c6 ci: use macOS 12 for macOS and iOS builds
macOS 11 is gone: https://github.com/actions/runner-images/pull/10198
2024-07-18 13:25:43 +02:00
Olivier Valentin
ae6e146775
hurd: stub uv_thread_setpriority() 2024-07-18 11:33:39 +02:00
Olivier Valentin
90648ea3e5
hurd: add includes and macro prerequisites
- ptsname() needs _XOPEN_SOURCE >= 500
- setenv needs _POSIX_C_SOURCE >= 200112
- setgroups needs grp.h
2024-07-16 22:34:02 +02:00
Ben Noordhuis
2780b87d56
unix,win: export wtf8 functions properly (#4437)
Mark them UV_EXTERN so they are visible on Windows.

Fixes: https://github.com/libuv/libuv/issues/4436
2024-07-12 10:22:26 +02:00
Ben Noordhuis
e37539a46c
build: fix android ci build (#4451)
It's complaining in the post-run step about a missing symbol:

    /__e/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version
    `GLIBC_2.28' not found (required by /__e/node20/bin/node)

For now pin actions/checkout to node 16.
2024-07-11 22:22:27 +02:00
Viacheslav Muravyev
7c491bde32
unix,win: remove unused req parameter from macros (#4435)
Remove the unused `req` parameter from the uv__req_register and
uv__req_unregister macros.
2024-07-11 21:29:15 +02:00
Uilian Ries
6621fe045a
doc: add instruction how to install with Conan (#4432)
Update the README file with instructions on how
to install libuv through the Conan package manager.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
2024-07-11 21:08:48 +02:00
Hüseyin Açacak
36f0789d83
win: map ERROR_BAD_EXE_FORMAT to UV_EFTYPE (#4445)
CreateProcessW() in uv_spawn() on Windows will fail with
ERROR_BAD_EXE_FORMAT if attempting to run a file that is not
an executable.

Refs: https://github.com/libuv/libuv/issues/2348
2024-07-11 20:41:14 +02:00
Andy Pan
fedfa9893e tcpkeepalive: distinguish OS versions and use proper time units
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-06-27 12:45:51 +02:00
Andy Pan
ba24986f8d
unix: support SO_REUSEPORT with load balancing for UDP (#4419)
Signed-off-by: Andy Pan <i@andypan.me>
2024-06-20 17:17:17 +02:00
Jeffrey H. Johnson
eb5af8e3c0
aix,ibmi: fix compilation errors in fs_copyfile (#4404)
On IBM AIX (and PASE for IBM i), use st_timespec_t
when _XOPEN_SOURCE>=700 and _ALL_SOURCE is defined.

Signed-off-by: Jeffrey H. Johnson <trnsz@pobox.com>
2024-05-30 22:31:15 +02:00
Andy Pan
1ee1063402
test: fix the flaky test-tcp-reuseport
Start connecting to the peers after all threads
to poll for accepting connections.

Ref: #4407
2024-05-30 09:53:44 +02:00
Juan José Arboleda
541329d51f doc: add entries for extended getpw
This patch adds documentation for the introduced `uv_os_get_passwd2`,
`uv_os_get_group`, `uv_os_free_group` methods in
https://github.com/libuv/libuv/pull/3523

Fixes: https://github.com/libuv/libuv/issues/4007
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-05-28 17:04:30 +02:00
Andy Pan
d2d92b74a8
unix: support SO_REUSEPORT with load balancing for TCP 2024-05-21 13:36:49 +02:00
Andy Pan
c8d4a87f49
bsd: support pipe2() on *BSD (#4412)
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-05-21 10:07:38 +02:00
Andy Pan
ab3ecf6565 unix: use the presence of SOCK_* instead of OS macros for socketpair
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-05-21 09:41:03 +02:00
Andy Pan
287987b37c test: remove the obsolete HAVE_KQUEUE macro
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-05-21 09:40:07 +02:00
Andy Pan
10ccd08471
dragonfly: disable SO_REUSEPORT for UDP socket bindings (#4410)
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-05-20 12:36:41 +02:00
Juan José
bf61390769
linux,darwin: make uv_fs_copyfile behaves like cp -r (#4396)
This commit changes the timestamps in the file, the ownership and the
group.

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

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-05-08 11:30:30 +02:00
josedelinux
520eb622f0
doc: fix some typos 2024-04-26 13:57:26 +02:00
Saúl Ibarra Corretgé
497f3168d1 win: remove no longer needed define
Windows 7 is no longer supported.
2024-04-22 20:39:20 +02:00
Saúl Ibarra Corretgé
8083ab26e0 mailmap: update saghul's main email address 2024-04-15 16:12:10 +02:00
Saúl Ibarra Corretgé
c0a61c3bb3 darwin: simplify uv_hrtime
mach_continuous_time is available since macOS 10.12, but our minimum
version is 11, so no need for a workaround.

Also, prefer that to `clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW)` which
the documentation suggests
(https://developer.apple.com/documentation/driverkit/3438077-mach_continuous_time)
since the latter calls mach_timebase_info every time, unnecessarify: 49dcc07a40/Libc/gen/clock_gettime.c (L107)
2024-04-15 16:12:10 +02:00
Brad King
f50ae53c42
unix: de-duplicate conditions for using kqueue (#4378)
Our platform-specific headers provide a dedicated indicator.
2024-04-14 11:13:21 +02:00
Ben Noordhuis
17219b8f39
test: use newer ASSERT_MEM_EQ macro (#4346)
Should hopefully make it easier to debug CI flakiness because
currently the test sometimes fails without a clear indication why.

Refs: https://github.com/libuv/libuv/issues/4106
2024-03-31 17:27:04 +02:00
Ben Noordhuis
46c0e1769b
win: robustify uv_os_getenv() error checking (#4339)
Make it less likely for the thread-local error value to get
clobbered between performing the operation and checking the result.

Refs: https://github.com/libuv/libuv/issues/4338
2024-03-31 17:25:13 +02:00
Ben Noordhuis
4fce06ec96
unix: fix fd leaks in SCM_RIGHTS error path (#4358)
The file descriptor leak in the inner path was pointed out by @theanarkh
and I subsequently spotted another one in the outer loop. Rewrite the
function to process all control messages.

Refs: https://github.com/libuv/libuv/pull/4357
2024-03-25 12:45:40 +01:00
Ben Noordhuis
77e4cd5b18
linux: don't use sendmmsg() for single datagrams (#4366)
Benchmarking shows that sendmsg() is persistently around 1% faster for
single datagrams, and that kind of stands to reason because there is
less setup overhead, and the kernel has to copy in less data.

Fixes: https://github.com/libuv/libuv/issues/4320
2024-03-25 12:45:23 +01:00
Ben Noordhuis
d05ed869bb
doc: correct udp socket options documentation (#4371)
uv_udp_init() creates the UDP socket lazily but to set socket options
there must be, well, a socket to set the options on. Document how and
when that requirement is met.

Fixes: https://github.com/libuv/libuv/issues/4370
2024-03-25 12:44:52 +01:00
Saúl Ibarra Corretgé
abc9767034
win: simplify uv_once implementation
* win: simplify uv_once implementation

InitOnceExecuteOnce is available in Windows >= Vista.

Ref: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initonceexecuteonce
2024-03-25 11:57:52 +01:00
Saúl Ibarra Corretgé
6adeeacee7
unix,win: error on zero delay tcp keepalive
Closes: https://github.com/libuv/libuv/pull/4350
Closes: https://github.com/libuv/libuv/issues/3487
2024-03-22 22:11:23 +01:00
tgolang
f55628eed0
doc: fix typos in ChangeLog (#4355)
Signed-off-by: tgolang <seekseat@aliyun.com>
2024-03-22 20:10:41 +01:00
Ben Noordhuis
3ecce91410
linux: don't delay EPOLL_CTL_DEL operations (#4328)
Perform EPOLL_CTL_DEL immediately instead of going through
io_uring's submit queue, otherwise the file descriptor may
be closed by the time the kernel starts the operation.

Fixes: https://github.com/libuv/libuv/issues/4323
2024-03-21 09:23:08 +01:00
Ben Noordhuis
cc23e204d7
unix: reinstate preadv/pwritev fallback code (#4345)
I removed the fallback code back in October but it prevents Node.js
from upgrading libuv in their v20.x release line because they support
systems older than we do. Bring back a dlsym-based fallback path.

Fixes: https://github.com/libuv/libuv/issues/4332
2024-03-20 18:39:18 +01:00
Ben Noordhuis
e0c5fc8714
win: remove _alloca usage (#4361)
Remove it since it can cause stack overflows. Use heap allocation
instead.

Fixes: https://github.com/libuv/libuv/issues/4348
2024-03-20 12:09:37 +01:00
Ben Noordhuis
91ba13054a
test,ci: fix [AM]San, disable ASLR (#4365)
The kernel that ships with the new Ubuntu 22.04 CI image seems to have a
PIE slide that is bigger than the sanitizer runtimes can handle.

It makes ASan fail with thousands of "AddressSanitizer:DEADLYSIGNAL"
warnings, and MSan error with complaints about memory accesses outside
known ranges. Disabling address space layout randomization fixes both.

This commit also fixes a small bug in the platform_output test where
the cgroups v1 logic did not handle the "unlimited quota" special case
properly. Ubuntu 20.04 still uses cgroups v1.
2024-03-17 15:53:23 +01:00
Farzin Monsef
b0816180e3
linux: fix /proc/self/stat executable name parsing (#4353)
- The filename of the executable may contain both spaces and parentheses
- Use uv__slurp instead of open/read/close
2024-03-14 09:35:25 +01:00
Andy Pan
fa6745b4f2
sunos: sync tcp keep-alive with other unices (#4337) 2024-03-12 11:16:49 +01:00
Saúl Ibarra Corretgé
6912038d72 unix,fs: fix realpath calls that use the system allocator
Make sure we allocate the memory with uv__malloc so it's in turn freed
with uv__free.

Fixes: https://github.com/libuv/libuv/issues/4329
2024-03-08 10:08:48 +01:00
Ben Noordhuis
2c15345016
test: disable env var test under win32+asan (#4342)
The test hits an honest-to-$deity compiler runtime bug, see the
investigation in the linked issue.

Fixes: https://github.com/libuv/libuv/issues/4338
2024-03-07 09:46:57 +01:00
Santiago Gimeno
ff9587991f
win: almost fix race detecting ESRCH in uv_kill (#4341)
It might happen that only using `WaitForSingleObject()` with timeout 0
could return WAIT_TIMEOUT as the process might not have been signaled
yet. To improve things, first use `GetExitCodeProcess()` and check
that `status` is not `STILL_ACTIVE`. Then, to cover for the case that the exit
code was actually `STILL_ACTIVE` use `WaitForSingleObject()`. This could
still be prone to the race condition but only for that case.
2024-03-05 21:20:50 +01:00
Farzin Monsef
625d3d275a
cygwin: implement uv_resident_set_memory (#4333)
According to the documentation for Cygwin, the penultimate field
of /proc/pid/stat corresponds to the RSS, so the method is basically
the same as in the Linux version. The only difference is that getpagesize()
will return wincap.allocation_granularity(), but in this mapping, RSS is
calculated using wincap.page_size(), which can be accessed by sysinfo.mem_unit.
2024-03-02 11:24:57 +01:00
Geddy
a7c44d6748
udp,unix: fix sendmsg use-after-free (#4321)
Issue:
1. uv__io_poll calls uv__udp_io with revents == POLLIN + POLLOUT
2. uv__udp_io calls your recv_cb
3. you close the handle in callback
4. uv__udp_io calls uv__udp_sendmsg
5. uv__udp_sendmsg calls uv__io_feed
6. kaboom!
2024-02-28 17:32:43 -05:00
hiiizxf
e8458b2402
doc: fix tty example segfault (#4322)
Fixes: https://github.com/libuv/libuv/issues/4303
2024-02-28 12:32:24 +01:00
Thomas Walter
6b56200cc8
linux: fix uv_available_parallelism using cgroup (#4278)
uv_available_parallelism does not handle container cpu limit
set by systems like Docker or Kubernetes. This patch fixes
this limitation by comparing the amount of available cpus
returned by syscall with the quota of cpus available defined
in the cgroup.

Fixes: https://github.com/libuv/libuv/issues/4146
2024-02-28 12:23:23 +01:00
Jameson Nash
cc9e96147f
misc: run sample CI when code changes (#4324) 2024-02-23 14:15:03 -05:00
Ben Noordhuis
507f3046d1
linux: create io_uring sqpoll ring lazily (#4315)
It's been reported that creating many event loops introduces measurable
overhead now that libuv creates an sqpoll-enabled ring.

I don't really see any change in CPU time with or without this change
but deferring ring creation until it's actually used seems like a good
idea, and comes with no downsides that I can think of, so let's do it.

Fixes: https://github.com/libuv/libuv/issues/4308
2024-02-14 11:20:44 +01:00
Anthony Alayo
7b9e37c7da
build: add alias for libuv to CMakeLists.txt (#4297)
Fixes: https://github.com/libuv/libuv/issues/4282
2024-02-09 21:08:24 +01:00
Ben Noordhuis
009d7414bc
test: fix -Wpointer-to-int-cast on 32 bits systems (#4309)
The return value from signal(2) is a pointer. Use the right macro.
2024-02-09 19:17:20 +01:00
Santiago Gimeno
08a1e7fd23
Now working on version 1.48.1
Fixes: https://github.com/libuv/libuv/issues/4248
2024-02-07 22:44:52 +01:00
Santiago Gimeno
99e576612d Add SHA to ChangeLog 2024-02-07 21:20:12 +01:00
Santiago Gimeno
e9f29cb984 2024.02.07, Version 1.48.0 (Stable)
Changes since version 1.47.0:

* misc: remove deprecated stalebot file (Jameson Nash)

* build: disable windows asan buildbot (Ben Noordhuis)

* test: don't run tcp_writealot under msan (Ben Noordhuis)

* build,win: remove extraneous -lshell32 (Ben Noordhuis)

* unix: ignore ifaddrs with NULL ifa_addr (Stephen Gallagher)

* unix,win: utility for setting priority for thread (Hao Hu)

* pipe: add back error handling to connect / bind (Jameson Nash)

* test: check if ipv6 link-local traffic is routable (Ben Noordhuis)

* win: remove check for UV_PIPE_NO_TRUNCATE (Jameson Nash)

* linux: disable io_uring on hppa below kernel 6.1.51 (matoro)

* unix,win: fix read past end of pipe name buffer (Ben Noordhuis)

* unix: unbreak macOS < 10.14 (Sergey Fedorov)

* aix: disable ipv6 link local (Abdirahim Musse)

* doc: move cjihrig to emeriti (cjihrig)

* unix: correct pwritev conditional (Bo Anderson)

* test_fs.c: Fix issue on 32-bit systems using btrfs (Stephen Gallagher)

* misc: ignore libuv-release-tool files (Jameson Nash)

* win: honor NoDefaultCurrentDirectoryInExePath env var (Ardi Nugraha)

* idna: fix compilation warning (Saúl Ibarra Corretgé)

* linux: remove HAVE_IFADDRS_H macro (Ben Noordhuis)

* test: skip tcp-write-in-a-row on IBM i (Abdirahim Musse)

* build,win: work around missing uuid.dll on MinGW (Anton Bachin)

* win: stop using deprecated names (Matheus Izvekov)

* unix,win: fix busy loop with zero timeout timers (Matheus Izvekov)

* aix,ibmi: use uv_interface_addresses instead of getifaddrs (Abdirahim
  Musse)

* linux: fix bind/connect for abstract sockets (Santiago Gimeno)

* win: replace c99 comments with c89 comments (Trevor Flynn)

* build: add .cache clangd folder to .gitignore (Juan José Arboleda)

* unix: support full TCP keep-alive on Solaris (Andy Pan)

* freebsd: fix F_KINFO file path handling (David Carlier)

* linux: retry fs op if unsupported by io_uring (Santiago Gimeno)

* freebsd: fix build on non-intel archs (David Carlier)

* unix: optimize uv__tcp_keepalive cpp directives (Andy Pan)

* linux: disable io_uring on ppc64 and ppc64le (Brad King)

* doc: add very basic Security Policy document (Santiago Gimeno)

* build: re-enable msvc-asan job on CI (Jameson Nash)

* win/spawn: optionally run executable paths with no file extension
  (Brad King)

* win: fix ESRCH implementation (Jameson Nash)

* unix,win: reset the timer queue on stop (Santiago Gimeno)

* fix: always zero-terminate idna output (Ben Noordhuis)

* fix: reject zero-length idna inputs (Ben Noordhuis)

* test: empty strings are not valid IDNA (Santiago Gimeno)

* Merge pull request from GHSA-f74f-cvh7-c6q6 (Ben Noordhuis)
2024-02-07 20:20:07 +00:00
Ben Noordhuis
c858a14764
Merge pull request from GHSA-f74f-cvh7-c6q6
* fix: always zero-terminate idna output

* fix: reject zero-length idna inputs

* test: empty strings are not valid IDNA

---------

Co-authored-by: Santiago Gimeno <santiago.gimeno@gmail.com>
2024-02-07 20:53:55 +01:00
Santiago Gimeno
e0327e1d50
test: empty strings are not valid IDNA
Fixes: https://github.com/libuv/libuv/security/advisories/GHSA-f74f-cvh7-c6q6
2024-02-07 20:50:13 +01:00
Ben Noordhuis
3530bcc303
fix: reject zero-length idna inputs
Fixes: https://github.com/libuv/libuv/security/advisories/GHSA-f74f-cvh7-c6q6
2024-02-07 20:50:04 +01:00
Ben Noordhuis
0f2d7e784a
fix: always zero-terminate idna output
Fixes: https://github.com/libuv/libuv/security/advisories/GHSA-f74f-cvh7-c6q6
2024-02-07 20:49:53 +01:00
Santiago Gimeno
bb6fbcf6e7
unix,win: reset the timer queue on stop (#4304)
As there were instances where this didn't happen and could cause memory
corruption issues.

Refs: https://github.com/libuv/libuv/issues/4248
2024-02-07 10:43:29 +01:00
Santiago Gimeno
10f313631c
Revert "unix: restore signal disposition to previous one (#4216)" (#4302)
This reverts commit b9421d7066.

Refs: https://github.com/libuv/libuv/issues/4299
Refs: https://github.com/libuv/libuv/issues/4248
2024-02-06 07:52:21 +01:00
Jameson Nash
129362f356
win: fix ESRCH implementation (#4301)
Per documentation, this was the wrong way to test for ESRCH. This hopefully
fixes it.

Fixes: https://github.com/libuv/libuv/issues/4300
2024-02-05 21:24:07 +01:00
Brad King
3f7191e5c2
win/spawn: optionally run executable paths with no file extension (#4292)
Add a process options flag to enable the optional behavior. Most users
are likely recommended to set this flag by default, but it was deemed
potentially breaking to set it by default in libuv.

Co-authored-by: Kyle Edwards <kyle.edwards@kitware.com>
2024-02-05 11:04:05 -05:00
Jameson Nash
535efdf319
build: re-enable msvc-asan job on CI (#4289) 2024-01-21 10:44:34 -05:00
Santiago Gimeno
f98516ddd5
doc: add very basic Security Policy document (#4290) 2024-01-19 19:09:39 +01:00
Brad King
3b6a1a14ca
linux: disable io_uring on ppc64 and ppc64le (#4285)
Since `io_uring` support was added, libuv's signal handler randomly
segfaults on ppc64 when interrupting `epoll_pwait`.  Disable it
pending further investigation.

Issue: https://github.com/libuv/libuv/issues/4283
2024-01-13 12:04:01 +01:00
Andy Pan
a7cbda92b6
unix: optimize uv__tcp_keepalive cpp directives (#4275)
Reduce the amount of code being compiled and trim trailing whitespace in
passing.
2024-01-12 11:54:51 +01:00
David CARLIER
a407b232f0
freebsd: fix build on non-intel archs (#4276)
KINFO_FILE_SIZE is only defined on Intel archs.

Fixes: https://github.com/libuv/libuv/issues/4274
2024-01-09 11:10:35 +01:00
Santiago Gimeno
160cd5629e
linux: retry fs op if unsupported by io_uring (#4268)
Fallback to the threadpool if it returns `EOPNOTSUPP`.

Fixes: https://github.com/nodejs/node/issues/50876
2024-01-08 22:25:44 +01:00
David CARLIER
7d092913b3
freebsd: fix F_KINFO file path handling (#4256)
The new F_KINFO flag does not seem to work with directories nor with
deleted entries.

Fixes: https://github.com/libuv/libuv/issues/4255
2024-01-07 12:58:32 +01:00
Andy Pan
a9381cdb03
unix: support full TCP keep-alive on Solaris (#4272)
Solaris claimed it supported the TCP-Alives mechanism,
but TCP_KEEPIDLE, TCP_KEEPINTVL, and TCP_KEEPCNT were not
available on Solaris until the latest version 11.4.
Therefore, we need to simulate the TCP-Alives mechanism on
other platforms via TCP_KEEPALIVE_THRESHOLD + TCP_KEEPALIVE_ABORT_THRESHOLD.
2024-01-06 10:46:47 +01:00
Juan José
e72a91e063
build: add .cache clangd folder to .gitignore (#4257)
The clangd index, before creating the `compile_commands.json` file will
create the indexes under a `.cache` folder. This does not need to be
tracked by the repo.

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-01-05 10:38:15 +01:00
Trevor Flynn
64bd28f5ba
win: replace c99 comments with c89 comments (#4270) 2024-01-05 10:34:33 +01:00
Santiago Gimeno
1dd0ab1315
linux: fix bind/connect for abstract sockets (#4266)
The `\0` character has no special significance in abstract sockets, so
the addrlen field in both `bind()` and `connect()` should take that into
account.
2023-12-25 23:35:14 +01:00
Abdirahim Musse
8861a97efa
aix,ibmi: use uv_interface_addresses instead of getifaddrs (#4222)
AIX and IBM i don't have getifaddrs but we do have code in
`uv_interface_addresses` to get the interface addresses.

Refs: https://github.com/libuv/libuv/issues/4117
2023-12-23 00:58:49 +01:00
Matheus Izvekov
51a22f60d6
unix,win: fix busy loop with zero timeout timers (#4250)
Calling `uv_timer_start(h, cb, 0, 0)` from a timer callback resulted in
the timer running immediately because it was inserted at the front of
the timer heap.

If the callback did that every time, libuv would effectively busy-loop
in `uv__run_timers()` and never make forward progress.

Work around that by collecting all expired timers into a queue and only
running their callback afterwards.

Fixes: https://github.com/libuv/libuv/issues/4245
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
2023-12-22 12:40:50 +01:00
Matheus Izvekov
8a499e1331
win: stop using deprecated names (#4253) 2023-12-22 12:30:48 +01:00
Anton Bachin
34db4c21b1
build,win: work around missing uuid.dll on MinGW (#4261) 2023-12-20 14:27:13 +01:00
Abdirahim Musse
1479b76310
test: skip tcp-write-in-a-row on IBM i (#4197)
On IBM i this test fails asserting the write queue size.
The test expects the queue size to be greater than 0 but
the queue size is 0 on IBM i.

66160d6973/test/test-tcp-write-in-a-row.c (L75)

The test expects the write to get queued because the size of the data
is larger than the send and receive buffers.

66160d6973/test/test-tcp-write-in-a-row.c (L39-L40)

For some reason the request does not seem to get queued on IBM i.
The root cause of the issue will need further investigation.

Part of #4143
2023-12-12 15:19:02 -05:00
Ben Noordhuis
a7d5255122
linux: remove HAVE_IFADDRS_H macro (#4243)
Introduced long ago for old Linux/libc flavors libuv no longer supports.

We include <ifaddrs.h> unconditionally elsewhere so there is no point in
special-casing it here.

Fixes: https://github.com/libuv/libuv/issues/4242
2023-12-12 15:13:31 -05:00
Saúl Ibarra Corretgé
12bd89bbc3 idna: fix compilation warning
w_target_len is set but unsued in release mode.
2023-12-11 09:42:18 +01:00
Ardi Nugraha
5e302730cd
win: honor NoDefaultCurrentDirectoryInExePath env var (#4238)
Fixes: https://github.com/libuv/libuv/issues/3888
Refs: https://github.com/nodejs/node/issues/46264
2023-11-30 22:54:41 +01:00
Jameson Nash
a5c01d4de3
misc: ignore libuv-release-tool files (#4201) 2023-11-24 11:22:25 +01:00
Stephen Gallagher
de43f42735
test_fs.c: Fix issue on 32-bit systems using btrfs (#4227)
On Fedora's build system, the build environment runs on btrfs. This
revealed a bug in the test on i686 systems, where this comparison was
being performed as a comparison of two signed integers, but the
filesystem type of btrfs happens to use the higher-order bits, resulting
in it appearing as a negative value.

BTRFS_SUPER_MAGIC     0x9123683e

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2023-11-24 11:18:51 +01:00
Bo Anderson
fc70430b09
unix: correct pwritev conditional (#4233) 2023-11-24 11:17:52 +01:00
Colin Ihrig
7ba94d3909
doc: move cjihrig to emeriti (#4234) 2023-11-19 08:47:23 -05:00
Abdirahim Musse
bfbe4e38d7
aix: disable ipv6 link local (#4229)
AIX does not implement ifaddrs and when retrieving the network
interfaces with uv_interface_addresses there was a test failure in
tcp_connect6_link_local.

For now disable ipv6 link local on aix to:

1) fix broken aix build
2) stop blocking libuv upgrade in node

Refs: https://github.com/libuv/libuv/pull/4222#issuecomment-1812962233
Refs: https://github.com/nodejs/node/pull/50650
2023-11-18 19:19:16 +01:00
Sergey Fedorov
4785ad6337
unix: unbreak macOS < 10.14 (#4230) 2023-11-18 09:57:40 +01:00
Ben Noordhuis
6be130e1b8
unix,win: fix read past end of pipe name buffer (#4209)
Passing a socket name without a trailing nul byte to uv_pipe_bind2() or
(on Windows) uv_pipe_connect2() resulted in reading beyond the end of
the name buffer when copying or converting it.

Fix that by copying the socket name to temporary storage first and add
the trailing nul byte explicitly.

Add a check for embedded nul bytes in the socket name.

Fix a small memory leak in the Windows error path of uv_pipe_bind2().
2023-11-16 09:05:51 +01:00
matoro
f144429365
linux: disable io_uring on hppa below kernel 6.1.51 (#4224)
First kernel with support is 6.1, was only fully functional from .51
onwards: https://lore.kernel.org/all/cb912694-b1fe-dbb0-4d8c-d608f3526905@gmx.de/

Co-authored-by: matoro <matoro@users.noreply.github.com>
2023-11-15 23:57:06 +01:00
Jameson Nash
35da5ded3b
win: remove check for UV_PIPE_NO_TRUNCATE (#4221)
There is no length at which this gets truncated on Windows. The
underlying file system will just not successfully connect to a longer
path (in WTF-16 characters), which will return an error asynchronously
with the existing API.

Refs: #4040
2023-11-15 15:08:49 +01:00
Viacheslav Muravyev
b9421d7066
unix: restore signal disposition to previous one (#4216)
Fixes: https://github.com/libuv/libuv/issues/2435
2023-11-15 14:39:17 +01:00
Ben Noordhuis
54d8364c24
test: check if ipv6 link-local traffic is routable (#4220)
Fixes: https://github.com/libuv/libuv/issues/4211
2023-11-14 22:09:30 +01:00
Jameson Nash
d843b7cf7f
pipe: add back error handling to connect / bind (#4202)
This was incorrectly dropped by #4030, where previously connecting to ""
might fail eventually, now instead it would return EINVAL and then fail
to initialize the struct or call the callback.
2023-11-14 09:26:53 -05:00
Hao Hu
e135dfe183
unix,win: utility for setting priority for thread (#4075)
Add uv_thread_setpriority for setting priority for threads created by
uv_thread_create. Add uv_thread_getpriority for getting thread priority.

For Linux by default, if the scheduling policy is SCHED_OTHER and the
priority is 0, we need to set the nice value.

Fixes: https://github.com/libuv/libuv/issues/4051
2023-11-14 11:30:46 +01:00
Stephen Gallagher
31e4b90c3c
unix: ignore ifaddrs with NULL ifa_addr (#4218)
Passing this to uv__is_ipv6_link_local() is causing a segmentation
fault. Note that the documentation for getifaddrs() explicitly states
that this value may be NULL.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2023-11-14 10:23:28 +01:00
Ben Noordhuis
874363f652
build,win: remove extraneous -lshell32 (#4213)
I suggested in https://github.com/libuv/libuv/pull/4182 to add the flag
to configure.ac as well but seems we already link to it.

I've removed the first one, not the second one, in case libuv is linked
with --as-needed.
2023-11-13 13:25:41 -05:00
Ben Noordhuis
f01219dfb7
test: don't run tcp_writealot under msan (#4214)
The test is prone to time out at the best of times, never mind when
running under MemorySanitizer.
2023-11-10 20:17:31 +01:00
Ben Noordhuis
f067f50ae4
build: disable windows asan buildbot (#4215)
uv_run_tests.exe fails to start up with exit code 0xC0000135 a.k.a.
STATUS_DLL_NOT_FOUND, suggesting it cannot find the ASAN runtime
libraries. Disable the buildbot until we figure out how to fix that.

Refs: https://github.com/libuv/libuv/issues/4210
2023-11-10 18:56:46 +01:00
Jameson Nash
4107b8d4db
misc: remove deprecated stalebot file (#4199)
Refs: https://github.com/probot/stale/pull/430
2023-11-07 10:53:16 -05:00
Jameson Nash
815693f715 Now working on version 1.47.1
Fixes: https://github.com/libuv/libuv/issues/4186
2023-11-06 13:24:46 -05:00
Jameson Nash
97b7873cba Add SHA to ChangeLog 2023-11-06 13:17:32 -05:00
Jameson Nash
be6b81a352 2023.11.06, Version 1.47.0 (Stable)
Changes since version 1.46.0:

* test: fix license blurb (Ben Noordhuis)

* linux: fix harmless warn_unused_result warning (Shuduo Sang)

* darwin: fix build warnings (小明)

* linux: don't use io_uring on pre-5.10.186 kernels (Ben Noordhuis)

* fs: fix WTF-8 decoding issue (Jameson Nash)

* test: enable disabled tcp_connect6_error_fault (Ben Noordhuis)

* test: enable disabled fs_link (Ben Noordhuis)

* test: enable disabled spawn_same_stdout_stderr (Ben Noordhuis)

* linux: handle UNAME26 personality (Ben Noordhuis)

* build: move cmake_minimum_required version to 3.9 (Keith Winstein)

* unix: set ipv6 scope id for link-local addresses (Ben Noordhuis)

* unix: match kqueue and epoll code (Trevor Norris)

* win,spawn: allow `%PATH%` to be unset (Kyle Edwards)

* doc: switch to Furo, a more modern Sphinx theme (Saúl Ibarra Corretgé)

* darwin: make TCP_KEEPINTVL and TCP_KEEPCNT available (小明)

* win,fs: avoid winapi macro redefinition (Brad King)

* linux: add missing riscv syscall numbers (michalbiesek)

* doc: fix broken "Shared library" Wikipedia link (Alois Klink)

* unix: get mainline kernel version in Ubuntu (Santiago Gimeno)

* unix: get mainline kernel version in Debian (Ben Noordhuis)

* build: fix qemu install in CI-unix workflow (Santiago Gimeno)

* unix: disable io_uring close on selected kernels (Santiago Gimeno)

* test: skip tests when ipv6 is not available (Santiago Gimeno)

* ibmi: implement ifaddrs, getifaddrs, freeifaddrs (Abdirahim Musse)

* unix: reset signal counters after fork (SmorkalovG)

* win,process: avoid assert after spawning Store app (Jameson Nash)

* unix: remove pread/preadv conditionals (Ben Noordhuis)

* unix: remove pwrite/pwritev conditionals (Ben Noordhuis)

* darwin: remove workaround for data corruption bug (Ben Noordhuis)

* src: default to stream=stderr in handle printer (Ben Noordhuis)

* test: switch to new-style ASSERT_EQ macros (Pleuvens)

* zos: correctly get cpu model in uv_cpu_info() (jolai)

* test: fix get_passwd2 on IBM i (Abdirahim Musse)

* unix: don't malloc on sync uv_fs_read (Ben Noordhuis)

* freebsd: get fs event path with fcntl(F_KINFO) (David Carlier)

* test: switch from ASSERT_* to ASSERT_PTR_* (Pleuvens)

* darwin: workaround apple pthread_cond_wait bug (Julien Roncaglia)

* doc: uv_close should be called after exit callback (Pleuvens)

* test: 192.0.2.0/24 is the actual -TEST-NET-1 (prubel)

* unix: add back preadv/pwritev fallback (Ben Noordhuis)

* unix: rename variable for consistency (Ben Noordhuis)

* unix: merge read/write code into single functions (Ben Noordhuis)

* doc: filename arg to uv_fs_event_cb can be NULL (Ben Noordhuis)

* build,win: we need to link against shell32.lib (Per Allansson)

* unix: no preadv/pwritev workaround if not needed (Jeffrey H. Johnson)

* build: add CI for Windows ARM64 (build only) (Per Allansson)

* linux: disable io_uring on 32 bits arm systems (Ben Noordhuis)

* build: run sanitizers on macos ci (Ben Noordhuis)

* misc: export WTF8 conversion utilities (Jameson Nash)

* build: fix libuv.a file name for cmake (Jameson Nash)

* build: add windows ubsan and clang ci (Matheus Izvekov)

* win: improve accuracy of ProductName between arch (Christian Heimlich)
2023-11-06 13:17:17 -05:00
Christian Heimlich
66160d6973
win: improve accuracy of ProductName between arch (#4191)
uv_os_uname() on Windows queries the registry value "HKEY_LOCAL_MACHINE\
SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName" to fill
uv_utsname_t. If calling application was compiled for x86 and run on a
x86_64 host, that query is redirected to "Computer\HKEY_LOCAL_MACHINE\
SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\ProductName"
instead.

For whatever reason, the value of 'ProductName' in the 32-bit registry
section on 64-bit Windows sometimes differs from the 64-bit equivalent
value and is inaccurate (e.g. containing the data
"Windows 10 Enterprise" while the 64-bit value accurately contains
"Windows 10 Pro").

Adds the 'KEY_WOW64_64KEY' security descriptor when opening the
appropriate registry key so that the value of ProductName is always
taken from the primary registry on 64-bit systems, regardless of
compiled architecture. The descriptor is safely ignored on 32-bit hosts.
2023-11-01 02:30:10 +01:00
Matheus Izvekov
93efccf4ee
build: add windows ubsan and clang ci (#4138)
Fixes a detected error: incompatible pointer to integer conversion
passing 'uv_os_fd_t' (aka 'void *') to parameter of type 'SOCKET' (aka
'unsigned long long').

Use upstream llvm to work-around broken VS2022 clang unable to link.
2023-10-30 15:16:57 -04:00
Jameson Nash
77991a0761
build: fix libuv.a file name for cmake (#4185)
This makes cmake more consistent about how to name this file, otherwise
sometimes it names it uv.lib and sometimes libuv.a depending on which
compiler is selected or if ./configure is used.

Refs: https://github.com/libuv/libuv/pull/2085#issuecomment-1735276640
2023-10-28 21:05:42 -04:00
Jameson Nash
f388908593
misc: export WTF8 conversion utilities (#4021)
As promised in #2970, this attempts to migrate code to a common set of
utilities in a common place in the code and use them everywhere. This
also exports the functionality, since the Windows API with
WideCharToMultiByte is fairly verbose relative to what libuv and
libuv's clients typically need, so it is useful not to require clients
to reimplement this conversion logic unnecessarily (and because Windows
is not 64-bit ready here, but this implementation is.)
2023-10-28 21:04:57 -04:00
Ben Noordhuis
56fca44a4b
build: run sanitizers on macos ci (#4189)
Skip three fs_event tests that time out under Thread Sanitizer.
2023-10-28 15:05:42 +02:00
Ben Noordhuis
a389393ffa
linux: disable io_uring on 32 bits arm systems (#4187)
It's been reported that no released kernels are bug-free enough to use
io_uring without causing regressions.

Fixes: https://github.com/libuv/libuv/issues/4158
2023-10-28 13:18:42 +02:00
Per Allansson
7b34154cf2
build: add CI for Windows ARM64 (build only) (#4184) 2023-10-27 18:53:45 -04:00
Jeffrey H. Johnson
da527d8d2a
unix: no preadv/pwritev workaround if not needed (#4180)
The workaround for preadv/pwritev is needed only
for Solaris, not illumos, so avoid it on illumos.

Haiku R1/prebeta5 (and later) provide preadv and
pwritev, so only use workaround on lower versions.

Signed-off-by: Jeffrey H. Johnson <trnsz@pobox.com>
2023-10-26 20:23:36 +02:00
Per Allansson
b8368a1441
build,win: we need to link against shell32.lib (#4182)
The recently added support for minidumps use SHGetKnownFolderPath which
requires shell32.lib - for some reason the builds work without that on
x64, while failing on arm.
2023-10-25 21:48:57 +02:00
Ben Noordhuis
c5f027d6be
doc: filename arg to uv_fs_event_cb can be NULL (#4177)
Refs: https://github.com/libuv/libuv/issues/4160
2023-10-22 11:55:07 +02:00
Ben Noordhuis
9956da1567 unix: merge read/write code into single functions
I split those out in a previous commit in anticipation of changes that
never came. Let's merge them back.
2023-10-22 11:51:35 +02:00
Ben Noordhuis
8ac649e2aa unix: rename variable for consistency
uv__fs_write_do() calls it `r` so call it that in `uv__fs_read_do()`
too.
2023-10-22 11:51:35 +02:00
Ben Noordhuis
8d69f256d1 unix: add back preadv/pwritev fallback
Implement in terms of pread/pwrite and only try to read/write the first
buffer. Callers are supposed to handle partial reads and libuv takes
care of partial writes.

(Our own fs_read_bufs test doesn't but that's fine because this commit
is a fix-up for unsupported platforms that aren't in our CI matrix.)

Fixes: https://github.com/libuv/libuv/issues/4176
2023-10-22 11:51:35 +02:00
prubel
815dd8a25c
test: 192.0.2.0/24 is the actual -TEST-NET-1 (#4133)
Section 3 of rfc 5737 lists 192.0.2.0/24 as TEST-NET-1,
fix confusion about /8 and /24.
2023-10-18 00:24:34 +02:00
Pleuvens
dc1bb0088e
doc: uv_close should be called after exit callback (#4164)
Fixes: https://github.com/libuv/libuv/issues/1911
2023-10-14 13:07:05 +02:00
Julien Roncaglia
197f453b76
darwin: workaround apple pthread_cond_wait bug (#4166)
Under heavy workloads pthread_cond_wait on macOS can return EINVAL while
all the input parameters are correct.

As it happens due to a syscall having an errno of EBUSY we can detect it
and work around it.

Fixes: https://github.com/libuv/libuv/issues/4165
2023-10-13 21:32:46 +02:00
Pleuvens
d8669609d8
test: switch from ASSERT_* to ASSERT_PTR_* (#4163)
Also introduce a new ASSERT_PTR_LT macro.
2023-10-12 20:47:44 +02:00
David CARLIER
004dfd2d4b
freebsd: get fs event path with fcntl(F_KINFO) 2023-10-12 20:43:11 +02:00
Ben Noordhuis
13148457a9
unix: don't malloc on sync uv_fs_read (#4162)
We can use the |bufs| argument directly instead of always copying it
and sometimes heap-allocating it.

The same trick doesn't work for uv_fs_write() because the iterator
mutates the buffers in the list and that's visible to the caller.

Fixes: https://github.com/libuv/libuv/issues/4038
2023-10-12 20:40:18 +02:00
Abdirahim Musse
75f7de4010
test: fix get_passwd2 on IBM i (#4154)
uid 0 is `qsecofr` on IBM i.

Refs: https://github.com/libuv/libuv/issues/4143
2023-10-06 18:25:40 +00:00
jolai
fc4840ebc9
zos: correctly get cpu model in uv_cpu_info() (#4136)
The previous implementation using si11v1cpcmodel did not return a valid
cpu model on z/OS. So use PCCA instead to correctly get the cpu model.

Co-authored-by: Wayne Zhang <shuowang.zhang@ibm.com>
Co-authored-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
Co-authored-by: Jonathan Lai <jonathan.lai@ibm.com>
Fixes: https://github.com/libuv/libuv/issues/4102
2023-10-06 19:53:38 +02:00
Pleuvens
011a1ac1a3
test: switch to new-style ASSERT_EQ macros (#4159)
Switch from old-style ASSERT macro to new-style ASSERT_EQ,... macros.

Using new-style macros makes it easier to debug test failures

Fixes: https://github.com/libuv/libuv/issues/2974
2023-10-06 19:50:15 +02:00
Ben Noordhuis
56fada47f2
src: default to stream=stderr in handle printer (#4161)
Make printing handles from gdb a little easier because it doesn't always
know how to locate the stdout or stderr globals from libc.

With this commit `call uv_print_all_handles(0, 0)` prints the handles
from the default loop to stderr.
2023-10-03 13:30:16 +02:00
Ben Noordhuis
737f4f953f darwin: remove workaround for data corruption bug
XNU kernels anno ~2010 had a data corrruption bug where concurrent
write and pwrite calls sometimes resulted in blocks of zeroes being
written instead of the actual data.

Libuv works around that by serializing all writes with a process-wide
mutex, meaning oncurrent writes (for all files, not just single files)
have a concurrency of 1. Obviously that's not great for performance.

Modern day macOS no longer has this bug, so remove the workaround.
2023-10-03 13:09:40 +02:00
Ben Noordhuis
fef619608b unix: remove pwrite/pwritev conditionals 2023-10-03 13:09:40 +02:00
Ben Noordhuis
663d88b677 unix: remove pread/preadv conditionals 2023-10-03 13:09:40 +02:00
Jameson Nash
c03569f0df
win,process: avoid assert after spawning Store app (#4152)
Make sure this handle is functional. The Windows kernel seems to have a
bug that if the first use of AssignProcessToJobObject is for a Windows
Store program, subsequent attempts to use the handle with fail with
INVALID_PARAMETER (87). This is possilby because all uses of the handle
must be for the same Terminal Services session. We can ensure it is
tied to our current session now by adding ourself to it. We could
remove ourself afterwards, but there doesn't seem to be a reason to.

Secondly, we start the process suspended so that we can make sure we
added it to the job control object before it does anything itself (such
as launch more jobs or exit).

Fixes: https://github.com/JuliaLang/julia/issues/51461
2023-10-02 15:15:18 +02:00
SmorkalovG
2a4cab70ef
unix: reset signal counters after fork (#3485)
If a signal was received but was not dispatched before fork then
caught_signals counter should be reset. Closing of signal pipe makes
impossible to receive the signal that was counted.
There is no need in this signal because it was sent to parent process

Fixes: https://github.com/libuv/libuv/issues/3483
2023-09-29 12:54:35 +02:00
Abdirahim Musse
d83fadaf09
ibmi: implement ifaddrs, getifaddrs, freeifaddrs (#4155)
Add PASE implementation of ifaddrs, getifaddrs, freeifaddrs.

Refs: https://github.com/libuv/libuv/issues/4117
2023-09-28 21:16:11 +02:00
Santiago Gimeno
d277f71333
test: skip tests when ipv6 is not available (#4151) 2023-09-26 21:55:32 +02:00
Santiago Gimeno
c811169f91
unix: disable io_uring close on selected kernels (#4141)
Specifically on non-longterm kernels between 5.16.0 (non-longterm) and
6.1.0 (longterm). Starting with longterm 6.1.0, the issue is solved.
2023-09-17 22:09:00 +02:00
Santiago Gimeno
4e416266f6
build: fix qemu install in CI-unix workflow (#4142)
The version of the deb package has changed to 7.2.
2023-09-17 21:18:50 +02:00
Ben Noordhuis
0d78f3c758 unix: get mainline kernel version in Debian (#4131)
In Debian, the mainline kernel version is reported via the `uname()`
`version` field.
2023-09-01 11:24:26 +02:00
Santiago Gimeno
e2c8fed7b3 unix: get mainline kernel version in Ubuntu (#4131)
In Ubuntu, the kernel version reported by `uname()` follows the
versioning format that Ubuntu uses for their kernels which does not have
a direct correspondence with the mainline kernel version they're based
on. Get that version from `/proc/version_signature` as documented in:

https://wiki.ubuntu.com/Kernel/FAQ#Kernel.2FFAQ.2FGeneralVersionRunning.How_can_we_determine_the_version_of_the_running_kernel.3F
2023-09-01 11:24:26 +02:00
Alois Klink
0a02887e62
doc: fix broken "Shared library" Wikipedia link (#4128)
`linkcheck` is printing the following error:

```
( guide/utilities: line  311) broken    https://en.wikipedia.org/wiki/Shared_library#Shared_libraries - Anchor 'Shared_libraries' not found
```
2023-08-28 12:41:40 -04:00
michalbiesek
65dc822d6c
linux: add missing riscv syscall numbers (#4127)
Signed-off-by: Michal Biesek <michalbiesek@gmail.com>
2023-08-25 21:41:56 +02:00
Brad King
b3759772d2
win,fs: avoid winapi macro redefinition (#4123)
Adjust include order to avoid redefining `CTL_CODE`, `FILE_READ_ACCESS`,
and `FILE_WRITE_ACCESS`.  Without this, compilation shows:

```
...\um\winioctl.h(273): warning C4005: 'CTL_CODE': macro redefinition
...\src\win\winapi.h(4497): note: see previous definition of 'CTL_CODE'

...\um\winioctl.h(320): warning C4005: 'FILE_READ_ACCESS': macro redefinition
...\src\win\winapi.h(4488): note: see previous definition of 'FILE_READ_ACCESS'

...\um\winioctl.h(321): warning C4005: 'FILE_WRITE_ACCESS': macro redefinition
...\src\win\winapi.h(4492): note: see previous definition of 'FILE_WRITE_ACCESS'
```
2023-08-19 12:17:16 +02:00
小明
65541f772f
darwin: make TCP_KEEPINTVL and TCP_KEEPCNT available (#3908)
In earlier versions, macOS only defined TCP_KEEPALIVE, but since macOS
10.8 (Mountain Lion), it has supported TCP_KEEPINTVL and TCP_KEEPCNT.

https://lists.apple.com/archives/macnetworkprog/2012/Jul/msg00005.html
2023-08-14 15:33:12 -04:00
Saúl Ibarra Corretgé
1b4bd9209e
doc: switch to Furo, a more modern Sphinx theme (#4094) 2023-08-14 15:27:18 -04:00
Kyle Edwards
c97017dd1d
win,spawn: allow %PATH% to be unset (#4116)
Fix: https://github.com/libuv/libuv/issues/4115
2023-08-14 15:25:11 -04:00
Trevor Norris
2f82750098
unix: match kqueue and epoll code (#4091)
Match the implementation for linux.c to kqueue.c in the code around the
calls to kevent and epoll.

In linux.c the code was made more DRY by moving the nfds check up
(including a comment of why it's possible) and combining two if checks
into one.

In kqueue.c the assert to check the timeout when nfds == 0 has been
moved to be called directly after the EINTR check. Since it should
always be true regardless.

Ref: https://github.com/libuv/libuv/pull/3893
Ref: https://github.com/nodejs/node/issues/48490
2023-08-04 14:10:53 -06:00
Ben Noordhuis
e893cd6826
unix: set ipv6 scope id for link-local addresses (#4107)
Link-local addresses (prefix fe80::/64) don't route unless you specify
the network interface to use so make libuv do that.

Fixes: https://github.com/nodejs/node/issues/48846
2023-08-03 22:18:50 +02:00
Keith Winstein
124d55c970
build: move cmake_minimum_required version to 3.9 (#4111)
CMake 3.27 warns that "Compatibility with CMake < 3.5 will be removed
from a future version of CMake."
(https://cmake.org/cmake/help/latest/release/3.27.html#deprecated-and-removed-features)
2023-08-01 17:30:20 -04:00
Ben Noordhuis
30c3ef9f6f
linux: handle UNAME26 personality (#4109) 2023-07-31 23:40:59 +02:00
Ben Noordhuis
55376b044b
test: enable disabled spawn_same_stdout_stderr (#4105)
This test was added in commit e403a2c486 from 2014 but its author forgot
to enable it.
2023-07-25 16:48:22 +02:00
Ben Noordhuis
9c1de6e93f
test: enable disabled fs_link (#4104)
This test was added in commit 060026ced from 2011 but its author forgot
to actually enable it.
2023-07-25 16:48:04 +02:00
Ben Noordhuis
49d83c0301
test: enable disabled tcp_connect6_error_fault (#4103)
The test was added in commit e3f2631127 from 2011 but it appears the
author forgot to add it to the test list.

The other test from that commit was enabled by yours truly in 2012 in
7447048981 but apparently I overlooked the second test as well.
2023-07-25 15:58:08 +02:00
Jameson Nash
d09441ca03
fs: fix WTF-8 decoding issue (#4092)
We forgot to mask off the high bits from the first byte, so we ended up
always failing the subsequent range check.

Refs: #2970
Fixes: https://github.com/nodejs/node/issues/48673
2023-07-13 12:22:07 -04:00
Ben Noordhuis
50b53cbd0d
linux: don't use io_uring on pre-5.10.186 kernels (#4093)
Those kernels have a known resource consumption bug where the sqpoll
thread busy-loops.

Fixes: https://github.com/libuv/libuv/issues/4089
2023-07-12 23:33:49 +02:00
小明
1230fad8f4
darwin: fix build warnings (#4073) 2023-07-12 23:03:36 +02:00
Shuduo Sang
a939d643dd
linux: fix harmless warn_unused_result warning (#4056) 2023-07-12 23:00:59 +02:00
Ben Noordhuis
2f87d5c114
test: fix license blurb (#4085)
Fixes: https://github.com/libuv/libuv/issues/4080
2023-07-10 10:37:38 +02:00
Santiago Gimeno
c5644368b5
Now working on version 1.46.1
Fixes: https://github.com/libuv/libuv/issues/4060
2023-06-30 22:58:52 +02:00
Santiago Gimeno
ad523c20c7 Add SHA to ChangeLog 2023-06-30 18:31:51 +00:00
Santiago Gimeno
f0bb7e40f0 2023.06.30, Version 1.46.0 (Stable)
Changes since version 1.45.0:

* Add SHA to ChangeLog (Santiago Gimeno)

* misc: update readthedocs config (Jameson Nash)

* test: remove erroneous RETURN_SKIP (Ben Noordhuis)

* android: disable io_uring support (Ben Noordhuis)

* linux: add some more iouring backed fs ops (Santiago Gimeno)

* build: add autoconf option for disable-maintainer-mode (Jameson Nash)

* fs: use WTF-8 on Windows (Stefan Karpinski)

* unix,win: replace QUEUE with struct uv__queue (Ben Noordhuis)

* linux: fs_read to use io_uring if iovcnt > IOV_MAX (Santiago Gimeno)

* ios: fix uv_getrusage() ru_maxrss calculation (Ben Noordhuis)

* include: update outdated code comment (Ben Noordhuis)

* linux: support abstract unix sockets (Ben Noordhuis)

* unix,win: add UV_PIPE_NO_TRUNCATE flag (Ben Noordhuis)

* unix: add loongarch support (liuxiang88)

* doc: add DPS8M to LINKS.md (Jeffrey H. Johnson)

* include: add EUNATCH errno mapping (Abdirahim Musse)

* src: don't run timers if loop is stopped/unref'd (Trevor Norris)

* win: fix -Wpointer-to-int-cast warning (Ben Noordhuis)

* test,win: fix -Wunused-variable warning (Ben Noordhuis)

* test,win: fix -Wformat warning (Ben Noordhuis)

* linux: work around io_uring IORING_OP_CLOSE bug (Ben Noordhuis)

* win: remove unused functions (Ben Noordhuis)

* bench: add bench to check uv_loop_alive (Trevor Norris)

* test: add uv_cancel test for threadpool (Trevor Norris)

* unix: skip prohibited syscalls on tvOS and watchOS (小明)

* unix,fs: make no_pwritev access thread-safe (Santiago Gimeno)

* unix: fix build for lower versions of Android (小明)
2023-06-30 18:31:51 +00:00
小明
7b43d70be4
unix: fix build for lower versions of Android (#4046)
Available since Android N (API level 24): getgrgid_r, preadv, pwritev

Refs: https://cs.android.com/android/platform/superproject/+/master:bionic/docs/status.md
2023-06-26 13:47:48 +02:00
Santiago Gimeno
c8fad2ac09
unix,fs: make no_pwritev access thread-safe (#4066) 2023-06-23 13:17:37 +02:00
小明
ca544ed6fc
unix: skip prohibited syscalls on tvOS and watchOS (#4043) 2023-06-23 11:09:53 +02:00
Trevor Norris
6df5a72151
test: add uv_cancel test for threadpool (#4065 2/2)
Check that uv_cancel() returns UV_EBUSY when called while the uv_work_cb
is being executed.
2023-06-21 11:31:44 -06:00
Trevor Norris
3e0b846bdb
bench: add bench to check uv_loop_alive (#4065 1/2) 2023-06-21 11:31:25 -06:00
Ben Noordhuis
4b0fe81758
win: remove unused functions (#4063) 2023-06-20 22:30:31 +02:00
Ben Noordhuis
1752791c9e
linux: work around io_uring IORING_OP_CLOSE bug (#4059)
Work around a poorly understood bug in older kernels where closing a
file descriptor pointing to /foo/bar results in ETXTBSY errors when
trying to execve("/foo/bar") later on.

The bug seems to have been fixed somewhere between 5.15.85 and 5.15.90.
I couldn't pinpoint the responsible commit but good candidates are the
several data race fixes.

Interestingly, it seems to manifest only when running under Docker so
the possibility of a Docker bug can't be completely ruled out either.

This commit moves uv__kernel_version() from fs.c to linux.c because the
latter now uses it more than the former.

Fixes: https://github.com/nodejs/node/issues/48444
2023-06-20 13:01:12 +02:00
Ben Noordhuis
2bf97f123f test,win: fix -Wformat warning 2023-06-19 21:41:06 +02:00
Ben Noordhuis
9179888c2b test,win: fix -Wunused-variable warning 2023-06-19 21:41:06 +02:00
Ben Noordhuis
dde50f0e22 win: fix -Wpointer-to-int-cast warning 2023-06-19 21:41:06 +02:00
Trevor Norris
24d1d0802d
src: don't run timers if loop is stopped/unref'd (#4048)
The initial run of timers shouldn't happen if uv_stop() has been run
before uv_run() was called, and for backwards compatibility they also
shouldn't run if they have been unref'd before calling uv_run().
2023-06-16 11:00:06 -06:00
Abdirahim Musse
6a9e4293d8
include: add EUNATCH errno mapping (#4047)
add EUNATCH errno mapping
2023-06-16 09:27:39 -04:00
Jeffrey H. Johnson
4002231bd9
doc: add DPS8M to LINKS.md (#4052) 2023-06-16 10:29:26 +02:00
liuxiang88
7ada448d18
unix: add loongarch support (#4054)
Signed-off-by: liuxiang <liuxiang@loongson.cn>
2023-06-16 10:25:25 +02:00
Ben Noordhuis
2f1614b128
unix,win: add UV_PIPE_NO_TRUNCATE flag (#4040)
Libuv's default behavior is to truncate long Unix socket paths. The flag
tells it to return an error instead.

Fixes: https://github.com/libuv/libuv/issues/4036
2023-06-06 17:08:36 +02:00
Ben Noordhuis
b9b6db052b
linux: support abstract unix sockets (#4030)
Add two new APIs for binding and connecting to abstract UNIX sockets.

Fixes: https://github.com/libuv/libuv/issues/4028
2023-06-04 22:43:14 +02:00
Ben Noordhuis
e8ec610f28
include: update outdated code comment (#4037)
I believe it's fair to say at this point that these functions are not
going to be removed in v0.12. They are still deprecated though.
2023-06-04 22:41:58 +02:00
Ben Noordhuis
65c1402ee6
ios: fix uv_getrusage() ru_maxrss calculation (#4027)
Apple's documentation claims ru_maxrss is reported in kilobytes but the
XNU source code suggests the actual unit is bytes, like macOS.

Fixes: https://github.com/libuv/libuv/issues/4025
2023-05-25 13:08:43 +02:00
Santiago Gimeno
e7b9633170
linux: fs_read to use io_uring if iovcnt > IOV_MAX (#4023)
Just cap it to `IOV_MAX` as it's already done when performing reads
using the threadpool.
2023-05-25 12:09:51 +02:00
Ben Noordhuis
1b01b786c0
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
2023-05-25 00:04:30 +02:00
Stefan Karpinski
8f32a14afa
fs: use WTF-8 on Windows (#2970)
This allows working with valid filenames that are not well-formed
UTF-16. This is a superset of UTF-8, which does not error when it
encounters an unpaired surrogate but simply allows it.

Fixes: https://github.com/libuv/libuv/issues/2048
Refs: https://simonsapin.github.io/wtf-8/
Replaces: https://github.com/libuv/libuv/pull/2192 by Nikolai Vavilov <vvnicholas@gmail.com>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2023-05-23 10:25:38 -04:00
Jameson Nash
6d0d4a3e4d
build: add autoconf option for disable-maintainer-mode (#4000) 2023-05-23 09:15:53 -04:00
Santiago Gimeno
962b8e626c
linux: add some more iouring backed fs ops (#4012)
Specifically: `link`, `mkdir`, `rename`, `symlink` and `unlink`.
2023-05-23 10:42:20 +02:00
Ben Noordhuis
281e6185cc
android: disable io_uring support (#4016)
Android's zealous seccomp filter blocks the io_uring_setup system call.

Fixes: https://github.com/libuv/libuv/issues/4010
2023-05-23 00:25:09 +02:00
Ben Noordhuis
5bf18a6e88
test: remove erroneous RETURN_SKIP (#4015)
The threadpool_multiple_event_loops test already calls RETURN_SKIP when
needed. Remove it from the callback function where it isn't needed work
(nor works) and generates a build warning when compiling for qemu.

Fixes: https://github.com/libuv/libuv/issues/4014
2023-05-23 00:24:39 +02:00
Jameson Nash
4e766761d0
misc: update readthedocs config (#4009)
Now required: https://docs.readthedocs.io/en/stable/config-file/v2.html#build-os
2023-05-20 09:36:23 -04:00
Santiago Gimeno
a4649f5078 Now working on version 1.45.1
Fixes: https://github.com/libuv/libuv/issues/3887
2023-05-19 13:37:42 +02:00
Santiago Gimeno
d4f8a4ab5d Add SHA to ChangeLog 2023-05-19 13:37:42 +02:00
Santiago Gimeno
b9789a452f 2023.05.19, Version 1.45.0 (Stable)
Changes since version 1.44.2:

* win: remove stdint-msvc2008.h (Ben Noordhuis)

* android: remove pthread-fixes.c (Ben Noordhuis)

* build: enable MSVC_RUNTIME_LIBRARY setting (自发对称破缺)

* unix: switch to c11 atomics (Ben Noordhuis)

* unix: don't accept() connections in a loop (Ben Noordhuis)

* win: fix off-by-1 buffer overrun in uv_exepath() (Ben Noordhuis)

* build: switch ci from macos-10.15 to macos-11 (Ben Noordhuis)

* win: fix thread race in uv_cwd() and uv_chdir() (Ben Noordhuis)

* unix,win: remove UV_HANDLE_SHUTTING flag (Santiago Gimeno)

* win: support Windows 11 in uv_os_uname() (Luan Devecchi)

* unix: fix uv_getrusage() ru_maxrss reporting (Ben Noordhuis)

* doc: add note about offset -1 in uv_fs_read/write (Steven
  Schveighoffer)

* test: fix musl libc.a dlerror() test expectation (Ben Noordhuis)

* kqueue: DRY file descriptor deletion logic (Ben Noordhuis)

* linux: teach uv_get_constrained_memory() cgroupsv2 (Ben Noordhuis)

* build: upgrade qemu-user-static package (Ben Noordhuis)

* linux: move epoll.c back into linux-core.c (Ben Noordhuis)

* unix: remove pre-macos 10.8 compatibility hack (Ben Noordhuis)

* unix,win: fix memory leak in uv_fs_scandir() (Ben Noordhuis)

* build: restore qemu download logic (Ben Noordhuis)

* win: fix uv__pipe_accept memory leak (number201724)

* doc: update LINKS.md (Daniel)

* unix: simplify atomic op in uv_tty_reset_mode() (Ben Noordhuis)

* build: add LIBUV_BUILD_SHARED cmake option (Christian Clason)

* linux: remove unused or obsolete syscall wrappers (Ben Noordhuis)

* linux: merge files back into single file (Ben Noordhuis)

* stream: process more than one write req per loop tick (ywave620)

* unix,win: give thread pool threads an 8 MB stack (Ben Noordhuis)

* build: add MemorySanitizer (MSAN) support (Ben Noordhuis)

* doc: add uv_poll_cb status==UV_EBADF note (jensbjorgensen)

* build: support AddressSanitizer on MSVC (Jameson Nash)

* win,pipe: improve method of obtaining pid for ipc (number201724)

* thread: add support for affinity (daomingq)

* include: map ENODATA error code (Ben Noordhuis)

* build: remove bashism from autogen.sh (Santiago Gimeno)

* win,tcp,udp: remove "active streams" optimization (Saúl Ibarra
  Corretgé)

* win: drop code checking for Windows XP / Server 2k3 (Saúl Ibarra
  Corretgé)

* unix,win: fix 'sprintf' is deprecated warning (twosee)

* doc: mention close_cb can be NULL (Qix)

* win: optimize udp receive performance (ywave620)

* win: fix an incompatible types warning (twosee)

* doc: document 0 return value for free/total memory (Ben Noordhuis)

* darwin: use hw.cpufrequency again for frequency info (Jameson Nash)

* win,test: change format of TEST_PIPENAME's (Santiago Gimeno)

* win,pipe: fixes in uv_pipe_connect() (Santiago Gimeno)

* misc: fix return value of memory functions (theanarkh)

* src: add new metrics APIs (Trevor Norris)

* thread: add uv_thread_getcpu() (daomingq)

* build: don't use ifaddrs.h on solaris 10 (Edward Humes)

* unix,win: add uv_get_available_memory() (Tim Besard)

* test: fix -Wunused-but-set-variable warnings (Ben Noordhuis)

* doc: bump min supported linux and freebsd versions (Ben Noordhuis)

* Add Socket Runtime to the LINKS.md (Sergey Rubanov)

* unix: drop kfreebsd support (Ben Noordhuis)

* win: fix fstat for pipes and character files (Stefan Stojanovic)

* win: fix -Wunused-variable warning (Ben Noordhuis)

* win: fix -Wunused-function warning (Ben Noordhuis)

* build: drop qemu-alpha from ci matrix (Ben Noordhuis)

* win: move child_stdio_buffer out of uv_process_t (Santiago Gimeno)

* test: fix some unreachable code warnings (Santiago Gimeno)

* linux: simplify uv_uptime() (Ben Noordhuis)

* test: unflake fs_event_watch_dir test (Ben Noordhuis)

* darwin: remove unused fsevents symbol lookups (Ben Noordhuis)

* build: add define guard around UV_EXTERN (Zvicii)

* build: add UndefinedBehaviorSanitizer support (Ben Noordhuis)

* build: enable platform_output test on qemu (Ben Noordhuis)

* linux: handle cpu hotplugging in uv_cpu_info() (Ben Noordhuis)

* build: remove unnecessary policy setting (dundargoc)

* docs: add vcpkg instruction step (Jack·Boos·Yu)

* win,fs: fix readlink errno for a non-symlink file (Darshan Sen)

* misc: extend getpw to take uid as an argument (Jameson Nash)

* unix,win: use static_assert when available (Ben Noordhuis)

* docs: delete code Makefile (Jameson Nash)

* docs: add CI for docs PRs (Jameson Nash)

* docs: update Sphinx version on RTD (Jameson Nash)

* doc: clean up license file (Ben Noordhuis)

* test: fix some warnings when compiling tests (panran)

* build,win: add mingw-w64 CI configuration (Jameson Nash)

* build: add CI for distcheck (Jameson Nash)

* unix: remove busy loop from uv_async_send (Jameson Nash)

* doc: document uv_fs_cb type (Tamás Bálint Misius)

* build: Improve build by cmake for Cygwin (erw7)

* build: add libuv:: namespace to libuvConfig.cmake (AJ Heller)

* test: fix ThreadSanitizer thread leak warning (Ben Noordhuis)

* test: fix ThreadSanitizer data race warning (Ben Noordhuis)

* test: fix ThreadSanitizer data race warning (Ben Noordhuis)

* test: fix ThreadSanitizer data race warning (Ben Noordhuis)

* test: cond-skip fork_threadpool_queue_work_simple (Ben Noordhuis)

* test: cond-skip signal_multiple_loops (Ben Noordhuis)

* test: cond-skip tcp_writealot (Ben Noordhuis)

* build: promote tsan ci to must-pass (Ben Noordhuis)

* build: add CI for OpenBSD and FreeBSD (James McCoy)

* build,test: fix distcheck errors (Jameson Nash)

* test: remove bad tty window size assumption (Ben Noordhuis)

* darwin,process: feed kevent the signal to reap children (Jameson Nash)

* unix: abort on clock_gettime() error (Ben Noordhuis)

* test: remove timing-sensitive check (Ben Noordhuis)

* unix: DRY and fix tcp bind error path (Jameson Nash)

* macos: fix fsevents thread race conditions (Ben Noordhuis)

* win: fix leak in uv_chdir (Trevor Norris)

* test: make valgrind happy (Trevor Norris)

* barrier: wait for prior out before next in (Jameson Nash)

* test: fix visual studio 2015 build error (Ben Noordhuis)

* linux: fix ceph copy error truncating readonly files (Bruno Passeri)

* test: silence more valgrind warnings (Trevor Norris)

* doc: add entries to LINKS.md (Trevor Norris)

* win,unix: change execution order of timers (Trevor Norris)

* doc: add trevnorris to maintainers (Trevor Norris)

* linux: remove epoll_pwait() emulation code path (Ben Noordhuis)

* linux: replace unsafe macro with inline function (Ben Noordhuis)

* linux: remove arm oabi support (Ben Noordhuis)

* unix,sunos: SO_REUSEPORT not valid on all sockets (Stacey Marshall)

* doc: consistent single backquote in misc.rst (Jason Zhang)

* src: switch to use C11 atomics where available (Trevor Norris)

* test: don't use static buffer for formatting (Ben Noordhuis)

* linux: introduce io_uring support (Ben Noordhuis)

* linux: fix academic valgrind warning (Ben Noordhuis)

* test: disable signal test under ASan and MSan (Ben Noordhuis)

* linux: add IORING_OP_OPENAT support (Ben Noordhuis)

* linux: add IORING_OP_CLOSE support (Ben Noordhuis)

* linux: remove bug workaround for obsolete kernels (Ben Noordhuis)

* doc: update active maintainers list (Ben Noordhuis)

* test: add ASSERT_OK (Trevor Norris)

* src: fix events/events_waiting metrics counter (Trevor Norris)

* unix,win: add uv_clock_gettime() (Ben Noordhuis)

* build: remove freebsd and openbsd buildbots (Ben Noordhuis)

* win: fix race condition in uv__init_console() (sivadeilra)

* linux: fix logic bug in sqe ring space check (Ben Noordhuis)

* linux: use io_uring to batch epoll_ctl calls (Ben Noordhuis)

* macos: update minimum supported version (Santiago Gimeno)

* docs: fix some typos (cui fliter)

* unix: use memcpy() instead of type punning (Ben Noordhuis)

* test: add additional assert (Mohammed Keyvanzadeh)

* build: export compile_commands.json (Lewis Russell)

* win,process: write minidumps when sending SIGQUIT (Elliot Saba)

* unix: constrained_memory should return UINT64_MAX (Tim Besard)

* unix: handle CQ overflow in iou ring (Santiago Gimeno)

* unix: remove clang compiler warning pragmas (Ben Noordhuis)

* win: fix mingw build (gengjiawen)

* test: fix -Wbool-compare compiler warning (Ben Noordhuis)

* win: define MiniDumpWithAvxXStateContext always (Santiago Gimeno)

* freebsd: hard-code UV_ENODATA definition (Santiago Gimeno)

* linux: work around EOWNERDEAD io_uring kernel bug (Ben Noordhuis)

* linux: fix WRITEV with lots of bufs using io_uring (Santiago Gimeno)
2023-05-19 13:37:42 +02:00
Santiago Gimeno
07261493a7 Revert "win: implement uv_try_write() for pipes(#3825 1/2)"
This reverts commit 244e0e2059.

For some reason this is breaking node.js IPC. I plan to investigate it
but we can let this for the next release.t

PR-URL: https://github.com/libuv/libuv/pull/4003
2023-05-19 11:08:49 +02:00
Santiago Gimeno
03bb703741 Revert "win: fixes in uv__pipe_try_write() (#3825 2/2)"
This reverts commit e1143f1265.

For some reason this is breaking node.js IPC. I plan to investigate it
but we can let this for the next release.

PR-URL: https://github.com/libuv/libuv/pull/4003
2023-05-19 11:08:49 +02:00
Santiago Gimeno
ef6a9a624d
linux: fix WRITEV with lots of bufs using io_uring (#4004)
In the case of trying to write more than `IOV_MAX` buffers, the
`IORING_OP_WRITEV` operation will return `EINVAL`. As a temporal fix,
fallback to the old ways. In the future we might implement this by
linking multiple `IORING_OP_WRITEV` requests using `IOSQE_IO_LINK`.
2023-05-19 11:03:17 +02:00
Ben Noordhuis
d23a20f62c
linux: work around EOWNERDEAD io_uring kernel bug (#4002)
io_uring sometimes erroneously returns EOWNERDEAD when the intention was
to return 0. It's harmless and fixed in linux 5.14 so just ignore the
error.

Fixes: https://github.com/libuv/libuv/issues/4001
Refs: https://github.com/torvalds/linux/commit/21f965221e
2023-05-17 16:54:36 +02:00
Santiago Gimeno
6f94701467
freebsd: hard-code UV_ENODATA definition (#3999)
`FreeBSD` defines `ENODATA` in /usr/include/c++/v1/errno.h which is only visible
if C++ is the compilation unit. This can cause interop issues when
integrating libuv build with C on a C++ project. Avoid this issue by
directly defining with the value defined in the file previously
mentioned.
2023-05-16 20:43:30 +02:00
Santiago Gimeno
d1a2efc77b
win: define MiniDumpWithAvxXStateContext always (#3998) 2023-05-16 16:29:03 +02:00
Ben Noordhuis
1a56f68451
test: fix -Wbool-compare compiler warning (#3996)
Fixes: https://github.com/libuv/libuv/issues/3995
2023-05-16 10:56:41 +02:00
Jiawen Geng
e7ecd116e0
win: fix mingw build (#3994)
Fixes: https://github.com/libuv/libuv/issues/3992
2023-05-15 23:35:35 +02:00
Ben Noordhuis
44b8153005
unix: remove clang compiler warning pragmas (#3989)
Instead of suppressing the VLA warning, use a fixed-size buffer that is
big enough to receive at least one control message but not so big that
IBMi PASE rejects it.
2023-05-15 10:52:23 +02:00
Santiago Gimeno
30fc896cc1
unix: handle CQ overflow in iou ring (#3991)
When there are more than 128 concurrent cq completions the CQ ring
overflows as signaled via the `UV__IORING_SQ_CQ_OVERFLOW`. If this
happens we have to enter the kernel to get the remaining items.
2023-05-15 10:42:14 +02:00
Tim Besard
6ad347fae4
unix: constrained_memory should return UINT64_MAX (#3753)
Document that we return UINT64_MAX if the cgroup limit is set to the
max. For cgroupv2, that happens if we encounter `max`, while cgroupv1
returns 9223372036854771712 when no limit is set (which according to
[this StackExchange discussion] is derived from LONG_MAX and
PAGE_SIZE). So make sure we also detect this case for cgroupv1.

[this StackExchange discussion]: https://unix.stackexchange.com/questions/420906/what-is-the-value-for-the-cgroups-limit-in-bytes-if-the-memory-is-not-restricte

Addresses: https://github.com/libuv/libuv/pull/3744/files#r974062912
2023-05-12 14:34:20 -04:00
Elliot Saba
748d894e82
win,process: write minidumps when sending SIGQUIT (#3840)
This commit adds the ability to dump core when sending the `SIGQUIT`
signal on Windows. The change reads in the current registry setting for
local dumps, and attempts to write out to that location before killing
the process. See [collecting-user-mode-dumps] for registry and pathing
details. This behavior mimics that of the dumps created by the typical
Windows Error Reporting mechanism.

[collecting-user-mode-dumps]: https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps
2023-05-12 14:28:35 -04:00
Lewis Russell
f70027cbdc
build: export compile_commands.json (#3968)
Allows LSP's like clangd to work.
2023-05-12 14:15:24 -04:00
Mohammed Keyvanzadeh
8a5b0955de
test: add additional assert (#3983)
Add a missing assert that checks whether `uv_pipe_init()`
succeeded or not.
2023-05-12 14:13:23 -04:00
Ben Noordhuis
ff7dcd2654
unix: use memcpy() instead of type punning (#3990)
Libuv makes no claim to being strict aliasing-clean but type punning
makes me feel unclean so replace it with memcpy().
2023-05-12 14:12:47 -04:00
cui fliter
3990fcad62
docs: fix some typos (#3984) 2023-05-12 14:12:01 -04:00
Santiago Gimeno
15e81386bf
macos: revert clonefile (#3987)
* Revert "macos: fix source not being followed when cloning (#3941)"

This reverts commit 507f2f950d.

* Revert "darwin: bring back macos-specific copyfile(3) (#3654)"

This reverts commit d4eb276eea.
2023-05-10 17:38:58 +02:00
Santiago Gimeno
3f331e97da
macos: update minimum supported version (#3982)
Only support the versions still maintained by Apple.
2023-05-02 17:04:42 +02:00
Ben Noordhuis
6e073ef5da
linux: use io_uring to batch epoll_ctl calls (#3979)
This work was sponsored by ISC, the Internet Systems Consortium.
2023-05-01 09:00:08 +02:00
Ben Noordhuis
f272082240
linux: fix logic bug in sqe ring space check (#3980)
Handle wraparound properly, otherwise we may end up overwriting elements
that have not been consumed by the kernel yet.
2023-05-01 06:17:26 +02:00
sivadeilra
c51522c08f
win: fix race condition in uv__init_console() (#3973)
Co-authored-by: Arlie Davis <ardavis@microsoft.com>
Fixes: https://github.com/libuv/libuv/issues/3970
2023-04-29 12:59:56 +02:00
Ben Noordhuis
932092e95d
build: remove freebsd and openbsd buildbots (#3974)
The buildbots are super flaky compared to other platforms and no one
seems invested enough to investigate. They don't add nearly enough value
for the friction they cause so away they go.

Fixes: https://github.com/libuv/libuv/issues/3934
Fixes: https://github.com/libuv/libuv/issues/3972
Refs: https://github.com/libuv/libuv/pull/3548
2023-04-27 22:15:01 +02:00
Ben Noordhuis
c8a1e6132b
unix,win: add uv_clock_gettime() (#3971)
Fixes: https://github.com/libuv/libuv/issues/1674
2023-04-27 22:13:46 +02:00
Trevor Norris
e02642cf3b src: fix events/events_waiting metrics counter (#3957)
The worker pool calls all callbacks locally within the queue. So the
value of nevents doesn't properly reflect that case. Increase the number
of events directly from the worker pool's callback to correct this.

In order to properly determine if the events_waiting counter needs to be
incremented, store the timeout value at the time the event provider was
called.
2023-04-24 15:29:14 -06:00
Trevor Norris
b60f08e782 test: add ASSERT_OK (#3957)
The majority of uses for ASSERT_EQ are to check if the return value is
0. So make a macro specifically for this and make things easier to read.
2023-04-24 15:29:14 -06:00
Ben Noordhuis
4fc331f8e8
doc: update active maintainers list (#3967)
Move Bert and Fedor to emeriti.
2023-04-23 17:52:41 +02:00
Lewis Russell
507f2f950d
macos: fix source not being followed when cloning (#3941)
Fixes: https://github.com/libuv/libuv/issues/3940
2023-04-23 11:54:25 +02:00
Ben Noordhuis
1c935a3445
linux: remove bug workaround for obsolete kernels (#3965)
Libuv no longer supports such kernels so the workaround can be removed.
2023-04-20 12:15:32 +02:00
Ben Noordhuis
dfae365f84
linux: add IORING_OP_CLOSE support (#3964) 2023-04-20 10:44:16 +02:00
Ben Noordhuis
5ca5e475bb
linux: add IORING_OP_OPENAT support (#3963) 2023-04-20 10:17:06 +02:00
Ben Noordhuis
3ba75f1300
test: disable signal test under ASan and MSan (#3961)
The signal_multiple_loops test is flaky when run under AddressSanitizer
and MemorySanitizer. Sometimes thread creation fails, other times it
simply times out.

Fixes: https://github.com/libuv/libuv/issues/3956
2023-04-19 07:40:18 +02:00
Ben Noordhuis
a7ff759ca1
linux: fix academic valgrind warning (#3960)
Fix a valgrind warning that only manifested with clang (not gcc!) by
explicitly passing 0L instead of plain 0 as the |sigsz| argument to
io_uring_enter(). That is, pass a long instead of an int.

On x86_64, |sigsz| is passed on the stack (the other arguments are
passed in registers) but where gcc emits a `push $0` that zeroes the
entire stack slot, clang emits a `movl $0,(%rsp)` that leaves the upper
32 bits untouched.

It's academic though since we don't pass IORING_ENTER_EXT_ARG and the
kernel therefore completely ignores the argument.

Refs: https://github.com/libuv/libuv/pull/3952
2023-04-19 07:39:10 +02:00
Ben Noordhuis
d2c31f429b
linux: introduce io_uring support (#3952)
Add io_uring support for several asynchronous file operations:

- read, write
- fsync, fdatasync
- stat, fstat, lstat

io_uring is used when the kernel is new enough, otherwise libuv simply
falls back to the thread pool.

Performance looks great; an 8x increase in throughput has been observed.

This work was sponsored by ISC, the Internet Systems Consortium.

Fixes: https://github.com/libuv/libuv/issues/1947
2023-04-18 12:32:08 +02:00
Ben Noordhuis
cb5da59226
test: don't use static buffer for formatting (#3953)
Don't use a static buffer to hold human-readable "big" numbers.

The buffer isn't big enough for benchmarks like fs_stat that print a
large number of them. Have the caller pass in a buffer instead.
2023-04-14 16:54:28 +02:00
Trevor Norris
2f33980a91
src: switch to use C11 atomics where available (#3950)
Switch all code in unix/ to use C11 atomics directly.

Change uv_library_shutdown() to use an exchange instead of load/store.

Unfortunately MSVC only started supporting C11 atomics in VS2022 version
17.5 Preview 2 as experimental. So resort to using the Interlocked API.

Ref: https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2/
Fixes: https://github.com/libuv/libuv/issues/3948
2023-04-12 13:54:22 -06:00
Jason Zhang
e189c31375
doc: consistent single backquote in misc.rst (#3946)
Fixes: https://github.com/libuv/libuv/issues/3928
2023-04-11 19:50:31 +02:00
Stacey Marshall
1eae55984d
unix,sunos: SO_REUSEPORT not valid on all sockets (#3949)
Issue observed on Solaris with ISC BIND 9.18 which reported "unable to
open route socket: unexpected error". illumos did not hit it because it
does not have SO_REUSEPORT (open RFE
https://www.illumos.org/issues/12455)
2023-04-11 19:49:25 +02:00
Ben Noordhuis
244df24bf4
linux: remove arm oabi support (#3942)
The last major distro that supported the oabi calling convention was
Debian 5 (Lenny) and that went out of support in February 2012. It seems
like a fairly safe assumption that nothing speaks oabi anymore in this
day and age.

Fixes: https://github.com/libuv/libuv/issues/3935
2023-04-02 00:20:26 +02:00
Ben Noordhuis
28b9f1e68b
linux: replace unsafe macro with inline function (#3933)
Replace the throw-type-safety-to-the-wind CAST() macro with an inline
function that is hopefully harder to misuse. It should make the inotify
code slightly more legible if nothing else.
2023-03-31 10:09:48 +02:00
Ben Noordhuis
0c8eccc3fc
linux: remove epoll_pwait() emulation code path (#3936)
This was removed before in 2018 but then reinstated again in 2019 to
fix building with old Android SDKs. Well, time marches on; this time
it's gone for good.

Refs: https://github.com/libuv/libuv/pull/1372
Refs: https://github.com/libuv/libuv/pull/2358
2023-03-28 11:58:56 +02:00
Trevor Norris
7b84d5b0ec
doc: add trevnorris to maintainers (#3931) 2023-03-20 14:23:50 -06:00
Trevor Norris
6600954906
win,unix: change execution order of timers (#3927)
The maximum number of times timers should run when uv_run() is called
with UV_RUN_ONCE and UV_RUN_NOWAIT is 1. Do that by conditionally
calling timers before entering the while loop when called with
UV_RUN_DEFAULT.

The reason to always run timers at the end of the while loop, instead of
at the beginning, is to help enforce the conceptual event loop model.
Which starts when entering the event provider (e.g. calling poll).

Other than only allowing timers to be processed once per uv_run()
execution, the only other noticeable change this will show is if all the
following are true:
* uv_run() is called with UV_RUN_NOWAIT or UV_RUN_ONCE.
* An event is waiting to be received when poll is called.
* Execution time between the call to uv_timer_start() and entering the
  while loop is longer than the timeout.

If all these are true, then timers that would have executed before
entering the event provider will now be executed afterward.

Fixes: https://github.com/libuv/libuv/issues/3686
Co-authored-by: Momtchil Momtchev <momtchil@momtchev.com>
2023-03-20 10:04:57 -06:00
Trevor Norris
4a65e10f5e
doc: add entries to LINKS.md (#3925)
Add the libuv wrapper nsuv to the list, along with other C++ apps that
were found to use libuv extensively and have been maintained recently.
2023-03-15 22:35:18 -06:00
Niklas Mischkulnig
d4eb276eea
darwin: bring back macos-specific copyfile(3) (#3654)
Co-authored-by: Mingye Wang <arthur200126@gmail.com>
2023-03-13 11:54:31 +01:00
Trevor Norris
91a7e49846
test: silence more valgrind warnings (#3917)
Pass the loop to MAKE_VALGRIND_HAPPY() so it's explicit on which loop
needs to be cleaned up. Since it asserts on uv_loop_close(), need to
remove a couple of those that were being done before the call.

Cleanup where loop was assigned, so the entire test either uses loop or
uv_default_loop(). Not both.

Also take care of any reqs that may have been left uncleaned.
2023-03-12 14:59:00 +01:00
Bruno Passeri
dfb206c8b0
linux: fix ceph copy error truncating readonly files (#3920)
Trying to copy a read-only file onto a ceph-fuse filesystem fails,
returning an `EACCES` error. This happens when the destination
doesn't exist yet, and a new file is created.

By checking that the error matches, and that the destination file
is empty, we can fix this issue while waiting for a proper Ceph
fix to be upstreamed.

Fixes: https://github.com/libuv/libuv/issues/3919
Refs: https://github.com/nodejs/node/issues/37284
Refs: https://github.com/libuv/libuv/issues/3117
Refs: https://github.com/libuv/libuv/issues/3322
2023-03-12 12:05:45 +01:00
Ben Noordhuis
9581e3df0c
test: fix visual studio 2015 build error (#3918) 2023-03-10 11:41:35 +01:00
Jameson Nash
964f79f7c8
barrier: wait for prior out before next in (#3905)
This code would previously get confused between rounds of the barrier
being called and a thread might incorrectly get stuck (deadlock) if the
next round started before that thread had exited the current round.

Avoid that by not starting the next round in++ before out-- has reached
zero indicating that all threads have left the prior round.

And fix it that on Windows by replacing the implementation with the one
from unix. There are some awkward platform-specific redirection here
with an extra malloc that is not needed on Win32, but that will be fixed
in libuv v2.

Fixes: https://github.com/libuv/libuv/issue/3872
2023-03-06 17:57:25 -05:00
Trevor Norris
460accf9be
test: make valgrind happy (#3916)
Missing a call to MAKE_VALGRIND_HAPPY() to silence valgrind output.
2023-03-03 15:52:31 -05:00
Trevor Norris
780b40ea7b
win: fix leak in uv_chdir (#3912)
The call to uv__cwd() always returns a new allocation. The previously
allocated utf16_buffer needs to be free'd before passing it in to
receive the next allocation.
2023-02-27 13:58:12 -05:00
Ben Noordhuis
e613fdd83c
macos: fix fsevents thread race conditions (#3909)
ThreadSanitizer complains about unsynchronized access to the
handle->loop->cf_state pointer.

The warning is probably benign but the fsevents thread already knows
the pointer. It doesn't have to read it, it just needs to propagate it.

Refs: https://github.com/libuv/libuv/issues/3880
2023-02-17 13:59:02 +01:00
Jameson Nash
62c2374a8c
unix: DRY and fix tcp bind error path (#3904)
The conditional bind-to-port logic in tcp.c had an error path that
closed the socket file descriptor while it was still owned by the
uv_tcp_t handle.

Fix that by not closing the file descriptor and refactoring the code so
it is hopefully harder to get wrong in the future.

The refactoring also makes the code a little flatter, removes duplicated
code, and, arguably, is in a more idiomatic libuv style.

Fixes: https://github.com/libuv/libuv/issues/3461
Replaces: https://github.com/libuv/libuv/pull/3462
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
2023-02-07 14:59:39 -05:00
Ben Noordhuis
84525b26fe
test: remove timing-sensitive check (#3899)
Remove expectations around uv_cond_timedwait() maximum sleep time.

The OpenBSD buildbot sleeps more than 5x longer than requested. It no
longer makes sense to expect some reasonable upper bound because at that
point we've moved well beyond reasonable.

Fixes: https://github.com/libuv/libuv/issues/3896
2023-02-07 11:15:59 -05:00
Ben Noordhuis
be2ddacb90
unix: abort on clock_gettime() error (#3898)
Per standard libuv operating procedures, abort on unexpected failure.
Don't silently ignore the error and return garbage.
2023-02-01 22:10:36 +01:00
Jameson Nash
42cc412c4a
darwin,process: feed kevent the signal to reap children (#3893)
Since we are emulating this event, but are not using the pending_queue,
we need to make sure it is accounted for properly. Also DRY some of the
reset_timeout code here.

This was observed to cause a hang in certain rare cases, particularly on
M1 machines.

Do a bit of code cleanup too, since we do not need to initialize the
internal signal handling pipe if it will not be used.
2023-02-01 13:42:26 -05:00
Ben Noordhuis
f1b4c76648
test: remove bad tty window size assumption (#3895)
Fixes: https://github.com/libuv/libuv/issues/3894
2023-01-31 18:35:18 +01:00
Jameson Nash
ee206367d4
build,test: fix distcheck errors (#3886)
When run under distcheck, the libuv source permissions are read-only,
which makes this test copyfile fail without explicit correction to the
permissions.
2023-01-22 15:26:22 -06:00
James McCoy
2638237e1f
build: add CI for OpenBSD and FreeBSD (#3548)
Fixes: https://github.com/libuv/libuv/issues/3510
2023-01-21 13:52:36 +01:00
Ben Noordhuis
67063ead60 build: promote tsan ci to must-pass
Refs: https://github.com/libuv/libuv/issues/3681
2023-01-20 22:38:59 +01:00
Ben Noordhuis
a3b7dfcfca test: cond-skip tcp_writealot
Too slow to run under ThreadSanitizer.

Refs: https://github.com/libuv/libuv/issues/3681
2023-01-20 22:38:59 +01:00
Ben Noordhuis
bcbaf671a9 test: cond-skip signal_multiple_loops
ThreadSanitizer's complaints about data races are likely legitimate but
they are pre-existing and not straightforward to fix with the current
design. Something for later.

Refs: https://github.com/libuv/libuv/issues/3681
2023-01-20 22:38:59 +01:00
Ben Noordhuis
c58cd28279 test: cond-skip fork_threadpool_queue_work_simple
Skip the test when ThreadSanitizer is active because the latter doesn't
support forking in multi-threaded processes.

Refs: https://github.com/libuv/libuv/issues/3681
2023-01-20 22:38:59 +01:00
Ben Noordhuis
f328457cb1 test: fix ThreadSanitizer data race warning
Legitimate if fairly benign warning: the `stop` global variable was
read and written without proper synchronization; `volatile` isn't
sufficient.

Refs: https://github.com/libuv/libuv/issues/3681
2023-01-20 22:38:59 +01:00
Ben Noordhuis
7b5a21deaa test: fix ThreadSanitizer data race warning
Refs: https://github.com/libuv/libuv/issues/3681
2023-01-20 22:38:59 +01:00
Ben Noordhuis
895a1c03be test: fix ThreadSanitizer data race warning
Refs: https://github.com/libuv/libuv/issues/3681
2023-01-20 22:38:59 +01:00
Ben Noordhuis
679d679f25 test: fix ThreadSanitizer thread leak warning
Refs: https://github.com/libuv/libuv/issues/3681
2023-01-20 22:38:59 +01:00
AJ Heller
0235e150e2
build: add libuv:: namespace to libuvConfig.cmake (#3596)
This may be breaking, but is still quite new, and seems to follow cmake
best practices.
2023-01-19 16:07:29 -06:00
erw7
17ea56ee73
build: Improve build by cmake for Cygwin (#2085)
- Fix build on Cygwin.
- Simplify file name of static library.

Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2023-01-19 15:33:07 -06:00
Tamás Bálint Misius
b4440f5aa2
doc: document uv_fs_cb type (#3517) 2023-01-19 14:05:07 -06:00
Jameson Nash
fe7ee4a624
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
2023-01-19 14:03:59 -06:00
Jameson Nash
a40058dbd1
build: add CI for distcheck (#3571)
Refs: https://github.com/libuv/libuv/issues/2190#issuecomment-465974240
Refs: https://github.com/libuv/libuv/issues/2199

Co-authored-by: Richard Lau <rlau@redhat.com>
2023-01-19 14:00:45 -06:00
Jameson Nash
c70cc5832b
build,win: add mingw-w64 CI configuration (#3885)
Co-authored-by: Nicolas Noble <pixel@nobis-crew.org>
2023-01-19 14:00:15 -06:00
panran
a4ba1bd73e
test: fix some warnings when compiling tests (#3816)
```
warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
note: in expansion of macro 'ASSERT_BASE'
#define ASSERT_EQ(a, b) ASSERT_BASE(a, ==, b, int64_t, PRId64)

warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but
argument 3 has type ‘uint32_t’ {aka ‘unsigned int’}
```

Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2023-01-19 10:48:13 -06:00
Ben Noordhuis
61e0bbda6b
doc: clean up license file (#3876)
GitHub gets confused by the non-standard format of the LICENSE file.
Move the extra bits into the creatively named LICENSE-extra file.

Fixes: https://github.com/libuv/libuv/issues/3875
2023-01-19 10:46:25 -06:00
Jameson Nash
a38c4dfa99
docs: update Sphinx version on RTD (#3882)
python3.9 -mvirtualenv sphinx
    . sphinx/bin/activate
    pip install Sphinx
    pip freeze > requirements.txt
2023-01-18 12:15:48 -06:00
Jameson Nash
975f685d69
docs: add CI for docs PRs (#3884) 2023-01-18 11:29:10 -06:00
Jameson Nash
4155405e60
docs: delete code Makefile (#3883)
This Makefile was a fairly poor sample, while now we have CMake for
these to use for testing.
2023-01-18 10:16:29 -06:00
Ben Noordhuis
55b5d88b01
unix,win: use static_assert when available (#3189)
Fixes: https://github.com/libuv/libuv/issues/3131
2023-01-17 22:26:41 -06:00
Jameson Nash
2f110a50df
misc: extend getpw to take uid as an argument (#3523)
File system operations may return uid and gid values, which we may want
to pretty-print. We already have the code for getting information for
the current user, so just need to add a parameter to make it exposed for
every user. We expose information about groups in a similar manner also.
2023-01-17 21:51:28 -06:00
Darshan Sen
7fd7e8264f
win,fs: fix readlink errno for a non-symlink file (#3719)
In Node.js, fs.readlink() on a non-symlink file used to throw an UNKNOWN
error on Windows. This change maps ERROR_NOT_A_REPARSE_POINT to
UV_EINVAL, so that now it throws EINVAL just like other platforms.

This is handled explicitly in `fs__readlink`, since elsewhere it might
map to EPERM instead (such as in `link`).
2023-01-17 21:04:52 -06:00
Jack·Boos·Yu
1279a20c03
docs: add vcpkg instruction step (#3747)
Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
2023-01-17 20:54:36 -06:00
dundargoc
39f9189f34
build: remove unnecessary policy setting (#3873)
All cmake policies up to CMP0065 are set to NEW by default since the
minimum required version is 3.4.
2023-01-14 11:12:51 +01:00
Ben Noordhuis
434eb4b0ac
linux: handle cpu hotplugging in uv_cpu_info() (#3861)
On Linux, CPUs can come online or go offline while uv_cpu_info() is busy
gathering data. Change uv_cpu_info() in the following ways:

1. Learn online CPUs from /proc/stat

2. Get the model name from /proc/cpuinfo when it has a matching CPU,
   or default to "unknown"

3. Get speed from /sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq
   when it exists, or default to 0

Before this commit, libuv read the speed from /proc/cpuinfo but that
reports the base frequency, not the actual frequency. My system has
two cores running permanently at 3.6 GHz but libuv thought all 12 ran
at 2.2 GHz.

Fixes: https://github.com/libuv/libuv/issues/2351
Fixes: https://github.com/libuv/libuv/issues/3858
2023-01-14 05:08:15 +01:00
Ben Noordhuis
5ee455ffc2
build: enable platform_output test on qemu (#3878)
The test was disabled because of a qemu bug that is presumed to have
since been fixed.

Refs: https://github.com/libuv/libuv/pull/3861
2023-01-12 15:22:19 +01:00
Ben Noordhuis
e972c6705f
build: add UndefinedBehaviorSanitizer support (#3870)
- add UBSAN build option

- turn on UBSAN CI build

Fixes: https://github.com/libuv/libuv/issues/3869
2023-01-04 23:43:50 +01:00
Zvicii
12b8c116a4
build: add define guard around UV_EXTERN (#3855)
Incidentally lets users control the definition of UV_EXTERN.
2023-01-03 22:03:37 +01:00
Ben Noordhuis
e9d91fccfc
darwin: remove unused fsevents symbol lookups (#3867)
One hasn't been in use since 2017, the other since 2013.
2022-12-22 00:51:19 +01:00
Ben Noordhuis
d5cfb89959
test: unflake fs_event_watch_dir test (#3863)
Increase the timer interval. That hopefully ameliorates the problem of
FSEvents.framework missing events on the macOS CI buildbot.

Not really a fix, more a mitigation.

Fixes: https://github.com/libuv/libuv/issues/3862
2022-12-21 07:51:50 +01:00
Ben Noordhuis
a3de1384c3
linux: simplify uv_uptime() (#3859)
Drop support for old kernels. Assume support for CLOCK_BOOTTIME.
2022-12-15 12:57:14 +01:00
Santiago Gimeno
abf77a9eda
test: fix some unreachable code warnings (#3851) 2022-12-10 19:36:46 +01:00
Santiago Gimeno
75d9411e80
win: move child_stdio_buffer out of uv_process_t (#3850) 2022-12-09 13:27:52 +01:00
Ben Noordhuis
cc000cfb5e
build: drop qemu-alpha from ci matrix (#3848)
As of recent, the fs_partial_read and fs_partial_write tests reliably
fail on that architecture.

An upgrade from Ubuntu 20.04 to 22.04 on the CI machines is suspected,
not any changes in libuv itself.

Perhaps it's possible to work around it in the tests but as Alpha is a
dead architecture, it doesn't seem worthwhile to sink time in that.
Let's remove it from the CI matrix instead.

Fixes: https://github.com/libuv/libuv/issues/3843
2022-12-06 22:57:52 +01:00
Santiago Gimeno
e1143f1265 win: fixes in uv__pipe_try_write() (#3825 2/2)
Return `UV_EAGAIN` on `ERROR_OPERATION_ABORTED`.
Use the correct format for `overlapped.hEvent`.
Some refactoring to always wait for the overlapped result.
Modernize tests and some improvements.
2022-12-01 23:16:58 +01:00
Ben Noordhuis
244e0e2059 win: implement uv_try_write() for pipes(#3825 1/2) 2022-12-01 23:16:58 +01:00
Ben Noordhuis
1a91508857 win: fix -Wunused-function warning 2022-12-01 11:27:49 +01:00
Ben Noordhuis
a138041c59 win: fix -Wunused-variable warning 2022-12-01 11:27:49 +01:00
Stefan Stojanovic
c17bd99f1c
win: fix fstat for pipes and character files (#3811)
Calling uv_fs_fstat for file types other then disk type was resulting in
error on Windows while it was retrieving data on Linux. This change
enables getting fstat for pipes and character files on Windows with data
fetched being as reasonable as possible.

A simple test is also added to check this behavior on all platforms. It
uses stdin, stdout and stderr. uv_fs_fstat needs to pass with disk files
pipes and character files (eg. console).

Refs: https://github.com/nodejs/node/issues/40006
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2022-11-29 17:46:09 -05:00
Ben Noordhuis
5102b2c093
unix: drop kfreebsd support (#3835)
Because kFreeBSD is dead. RIP.

Fixes: https://github.com/libuv/libuv/issues/3833
2022-11-28 22:45:28 +01:00
Sergey Rubanov
2c6858a018
Add Socket Runtime to the LINKS.md
PR-URL: https://github.com/libuv/libuv/pull/3834
2022-11-28 09:51:45 -05:00
Ben Noordhuis
8ddffeeea3
doc: bump min supported linux and freebsd versions (#3830)
The old Linux baseline was essentially RHEL 6 but that distro has been
out of support for two years now. Move to RHEL 7.

This commit also moves FreeBSD to tier 2 because it isn't actually
part of libuv's CI matrix, only Node's.

Fixes: https://github.com/libuv/libuv/issues/3822
2022-11-28 12:00:27 +01:00
Ben Noordhuis
238ba3b625
test: fix -Wunused-but-set-variable warnings (#3829) 2022-11-26 22:30:04 +01:00
Tim Besard
988d225cf0
unix,win: add uv_get_available_memory() (#3754) 2022-11-24 22:09:32 +01:00
Edward Humes
a737255791
build: don't use ifaddrs.h on solaris 10 (#3826)
Disable usage of ifaddrs.h on Solaris 10 at configuration time.
2022-11-22 21:46:55 +01:00
daomingq
64669fdd8d
thread: add uv_thread_getcpu() (#3803)
Add uv_thread_getcpu() api to get the cpu number on which the calling
thread is running.
2022-11-15 18:01:29 +01:00
Trevor Norris
e141586053
src: add new metrics APIs (#3749)
The following metrics are now always recorded and available via the new
uv_metrics_info() API.

* loop_count: Number of event loop iterations.
* events: Total number of events processed by the event handler.
* events_waiting: Total number of events waiting in the event queue when
  the event provider request was made.

Benchmarking has shown no noticeable impact recording these metrics.

PR-URL: https://github.com/libuv/libuv/pull/3749
2022-11-11 16:21:58 +01:00
theanarkh
6f69654294
misc: fix return value of memory functions (#3818)
Specifically uv_get_free_memory and uv_get_total_memory.
2022-11-11 10:56:06 +01:00
Santiago Gimeno
3706c4f855 win,pipe: fixes in uv_pipe_connect()
Make unices and windows consistent when closing a pipe while it's
connecting so they all return `UV_ECANCELED`.

Avoid race condition between `pipe_connect_thread_proc()` and `uv_close()` when
accessing `handle->name`.

Fixes: https://github.com/libuv/libuv/issues/3578
2022-11-11 10:44:34 +01:00
Santiago Gimeno
96637d032f win,test: change format of TEST_PIPENAME's
So `WaitNamedPipe()` doesn't fail. Increase the number of clients in
`pipe_connect_multiple` so `CreateFile()` returns `ERROR_PIPE_BUSY` and
the codepath leading to `WaitNamedPipe()` is exercised.
2022-11-11 10:44:34 +01:00
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
Jameson Nash
6999994def
unix,stream: optimize uv_shutdown() codepath (#3646)
Once the write queue is empty, we can fire the event immediately,
without needing a lot of syscalls and then waiting for the kernel to
feed us the event on the next tick. This also makes it more similar to
how it would behave if there was a write still in the queue also, which
we dispatch later in the same event loop iteration, then drain.
2022-07-07 15:24:35 -04:00
Ikko Ashimine
f1635257cb
docs: update introduction.rst (#3664)
Github -> GitHub
2022-07-07 14:07:29 -04:00
Ben Noordhuis
7ca20a2679
unix: retry tcgetattr/tcsetattr() on EINTR (#3669)
EINTR is explicitly documented as a possible error code of tcsetattr().

The documentation for tcgetattr() is silent on the subject but better
safe than sorry.

Fixes: https://github.com/libuv/libuv/issues/3645
2022-07-06 07:41:51 +02:00
Ben Noordhuis
3136561cd0
unix: fix c99 comments (#3667)
Causes compilation errors for people that build libuv with a C89
compiler.

Refs: https://github.com/libuv/libuv/discussions/3666
2022-07-06 07:02:05 +02:00
Jameson Nash
1a91b51976
shutdown,unix: reduce code duplication (#3648)
The UV_ECANCELED codepath had an incorrect comment, and the
implementation was generally less robust (for example, not checking if
`cb` was NULL), so we can merge these codepaths for cleaner code.
2022-06-28 23:44:03 -04:00
Samuel Cabrero
2108309302
unix,tcp: fix errno handling in uv__tcp_bind() (#3652)
The errno value is only meaningful if bind() fails and returns -1.

Some bind() implementations may return success but modify errno value
internally, like the socket_wrapper library used by the Samba testsuite.
2022-06-28 23:42:52 -04:00
Wayne Zhang
27eec099d6
zos: fix early exit of epoll_wait() (#3653)
This fixes an early exit bug in z/OS implementation of epoll_wait(),
resulting in some file events not being correctly captured.

The problem is that reventcount should only be incremented by 1, because
_NFDS counts as 1 even for fds with multiple revents set.

Also makes a few minor improvements to remove redundant checks.

Co-authored-by: Igor Todorovski <itodorov@ca.ibm.com>
2022-06-28 23:42:11 -04:00
Jameson Nash
e3aaff185f
udp,win: fix UDP compiler warning (#3647)
Previously it would pass a pointer to uninitialized memory to WSASendTo,
which triggered a compiler warning. However, `addrlen` will be 0, so it
seems unlikely to trigger an error or uninitialized memory access.

Refs: https://github.com/libuv/leps/pull/10
Refs: https://github.com/libuv/libuv/pull/1872
Refs: https://github.com/libuv/libuv/pull/2217
2022-06-17 16:06:15 -04:00
Wayne Zhang
0b1c752b5c
zos: implement uv_available_parallelism() (#3650)
Implement uv_available_parallelism() for z/OS by reporting the number of
online cpu using __get_num_online_cpus() from ZOSLIB.
2022-06-17 11:55:44 +01:00
theanarkh
8bcd689c04
tcp,pipe: fail bind or listen after close (#3641)
Return `UV_EINVAL` in `bind` and `listen` when `handle` is
`UV_HANDLE_CLOSING` or `UV_HANDLE_CLOSED`.

Fixes: https://github.com/libuv/libuv/issues/3503
2022-06-11 00:32:08 -04:00
Wayne Zhang
d938c104e1 zos: improve memory management of ip addresses (#3640 3/3)
Fixes an issue where under certain conditions, dynamically allocated
ip addresses, strings, and buffers were either leaking memory, being
incorrectly freed, or not performing error checks.

Also fixes an issue where the uv_interface_address_t struct was not
correctly initialized to 0, so use calloc() instead of malloc().

Co-authored-by: Igor Todorovski <itodorov@ca.ibm.com>
2022-06-11 00:26:43 -04:00
Wayne Zhang
524c5ed87d zos: add uv_interface_addresses() netmask support (#3640 2/3)
Use SIOCGIFNETMASK ioctl to retrieve the netmask for IPv4. However, this
approach is not supported for IPv6.

For IPv6 netmask, z/OS currently only provides the prefix length through
the __nif6e_prefixlen in __net_ifconf6entry_t struct, but this can be
used to calculate the IPv6 netmask similar to android implementation.

Co-authored-by: Igor Todorovski <itodorov@ca.ibm.com>
2022-06-11 00:26:33 -04:00
Wayne Zhang
75ad046bfb zos: correctly format interface addresses names (#3640 1/3)
On z/OS, the interface address name contains EBCDIC and may be padded
with whitespaces. The whitespace padding needs to be trimmed, and the
interface address name needs to be converted from EBCDIC to ASCII.

Co-authored-by: John Barboza <jbarboza@ca.ibm.com>
Co-authored-by: Igor Todorovski <itodorov@ca.ibm.com>
2022-06-11 00:26:21 -04:00
Wayne Zhang
77c8e993ec
zos: avoid fs event callbacks after uv_close() (#3620)
On z/OS, fs events are implemented by registering file interest. When
closing a fs event handle, it's possible that a change notification has
already been generated. In that case, the attempt to unregister file
interest will fail with EALREADY. This will result in the fs event being
delivered even though the handle is closing, which should not happen.

Fixes: https://github.com/libuv/libuv/issues/3601
2022-06-11 00:22:06 -04:00
Wayne Zhang
51dcac5da7
zos: don't err when killing a zombie process (#3625)
On z/OS, EPERM is returned if the process being killed is a zombie.
However, this shouldn't be treated as an error, so return 0 instead.

Co-authored-by: Muntasir Mallick <mmallick@ca.ibm.com>
Co-authored-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
2022-05-25 09:12:57 -04:00
Sergey Fedorov
99ab53e998
darwin: fix atomic-ops.h ppc64 build (#3634) 2022-05-24 17:04:47 +02:00
chucksilvers
730e07e2f7
kqueue: skip EVFILT_PROC when invalidating fds (#3629)
On NetBSD with libuv 1.44.1 we see that cmake occasionally hangs
waiting for a child process to exit, with libuv waiting forever for
`kevent` to deliver more events that never come. The child process has
already exited and is waiting to be collected with `waitpid`.

The hang occurs when the batch of events returned by one call to
`kevent` contains both a EVFILT_READ event for an fd and a later
EVFILT_PROC record for the PID with the same value as the earlier fd.
What happens is that `uv__platform_invalidate_fd` is called to
invalidate events later in the same batch for the fd, but
`uv__platform_invalidate_fd` invalidates the later EVFILT_PROC event
too because it sees the same "ident" value and does not check the
"filter" value to differentiate "ident" values that refer to fds vs.
"ident" values that refer to PIDs.

Add a check for the "filter" value to avoid confusing these two
different kinds of event "ident" values.
2022-05-17 13:43:52 +02:00
V-for-Vasili
1b8cc56194
aix,test: uv_backend_fd is not supported by poll (#3621)
Fixes: https://github.com/libuv/libuv/issues/3614
Co-authored-by: Vasili Skurydzin <vasili.skurydzin@ibm.com>
2022-05-13 12:43:28 +02:00
Jameson Nash
ee3718dd71
loop: better align order-of-events behavior between platforms (#3598)
Previously, Windows would always defer event processing to the loop
after they were received. This could cause confusion for users who were
using prepare and idle callbacks, as seen from this bug in nodejs[^1] and
this discussion in libuv[^2], and even some discrepancies in the libuv
tests too[^3].

[^1]: https://github.com/nodejs/node/pull/42340
[^2]: https://github.com/libuv/libuv/discussions/3550
[^3]: See change to test-spawn.c in this PR

So rather than declare those usages to be wrong, we change libuv to meet
those users expectations.

Replaces: https://github.com/libuv/libuv/pull/3585
2022-05-13 12:41:33 +02:00
Jameson Nash
ec67735412
win,pipe: fix bugs with pipe resource lifetime management (#3611)
If `uv_close` was called while a connect was pending, we would fail to
release the resources for the connection, since we had not yet set the
type of the struct.

Fix a thread data-race on slow connect path code: only permitted to
write to `req` on threads, as anything else causes data race
corruption.

There seemed be a small variety of other resource management bugs in
edge cases, which turned out to make this a lot larger than initially
expected.

Refs: https://github.com/libuv/libuv/pull/3598#issuecomment-1111513567
2022-05-13 12:40:02 +02:00
Ben Noordhuis
7825bfb49d
test: remove disabled callback_order test (#3619)
This test has always been disabled for the 10 years of its existence and
there are other tests that exercise "what happens when" event ordering.

Fixes: https://github.com/libuv/libuv/issues/3618
2022-05-09 09:17:35 +02:00
Ben Noordhuis
03a698b9c6
unix: use MSG_CMSG_CLOEXEC where supported (#3609)
Use MSG_CMSG_CLOEXEC on Unix-y platforms that support it (all except
macOS and SunOS spawn.)

Remove the feature test for Linux. Libuv's kernel baseline is 2.6.32
and MSG_CMSG_CLOEXEC was added in 2.6.23.
2022-04-27 22:44:00 +02:00
blogdaren
e0680d3061
doc: fix link to uvwget example main() function (#3605) 2022-04-27 10:23:28 +02:00
tuftedocelot
4e63e48879
openbsd: use utimensat instead of lutimes (#3607)
OpenBSD doesn't have lutimes so utimensat should be used instead.
2022-04-27 10:19:28 +02:00
Ben Noordhuis
a302ad427d
test: rewrite embed test (#3608)
- fix busy loop
- fix multi-thread race conditions
- reduce amount of platform-specific code

Fixes: https://github.com/libuv/libuv/issues/3606
2022-04-27 10:18:40 +02:00
Jameson Nash
9e59aa1bc8
release: check versions of autogen scripts are newer (#3554)
Use libtoolize --force to ensure it updates m4 directory with the
latest files. Add an option "release" to the autogen.sh script that
checks the versions of the input tools, so that we know they are always
using the latest version for each release.
2022-04-19 11:16:25 -04:00
Jameson Nash
7c9b3938df
macos: avoid posix_spawnp() cwd bug (#3597)
macOS 10.15 has a bug where configuring the working directory with
posix_spawn_file_actions_addchdir_np() makes posix_spawnp() fail with
ENOENT even though the executable is spawned successfully.

Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
2022-04-15 14:10:27 -04:00
Ben Noordhuis
6dfcdb9878
doc: remove smartos from supported platforms (#3594)
Commit 3af55129 from 2017 distinguished between smartos and other sunos
spawn but [0] makes it clear ("a new chapter" - barf) that smartos is
dead.

Stop mentioning smartos and put everything under the sunos umbrella.

[0] https://www.joyent.com/blog/a-new-chapter-begins-for-triton-and-smartos
2022-04-12 12:18:01 +02:00
Wayne Zhang
6d9275e412 uv: register __rfim_event 156 as UV_RENAME (#3540 3/3)
When the watched file is moved or removed, or an editor (e.g. vim)
renames then creates the file, the __rfim_event 156 occurs. This is an
undocumented event that should not happen, but register it as UV_RENAME
for now since it is functionally equivalent.

Co-authored-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
2022-04-11 11:31:57 -04:00
Wayne Zhang
571f898192 uv: register UV_RENAME event for _RFIM_UNLINK (#3540 2/3)
`rename()` can be used to rename a file path via _RFIM_UNLINK. So
register it as a UV_RENAME event.

Co-authored-by: Igor Todorovski <itodorov@ca.ibm.com>
2022-04-11 11:31:38 -04:00
Wayne Zhang
07c4cacb58 uv: re-register interest in a file after change (#3540 1/3)
The file is implicitly unregistered when the change notification is
sent, only one notification is sent per registration. So we need to
re-register interest in a file after each change notification we
receive.

Co-authored-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
2022-04-11 11:30:13 -04:00
Andy Fiddaman
612c28b89f
sunos: fs-event callback can be called after uv_close() (#3542)
On illumos and Solaris, fs events are implemented with
PORT_SOURCE_FILE type event ports. These are one-shot so
need re-arming each time they fire. Once they are armed
and an event occurs, the kernel removes them from the current
cache list and puts them on an event queue to be read by
the application.

There's a window in closing one of these ports when it could
have triggered and be pending delivery. In that case, the
attempt to disarm (dissociate) the event will fail with ENOENT
but libuv still goes ahead and closes down the handle. In
particular, the close callback (uv_close() argument) will be
called but then the event will subsequently be delivered if
the loop is still active; this should not happen.
2022-04-11 11:25:59 -04:00
Hannah Shi
b51e940dfa
test: separate some static variables by test cases (#3567) 2022-04-11 11:22:37 -04:00
Jiawen Geng
a78671543b
doc: make sample cross-platform build (#3592)
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
2022-04-11 09:52:28 +08:00
twosee
69ebb2d720
win: fix unexpected ECONNRESET error on TCP socket (#3584) 2022-04-07 21:44:45 -04:00
Ben Noordhuis
1fe609ea05
unix,win: fix UV_RUN_ONCE + uv_idle_stop loop hang (#3590)
Wrong accounting of idle handles in uv_run() made it sleep when there
was nothing left to do. Do a non-blocking poll for I/O instead.
2022-04-06 15:49:21 +02:00
V-for-Vasili
7233c428ec
build: fix AIX xlc autotools build (#3588) 2022-04-06 13:07:05 +01:00
Ben Noordhuis
223e526f27
test: fix flaky file watcher test (#3591)
FSEvents on macOS sometimes sends one change event, sometimes two.
Make the test more lenient.

Fixes #3589.
2022-04-06 13:40:51 +02:00
twosee
e6c67bf803
win: fix incompatible-types warning (#3581)
Introduced by https://github.com/libuv/libuv/pull/3350.
2022-03-31 13:53:41 -04:00
Guilherme Íscaro
2a31fe8552
core: add thread-safe strtok implementation (#3553)
This commit adds the support for a custom strtok implementation, which
is reentrant. On some systems strtok_r or strstep is available for that
purpose; however, since these are an extension, it is difficult to
control if it will be available on every supported system.
2022-03-22 15:15:00 -04:00
V-for-Vasili
9f2ed35da0
test: remove unused declarations in tcp_rst test (#3574)
Refs: https://github.com/libuv/libuv/pull/3482
2022-03-22 15:13:10 -04:00
Denny C. Dai
264f16dcf6
process,iOS: fix build breakage in process.c (#3563)
Remove the `TARGET_OS_IPHONE` ifdef to include posix spawn headers for
iOS build. Previously https://github.com/libuv/libuv/pull/3257
introduced posix spawn with \_\_APPLE\_\_ platform only, which resulted
in a number of spawn related definitions not found for iOS (such as
`uv__posix_spawn_fncs_tag`).

Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2022-03-22 15:11:26 -04:00
Jameson Nash
abf201a894
build: re-enable CI for windows changes (#3572)
I got the conditional reversed in https://github.com/libuv/libuv/pull/3564
2022-03-22 15:09:06 -04:00
Jameson Nash
e64ec13c13
build: add iOS to macos CI (#3564)
Smokescreen for build errors on iOS, currently ignoring failures due to
aforementioned build errors.
2022-03-21 20:32:22 -04:00
Jameson Nash
8528c622b0
build: filter CI by paths and branches (#3569)
Avoids some unnecessary CI work, particularly on forks, which would
often start a build on every push.
2022-03-21 18:34:00 -04:00
Jameson Nash
93309c6dbf
unix: simplify getpwuid call (#3535)
As suggested in https://github.com/libuv/libuv/pull/3523#discussion_r821550169
2022-03-21 15:44:43 -04:00
Darshan Sen
a6ba1d709e
Revert "win,errors: remap ERROR_ACCESS_DENIED to UV_EACCES (#3193)" (#3565)
Although the change remapped the error code to the correct one, a lot of
code already depends on the incorrect one, so it's not worth the
breakage.

This reverts commit 04a35efe69.

Refs: https://github.com/nodejs/node/pull/42340
Signed-off-by: Darshan Sen <raisinten@gmail.com>
2022-03-20 11:06:14 +01:00
Darshan Sen
4d8af0c945
build: remove Windows 2016 workflows (#3379)
Refs: https://github.blog/changelog/2021-10-19-github-actions-the-windows-2016-runner-image-will-be-removed-from-github-hosted-runners-on-march-15-2022/
Signed-off-by: Darshan Sen <darshan.sen@postman.com>
2022-03-20 11:04:19 +01:00
James McCoy
0b23a1ee7e
build: fix kFreeBSD build (#3566)
Define _GNU_SOURCE and link against libdl for dlopen.

Link to freebsd-glue for cmake builds.

This was previously fixed for Makefile builds in
c5d2bf12f7
2022-03-19 11:30:36 +01:00
Ben Noordhuis
ff8290179c
doc: update active maintainers list (#3527) 2022-03-19 10:32:33 +01:00
V-for-Vasili
c1128f3db3
ibmi: Implement UDP disconnect (#3561)
On IBM i a connectionless transport socket can be disconnected by
either setting the addr parameter to NULL or setting the
addr_length parameter to zero, and issuing another connect().

Refs: https://www.ibm.com/docs/en/i/7.4?topic=ssw_ibm_i_74/apis/connec.htm
2022-03-18 12:03:47 +00:00
Claes Nästén
739e441d4d
build: AC_SUBST for AM_CFLAGS (#3551)
Using autoconf 2.71 and automake 1.16.5 the CFLAGS from
CC_CHECK_CFLAGS_APPEND does not get set in the Makefile without AC_SUBST
causing compilation to fail on Solaris due to missing -std=gnu89
2022-03-15 13:51:00 +01:00
Wayne Zhang
442e471cfc
zos: implement cmpxchgi() using assembly (#3543)
Use hand-rolled assembly to resolve a runtime bug related to the codegen
from builtin __plo_CSST.

Co-authored-by: ccw <ccw.280231@ca.ibm.com>
2022-03-13 22:50:09 +01:00
Jameson Nash
bc9cd56345
process: reset the signal mask if the fork fails (#3537)
Fix a regression that sneaked into posix spawn changes.

Refs: https://github.com/libuv/libuv/pull/3257
2022-03-11 12:05:24 -05:00
Jameson Nash
08fe5aabff
build: make CI a bit noisier (#3532)
Github Actions will already hide the output, so we don't need to also
suppress the output. That can sometimes hide problems that might have
only been visible on inspection.
2022-03-11 11:59:38 -05:00
V-for-Vasili
5ec89b8c50
aix, ibmi: handle server hang when remote sends TCP RST (#3482)
Workaround getsockname() not working for a TCP handle that has
received RST from the remote.

Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2022-03-10 23:53:04 +00:00
Jameson Nash
df63ee1a1d Now working on version 1.44.2
Fixes: https://github.com/libuv/libuv/issues/3522
2022-03-09 12:58:37 -05:00
Jameson Nash
ee2668e586 Add SHA to ChangeLog 2022-03-09 12:55:07 -05:00
Jameson Nash
e8b7eb6908 2022.03.09, Version 1.44.1 (Stable)
Changes since version 1.44.0:

* process: simplify uv__write_int calls (Jameson Nash)

* macos: don't use thread-unsafe strtok() (Ben Noordhuis)

* process: fix hang after NOTE_EXIT (Jameson Nash)
2022-03-09 12:54:54 -05:00
Jameson Nash
bae2992cb0
process: fix hang after NOTE_EXIT (#3521)
Bug #3504 seems to affect more platforms than just OpenBSD. As this
seems to be a race condition in these kernels, we do not want to fail
because of it. Instead, we remove the WNOHANG flag from waitpid, and
track exactly which processes have exited. Should also be a slight speed
improvement for excessively large numbers of live children.
2022-03-09 12:25:51 -05:00
Ben Noordhuis
3c569c00df
macos: don't use thread-unsafe strtok() (#3524)
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2022-03-09 11:06:39 +01:00
Jameson Nash
4296fec7f5
process: simplify uv__write_int calls (#3519) 2022-03-07 17:07:49 -05:00
Jameson Nash
761de533b2 Now working on version 1.44.1
Fixes: https://github.com/libuv/libuv/issues/3452
2022-03-07 12:18:03 -05:00
Jameson Nash
8367fc2aac Add SHA to ChangeLog 2022-03-07 11:39:19 -05:00
Jameson Nash
d2bff50845 2022.03.07, Version 1.44.0 (Stable)
Changes since version 1.43.0:

* darwin: remove EPROTOTYPE error workaround (Ben Noordhuis)

* doc: fix v1.43.0 changelog entries (cjihrig)

* win: replace CRITICAL_SECTION+Semaphore with SRWLock (David Machaj)

* darwin: translate EPROTOTYPE to ECONNRESET (Ben Noordhuis)

* android: use libc getifaddrs() (Ben Noordhuis)

* unix: fix STATIC_ASSERT to check what it means to check (Jessica
  Clarke)

* unix: ensure struct msghdr is zeroed in recvmmsg (Ondřej Surý)

* test: test with maximum recvmmsg buffer (Ondřej Surý)

* unix: don't allow too small thread stack size (Ben Noordhuis)

* bsd: ensure mutex is initialized (Ben Noordhuis)

* doc: add gengjiawen as maintainer (gengjiawen)

* process: monitor for exit with kqueue on BSDs (Jeremy Rose)

* test: fix flaky uv_fs_lutime test (Momtchil Momtchev)

* build: fix cmake install locations (Jameson Nash)

* thread,win: fix C90 style nit (ssrlive)

* build: rename CFLAGS to AM_CFLAGS (Jameson Nash)

* doc/guide: update content and sample code (woclass)

* process,bsd: handle kevent NOTE_EXIT failure (Jameson Nash)

* test: remove flaky test ipc_closed_handle (Ben Noordhuis)

* darwin: bump minimum supported version to 10.15 (Ben Noordhuis)

* win: return fractional seconds in uv_uptime() (Luca Adrian L)

* build: export uv_a for cmake (WenTao Ou)

* loop: add pending work to loop-alive check (Jameson Nash)

* win: use GetTickCount64 for uptime again (Jameson Nash)

* win: restrict system DLL load paths (jonilaitinen)

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

* bench: add `uv_queue_work` ping-pong measurement (Momtchil Momtchev)

* build: fix error C4146 on MSVC (UMU)

* test: fix benchmark-ping-udp (Ryan Liptak)

* win,fs: consider broken pipe error a normal EOF (Momtchil Momtchev)

* document the values of enum uv_stdio_flags (Paul Evans)

* win,loop: add missing uv_update_time (twosee)

* win,fs: avoid closing an invalid handle (Jameson Nash)

* fix oopsie from

* doc: clarify android api level (Ben Noordhuis)

* win: fix style nits [NFC] (Jameson Nash)

* test: fix flaky udp_mmsg test (Santiago Gimeno)

* test: fix ipc_send_recv_pipe flakiness (Ben Noordhuis)

* doc: checkout -> check out (wyckster)

* core: change uv_get_password uid/gid to unsigned (Jameson Nash)

* hurd: unbreak build on GNU/Hurd (Vittore F. Scolari)

* freebsd: use copy_file_range() in uv_fs_sendfile() (David Carlier)

* test: use closefd in runner-unix.c (Guilherme Íscaro)

* Reland "macos: use posix_spawn instead of fork" (Jameson Nash)

* android: fix build error when no ifaddrs.h (ssrlive)

* unix,win: add uv_available_parallelism() (Ben Noordhuis)

* process: remove OpenBSD from kevent list (Jameson Nash)

* zos: fix build breakage (Ben Noordhuis)

* process: only use F_DUPFD_CLOEXEC if it is defined (Jameson Nash)

* win,poll: add the MSAFD GUID for AF_UNIX (roflcopter4)

* unix: simplify uv__cloexec_fcntl() (Ben Noordhuis)

* doc: add secondary GPG ID for vtjnash (Jameson Nash)

* unix: remove uv__cloexec_ioctl() (Jameson Nash)
2022-03-07 11:39:08 -05:00
Jameson Nash
20a2b1c341
unix: remove uv__cloexec_ioctl() (#3515)
Now that uv__cloexec_fcntl() is simplified
(https://github.com/libuv/libuv/pull/3492), there is no benefit to
maintaining duplicate code paths for the same thing.
2022-03-06 15:01:33 -05:00
Jameson Nash
538d718ff4
doc: add secondary GPG ID for vtjnash 2022-03-05 13:07:13 -05:00
Ben Noordhuis
c8583bbdf1
unix: simplify uv__cloexec_fcntl() (#3492)
FD_CLOEXEC is the only defined flag for fcntl(F_SETFD) so don't bother
getting the status of that flag first with fcntl(F_GETFD), just set it.
2022-03-05 12:55:49 -05:00
roflcopter4
8e67d8b364
win,poll: add the MSAFD GUID for AF_UNIX (#3511)
Enables the "fast poll" mechanism for the new(ish) Unix sockets in
Windows 10.
2022-03-05 12:54:41 -05:00
Jameson Nash
6ac063d10e
process: only use F_DUPFD_CLOEXEC if it is defined (#3512)
We can save a syscall on most modern systems (required by POSIX 2008),
but not on all systems.

Also handle errors from CLOEXEC. Even though fcntl does not really
define there to be any, it could theoretically be EBADF if the user
happened to pass a bad file descriptor to the same number fd (such that
no other code happened to already fail on that).
2022-03-05 12:52:04 -05:00
Ben Noordhuis
fd34b17f90
zos: fix build breakage (#3513)
Introduced earlier today in commit f250c6c7. _SC_NPROCESSORS_ONLN does
not seem to be defined on that platform.
2022-03-05 10:12:26 +01:00
Jameson Nash
60fbcad9ac
process: remove OpenBSD from kevent list (#3506)
From user reports, it appears that OpenBSD has a broken kevent NOTE_EXIT
implementation. However, we can simply go back to the old, slower
version therefore.

Fix: https://github.com/libuv/libuv/issues/3504
2022-03-04 21:38:31 -05:00
Ben Noordhuis
f250c6c73e
unix,win: add uv_available_parallelism() (#3499)
Replacement for the usage pattern where people use uv_cpu_info() as an
imperfect heuristic for determining the amount of parallelism that is
available to their programs.

Fixes #3493.
2022-03-04 22:35:14 +01:00
ssrlive
c40f8cb9f8
android: fix build error when no ifaddrs.h (#3505) 2022-03-03 13:18:28 +01:00
Jameson Nash
83efa3dd71
Reland "macos: use posix_spawn instead of fork" (#3257)
Fixes: https://github.com/libuv/libuv/issues/3050
Refs: https://github.com/libuv/libuv/issues/3086
Refs: https://github.com/libuv/libuv/pull/3064
Refs: https://github.com/libuv/libuv/pull/3107
Refs: https://github.com/libuv/libuv/pull/3064

This reverts commit 217fdf4265, then fixes
several issues with it:

* remove error fast-cleanup code that triggers a nodejs bug

Refs: https://github.com/libuv/libuv/pull/3107#issuecomment-782482608

* protect posix_spawn from EINTR

This is not a documented valid error, but seems to have been observed.

* ignore setuid/setgid syscall

This kernel function is not permitted unless the process is setuid root,
so disable this syscall. Falling back to fork/exec should be okay for
the rare cases that the user decides they need to do setuid(getuid()) or
setuid(geteuid()) for the child.

Refs: https://github.com/libuv/libuv/pull/3107#issuecomment-782482608

* improve posix_spawn path search

Ports the improvements in musl back to this function

* fix some additional problems and formatting issues

We previously might fail to start a watcher, in rare failure cases,
resulting in a zombie that we would fail to kill. Also avoid creating
the signal-pipe unless required (addresses a review comment from Apple)

* fix fd->fd mapping reuse

There was a chance that when duplicating the fd's into stdio_count+fd we
might be closing a currently opened fd with that value.
2022-03-02 15:15:39 -05:00
Guilherme Íscaro
56e279021f
test: use closefd in runner-unix.c (#3497)
This commit changes the plain close calls to
the closefd function, which will properly check if
close() returns an error.
2022-02-27 11:49:58 +01:00
David CARLIER
993e9ebd07
freebsd: use copy_file_range() in uv_fs_sendfile() (#3496)
Use copy_file_range() on FreeBSD 13 and above.
2022-02-27 11:49:29 +01:00
Vittore F. Scolari
7ae0c9543d
hurd: unbreak build on GNU/Hurd (#3450)
The GNU/Hurd platform does not define IP_ADD_SOURCE_MEMBERSHIP,
IP_DROP_SOURCE_MEMBERSHIP, MCAST_JOIN_SOURCE_GROUP and 
MCAST_LEAVE_SOURCE_GROUP.

Implement a few functions for the GNU/Hurd. Specifically:

* uv_resident_set_memory (from Linux)
* uv_get_free_memory (from Linux)
* uv_get_total_memory (from Linux)
* uv_cpu_info (from cygwin)
* uv__process_title_cleanup (void)
* uv_get_constrained_memory (stub)
* Leave proctitle unimplemented on Hurd for now
* Implement hurdish uv_exepath
* Enable ifaddrs api
* Unbreak udp basics
* Unbreak futime and lutime on Hurd
2022-02-23 12:04:18 -05:00
Jameson Nash
f3e0bffcb1
core: change uv_get_password uid/gid to unsigned (#3476)
Added in https://github.com/libuv/libuv/pull/742, these values are
typically defined as unsigned (since Linux 2.4). Only -1 is special,
representing an invalid id (e.g. see setreuid).
2022-02-22 10:59:06 -05:00
wyckster
c2a345fa67
doc: checkout -> check out (#3489)
"check out" is a verb phrase, but "checkout" is a noun. Since it is
being used as a verb, the spelling "check out" is required.
2022-02-22 10:58:43 -05:00
Ben Noordhuis
e0a5f58d2c
test: fix ipc_send_recv_pipe flakiness (#3478)
The read callback failed to handle the `nread == 0` case, which is rare
to non-existent on the systems we test on but apparently happens often
enough on Solaris on SPARC to draw attention.

Fixes #3469.
2022-02-20 12:17:13 +01:00
Santiago Gimeno
2bc22c40eb test: fix flaky udp_mmsg test
Take into account that the data may not be already available in the
socket causing the `recvmsg()` / `recvmmsg()` calls to return `EAGAIN`
or `EWOULDBLOCK`.

Fixes: https://github.com/libuv/libuv/issues/3479
2022-02-17 17:34:36 +01:00
Jameson Nash
d54c92e3e6
win: fix style nits [NFC] (#3474)
Internal functions usually have a uv__ prefix.
2022-02-15 10:13:24 -05:00
Ben Noordhuis
d41a9a07e4
doc: clarify android api level (#3480)
Google goes to great lengths to obscure the relationship between the two
so explicitly call out the API version matching Android 7.0.
2022-02-15 10:10:22 -05:00
Jameson Nash
cc7dbaa3a1
fix oopsie from #3466 (#3475)
I created `uv__backend_timeout` to be used internally for this reason,
then forgot to use it, resulting in flaky tests and excessive trips
around the uv_run loop.

Fix #3472
2022-02-14 13:37:05 -05:00
Jameson Nash
3b2c25d223
win,fs: avoid closing an invalid handle (#3473)
While usually functional, calling CloseHandle(INVALID_HANDLE_VALUE) can
result in debug builds (and/or wine) being unhappy and aborting there.
2022-02-14 12:29:47 -05:00
twosee
0209466496
win,loop: add missing uv_update_time (#3175)
Time of loop should be updated after the IOCP wait.
2022-02-14 11:40:42 -05:00
Paul Evans
722d003076
document the values of enum uv_stdio_flags (#3039)
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2022-02-14 11:37:19 -05:00
Momtchil Momtchev
df78de04e4
win,fs: consider broken pipe error a normal EOF (#3053)
This would later get translated in src/win/error.c this way, which
previously could lead to rather confusing and inaccurate error messages.
2022-02-13 01:40:10 -05:00
Ryan Liptak
912bb8c577
test: fix benchmark-ping-udp (#2817)
- Fixes the declaration of the benchmark in benchmark-list.h (it was not
  previously runnable at all)
- Fixes the benchmark itself hanging infinitely because the data was
  being dropped via ICMP Destination Unreachable errors (meaning nread
  was always zero in pinger_read_cb)
    + The data getting lost was fixed by binding the udp socket
- Properly checks for UV_UDP_MMSG_CHUNK, just as an example of what
  should generally be done (buf_free is actually a no-op as the buf is
  allocated on the stack)
2022-02-13 01:04:41 -05:00
UMU
8ec1732af0
build: fix error C4146 on MSVC (#3271)
> error C4146: unary minus operator applied to unsigned type, result still unsigned
2022-02-13 00:57:43 -05:00
Momtchil Momtchev
636cb8633b
bench: add uv_queue_work ping-pong measurement (#3425) 2022-02-13 00:40:35 -05:00
Darshan Sen
04a35efe69
win,errors: remap ERROR_ACCESS_DENIED to UV_EACCES (#3193)
If we try to use uv_fs_rmdir on a read-only directory on Windows, it
internally calls _wrmdir, which sets _doserrno to ERROR_ACCESS_DENIED
and errno to EACCES. However, ERROR_ACCESS_DENIED is mapped to
UV_EPERM, so I believe it should be remapped to UV_EACCES.
2022-02-13 00:31:59 -05:00
jonilaitinen
cf7f70c25d
win: restrict system DLL load paths (#3395)
Currently `LoadLibraryA` call first attempts to load the given DLL from
the application working directory before loading it from the system DLL
path. This may pose a security risk if an attacker is able to place a
malicious DLL into the application working directory as that DLL will
be loaded instead of the system DLL. This is especially dangerous if
the application is running with elevated privileges.

This changes the DLL loading to use `LoadLibraryExA` method with
`LOAD_LIBRARY_SEARCH_SYSTEM32` flag which restricts the DLL load
path to system DLL path, ignoring any DLLs in the application working
directory.
2022-02-13 00:26:55 -05:00
Jameson Nash
d0e500c876
win: use GetTickCount64 for uptime again (#3470)
Reverts 442aa1f469, since this is an
improved API in Windows Vista that is now usable as a replacement. It
simplifies the code substantially, while returning nearly the same
result (on my system, the performance counters were 6 seconds behind).

The old code also did not work on Wine-5.0 (where I observed that
`data_size == data_block->HeaderLength`, and so no data was present).
2022-02-13 00:24:34 -05:00
Jameson Nash
939a05633f
loop: add pending work to loop-alive check (#3466)
Pending work may be either (on any platform) pending_queue callbacks or
(on unix) watcher_queue handles to add to the io poll object.
Previously, we might have gotten somewhat stuck if the user caused an
event to be added to one of these in the idle or prepare callbacks, or
was embedding libuv.

Refs: https://github.com/libuv/libuv/pull/3234
Refs: https://github.com/libuv/libuv/issues/3101
Refs: https://github.com/libuv/libuv/pull/3308
2022-02-13 00:12:11 -05:00
WenTao Ou
7a68f5ab4b
build: export uv_a for cmake (#3373) 2022-02-08 11:43:19 -05:00
Luca Adrian L
50c1d00839
win: return fractional seconds in uv_uptime() (#3455)
Some systems return fractional seconds, some return full seconds.
On Windows uptime was artificially rounded down.

Fixes #3447.
2022-02-08 14:23:39 +01:00
Ben Noordhuis
de24da8c11
darwin: bump minimum supported version to 10.15 (#3406)
We can't realistically claim to support 10.7 or any version that Apple
no longer supports so let's bump the baseline to something more
realistic.

Refs: https://github.com/libuv/libuv/pull/482
Refs: https://github.com/libuv/libuv/pull/3405
2022-02-08 14:18:29 +01:00
Ben Noordhuis
038086dc08
test: remove flaky test ipc_closed_handle (#3464)
The test is very flaky, both on the CI and on people's local machines.

I spent some time trying to fix it but its design is fairly questionable
and it fails to test what it should more often than not because on fast
machines no queueing of data takes place.

Fixes #2307.
2022-02-08 14:18:10 +01:00
Jameson Nash
953f901dd2
process,bsd: handle kevent NOTE_EXIT failure (#3451)
The kernel may return ESRCH if the child has already exited here.
This is rather annoying, and means we must indirectly handle
notification to our event loop of the process exit.

Refs: https://github.com/libuv/libuv/pull/3441
Refs: https://github.com/libuv/libuv/pull/3257
2022-02-01 15:27:12 -05:00
woclass
870828c8af
doc/guide: update content and sample code (#3408)
- Add `Makefile` for example codes. (cherry-pick from old uvbook repo)
- Add a new example "Default loop" to "Basics of libuv"/"Default loop"
- Document review and update: `Introduction`, `Basics of libuv`, `Filesystem`
    + Update the referenced libuv code snippet
    + Link update: http->https
    **Content Updates**:
    - `filesystem.rst`#L291-L297: Add note for `uv_fs_event_start`
    - `filesystem.rst`#L334: Add description of the callback function parameter `status`

The following examples have been tested manually in WSL2 (Ubuntu 20.04) with libuv 1.42.0:
- helloworld
- default-loop
- idle-basic
- uvcat
- uvtee
- onchange (test on macOS)

Co-authored-by: Nikhil Marathe <nsm.nikhil@gmail.com>
2022-01-31 16:52:42 -05:00
Jameson Nash
930af43437
build: rename CFLAGS to AM_CFLAGS (#3431)
The CFLAGS variable is reserved and should never be set:
https://www.gnu.org/software/automake/manual/html_node/User-Variables.html
2022-01-31 16:50:32 -05:00
ssrlive
cdced3a3ad
thread,win: fix C90 style nit (#3393) 2022-01-31 16:49:01 -05:00
Jameson Nash
125da33f82
build: fix cmake install locations (#3415)
Adds static libraries and DLL import libraries, as well as making sure
the DLLs go to the correct folder.

Closes #3414
2022-01-31 16:25:20 -05:00
Momtchil Momtchev
e89abc80ea
test: fix flaky uv_fs_lutime test (#3424)
Disable `atime` testing for symlink as this test
is dependant on a race condition on some OSes
(Linux is one) as `lstat` updates the `atime`.
As both `mtime` and `atime` are set by the same
syscall, barring an eventual kernel bug, this
test does not omit any error case.
2022-01-31 16:25:05 -05:00
Jeremy Rose
d9e90857f0
process: monitor for exit with kqueue on BSDs (#3441)
This adds a workaround for an xnu kernel bug that sometimes results in
SIGCHLD not being delivered. The workaround is to use kevent to listen
for EVFILT_PROC/NOTE_EXIT events instead of relying on SIGCHLD on *BSD.
 
Apple rdar: FB9529664
Refs: https://github.com/libuv/libuv/pull/3257
2022-01-31 14:49:22 -05:00
Jiawen Geng
bb0b4bb783
doc: add gengjiawen as maintainer (#3430) 2022-01-20 22:08:14 +08:00
Ben Noordhuis
e43eb667b5
bsd: ensure mutex is initialized (#3428)
The process title mutex was destroyed on library unload without ensuring
it was initialized - and it may not be because it's initialized lazily.

On most platforms it worked by accident because an "all zeroes" mutex is
synonymous with an initialized and unlocked mutex, but not on NetBSD.

Refs: https://github.com/libuv/libuv/pull/3286#issuecomment-1014058782
2022-01-17 12:55:41 +01:00
Ben Noordhuis
b5fa965bcb
unix: don't allow too small thread stack size (#3423)
uv_thread_create_ex() lets you set a stack size that is smaller than is
safe. It enforces a lower bound of PTHREAD_STACK_MIN (when that constant
is defined) but with musl libc that's still too small to receive signals
on.

Put the lower bound at 8192 or PTHREAD_STACK_MIN, whichever is greater.
The same restriction was already in place for the _default_ stack size.
2022-01-17 09:36:26 +01:00
Ondřej Surý
d5ed7f1256 test: test with maximum recvmmsg buffer (#3419)
The maximum numbers receivable by the recvmmsg call is defined in
src/unix/udp.c as UV__MMSG_MAXWIDTH with the current value being 20.

Align the size of the receive buffer in the mmsg test to receive the
maximum number of UDP packets in the test.
2022-01-15 06:24:37 +01:00
Ondřej Surý
e9cb18484e unix: ensure struct msghdr is zeroed in recvmmsg (#3419)
With MUSL libc, the struct msghdr is padded to align with the types used
in the Linux kernel headers (int vs size_t).  When the padding was not
zeroed, the syscall would return EMSGSIZE because the random bytes in
the padding would be read by kernel as part of the size_t type.

Fixes: https://github.com/libuv/libuv/issues/3416
2022-01-15 06:24:37 +01:00
Jessica Clarke
2fbfa0358b
unix: fix STATIC_ASSERT to check what it means to check (#3417)
Currently it's checking pointers to the uv_buf_t fields match the size
of the iovec fields. This is true on traditional architectures where
pointers are just machine word-sized integers, but not on CHERI, and
thus Arm's Morello prototype, where pointers contain additional metadata
(including bounds and permissions). Drop the & to fix this.
2022-01-13 06:20:14 +01:00
Ben Noordhuis
c8cbdbd2c4
android: use libc getifaddrs() (#3412)
Fixes: https://github.com/libuv/libuv/issues/3411
2022-01-13 05:55:25 +01:00
Ben Noordhuis
3a7b95593a
darwin: translate EPROTOTYPE to ECONNRESET (#3413)
macOS versions 10.10 and 10.15 - and presumbaly 10.11 to 10.14, too -
have a bug where a race condition causes the kernel to return EPROTOTYPE
because the socket isn't fully constructed.

It's probably the result of the peer closing the connection and that is
why libuv translates it to ECONNRESET.

Previously, libuv retried until the EPROTOTYPE error went away but some
VPN software causes the same behavior except the error is permanent, not
transient, turning the retry mechanism into an infinite loop.

Refs: https://github.com/libuv/libuv/pull/482
Refs: https://github.com/libuv/libuv/pull/3405
2022-01-12 16:11:43 +01:00
David Machaj
a3e02e5e4a
win: replace CRITICAL_SECTION+Semaphore with SRWLock (#3383)
Fixes: https://github.com/libuv/libuv/issues/3382
2022-01-12 16:07:17 +01:00
Colin Ihrig
2e42847f4e
doc: fix v1.43.0 changelog entries
PR-URL: https://github.com/libuv/libuv/pull/3407
2022-01-09 19:51:43 -05:00
Ben Noordhuis
abb109f30f
darwin: remove EPROTOTYPE error workaround (#3405)
It's been reported in the past that OS X 10.10, because of a race
condition in the XNU kernel, sometimes returns a transient EPROTOTYPE
error when trying to write to a socket. Libuv handles that by retrying
the operation until it succeeds or fails with a different error.

Recently it's been reported that current versions of the operating
system formerly known as OS X fail permanently with EPROTOTYPE under
certain conditions, resulting in an infinite loop.

Because Apple isn't exactly forthcoming with bug fixes or even details,
I'm opting to simply remove the workaround and have the error bubble up.

Refs: https://github.com/libuv/libuv/pull/482
2022-01-09 12:20:15 +01:00
cjihrig
bb6248bca4
Now working on version 1.43.1
Fixes: https://github.com/libuv/libuv/issues/3397
2022-01-04 09:27:20 -05:00
cjihrig
2c31ecb8fa
Add SHA to ChangeLog 2022-01-04 09:18:00 -05:00
cjihrig
988f2bfc4d
2022.01.05, Version 1.43.0 (Stable)
Changes since version 1.42.0:

* run test named ip6_sin6_len (Jameson Nash)

* docs: fix wrong information about scheduling (Mohamed Edrah)

* unix: protect fork in uv_spawn from signals (Jameson Nash)

* drop only successfully sent packets post sendmmsg (Supragya Raj)

* test: fix typo in test-tty-escape-sequence-processing.c (Ikko
  Ashimine)

* cmake: use standard installation layout always (Sylvain Corlay)

* win,spawn: allow UNC path with forward slash (earnal)

* win,fsevent: fix uv_fs_event_stop() assert (Ben Noordhuis)

* unix: remove redundant include in unix.h (

* doc: mark SmartOS as Tier 3 support (

* doc: fix broken links for netbsd's sysctl manpage (

* misc: adjust stalebot deadline (

* test: remove `dns-server.c` as it is not used anywhere (

* build: fix non-cmake android builds (

* doc: replace pyuv with uvloop (

* asan: fix some tests (

* build: add experimental TSAN configuration (

* pipe: remove useless assertion (

* bsd: destroy mutex in uv__process_title_cleanup() (

* build: add windows build to CI (

* win,fs: fix error code in uv_fs_read() and uv_fs_write() ( Sen)

* build: add macos-latest to ci matrix (

* udp: fix &/&& typo in macro condition (

* build: install cmake package module (Petr Menšík)

* win: fix build for mingw32 (

* build: fix build failures with MinGW new headers (erw7)

* build: fix win build with cmake versions before v3.14 (

* unix: support aarch64 in uv_cpu_info() (

* linux: work around CIFS EPERM bug (

* sunos: Oracle Developer Studio support (

* Revert "sunos: Oracle Developer Studio support (

* sunos: Oracle Developer Studio support (

* stream: permit read after seeing EOF (

* thread: initialize uv_thread_self for all threads (

* kqueue: ignore write-end closed notifications (

* macos: fix the cfdata length in uv__get_cpu_speed ( Bache)

* unix,win: add uv_ip_name to get name from sockaddr (

* win,test: fix a few typos (AJ Heller)

* zos: use destructor for uv__threadpool_cleanup() ( Zhang)

* linux: use MemAvailable instead of MemFree (

* freebsd: call dlerror() only if necessary (

* bsd,windows,zos: fix udp disconnect EINVAL (
2022-01-04 09:18:00 -05:00
deal
a865f78124
bsd,windows,zos: fix udp disconnect EINVAL (#3350)
Fixes: https://github.com/libuv/libuv/issues/3344
2022-01-03 11:31:29 +01:00
Jameson Nash
64742416e0
freebsd: call dlerror() only if necessary (#3388)
Similar to the dlopen() codepath.

Refs: https://github.com/JuliaLang/julia/pull/40392
Refs: https://github.com/JuliaLang/julia/issues/39582
2022-01-03 11:25:45 +01:00
Andrey Hohutkin
beb64b0a88
linux: use MemAvailable instead of MemFree (#3351)
Fixes: https://github.com/nodejs/node/issues/23892
2022-01-03 11:24:19 +01:00
Wayne Zhang
0a47e4c771
zos: use destructor for uv__threadpool_cleanup() (#3376)
On z/OS, instead of calling the uv__threadpool_cleanup() function from
inside uv_library_shutdown(), the destructor attribute must be used;
otherwise, tests will fail with exit code 1 and no output. Additionally,
post() does not need to be called when the destructor attribute is used.

Also adds uv__os390_cleanup() function to clean System V message queue
on z/OS.

Co-authored-by: Igor Todorovski <itodorov@ca.ibm.com>
Co-authored-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
2021-12-03 10:04:44 +01:00
AJ Heller
4075298df2
win,test: fix a few typos
PR-URL: https://github.com/libuv/libuv/pull/3375
2021-11-30 23:22:31 -05:00
Campbell He
c7843ecfbc
unix,win: add uv_ip_name to get name from sockaddr (#3368)
uv_ip_name is a kind of wrapper of uv_ip4_name and uv_ip6_name
which can be used after getaddrinfo to get the IP name directly
from addrinfo.ai_addr.
2021-11-25 10:05:15 +01:00
Jesper Storm Bache
1e7074913e
macos: fix the cfdata length in uv__get_cpu_speed (#3356)
We observed crashes inside CFRelease in uv__get_cpu_speed on the new
Mac Book Pro (arm) hardware. The problem is that the stack got
clobbered. On the new mac hardware the returned length is 8.

For the 4 byte case, a temp variable is used to avoid having to add
endian-sensitive offsets.

Fixes: https://github.com/libuv/libuv/issues/3355
2021-11-24 19:50:52 -05:00
Jameson Nash
abfc4f0b15
kqueue: ignore write-end closed notifications (#3277)
The combination EVFILT_WRITE+EV_EOF is valid and indicates that the
reader has disconnected (called `shutdown(SHUT_RD)`). Probably very rare
in practice, but this seems more correct.

Issue noticed (for UV_DISCONNECT clients of uv_poll), while doing
research for https://github.com/libuv/libuv/pull/3250.
2021-11-24 19:37:02 -05:00
Jameson Nash
40bf9a89eb
thread: initialize uv_thread_self for all threads (#3357)
In particular, previously the main thread would have an id of NULL,
which was then not valid to use with any other API that expected a
uv_thread_t handle.
2021-11-24 19:34:57 -05:00
Jameson Nash
b2614a10a5
stream: permit read after seeing EOF (#3361)
On some streams (notably TTYs), it is permitted to continue reading
after getting EOF. So still stop reading on EOF, but allow the user to
reset the stream and try to read again (which may just get EOF).

This relaxes the constraint added in ce15b8405e.
Refs: https://github.com/libuv/libuv/pull/3006
2021-11-24 19:25:47 -05:00
Stacey Marshall
e592ebe9d3
sunos: Oracle Developer Studio support (#3374)
Oracle Developer Studio requires public functions to be
defined as "__global" when "-fvisibility=hidden" used as
added by [#3005](https://github.com/libuv/libuv/pull/3005).
For documentation on `__global` see Reducing Symbol Scope in
Oracle Developer Studio C/C++ guide
https://www.oracle.com/solaris/technologies/symbol-scope.html.

fs_utime_round test failed as timespec.tv_nsec conversion to
double resulted in negative number.  Skip this test for
__SPRO_C builds.

Note that it was necessary to have C99 language features
enabled with Studio compiler (-xc99=all) as version v1.41.0
has other commits that have used C99 features.

Tested with:
- cc: Studio 12.6 Sun C 5.15 SunOS_sparc 152881-05 2019/10/30
- gcc (GCC) 11.2.0

Refs: https://github.com/libuv/libuv/pull/3364
2021-11-24 16:10:13 +01:00
Colin Ihrig
69b811f340
Revert "sunos: Oracle Developer Studio support (#3364)"
This reverts commit 96b26b1ee2.

The commit was reported to break libuv on Illumos systems.
2021-11-19 17:12:04 -05:00
Stacey Marshall
96b26b1ee2
sunos: Oracle Developer Studio support (#3364)
Oracle Solaris linker visibility support.  Option "-fvisibility=hidden"
requires public functions to be defined as "__global".

fs_utime_round test failed as timespec.tv_nsec conversion to double
resulted in negative number.  Skipped this test.

Note that it was necessary to compile with C99 language features.
2021-11-18 11:01:47 +01:00
Ben Noordhuis
0f696da5f0
linux: work around CIFS EPERM bug (#3354)
It's been reported that copy_file_range() on a CIFS mount fails with
an EPERM error, even though the source and target files have the
appropriate permissions.

This is probably a variation on the EPERM error that libuv handles when
it tries to fchmod() a file on a CIFS mount that hasn't been mounted
with the "noperm" option, so let's handle it here too.

This commit applies minor refactoring because the "work around file
system bugs" section got quite unwieldy.

I also snuck in a bug fix where the workaround for buggy CephFS mounts
disabled copy_file_range() permanently.

Fixes: https://github.com/libuv/libuv/issues/3322
2021-11-09 22:17:50 +01:00
Juan José
48e0427533
unix: support aarch64 in uv_cpu_info() (#3327) 2021-11-03 11:13:22 +01:00
AJ Heller
77e6bd4874
build: fix win build with cmake versions before v3.14 (#3343)
Before v3.14, cmake throws the following error:

```
CMake Error at third_party/libuv/CMakeLists.txt:663 (install):
  install Library TARGETS given no DESTINATION!
```

I confirmed on Windows 7 and Windows Server 2016, with about a dozen
cmake versions between 3.7 and 3.22. I also confirmed that the
DESTINATION `${CMAKE_INSTALL_LIBDIR}` is populated with a valid path.

PR-URL: https://github.com/libuv/libuv/pull/3343
2021-11-02 13:58:25 -04:00
erw7
3e90bc76b0
build: fix build failures with MinGW new headers
A structure definition was added to mstcpip.h in
mingw-w64-x86_64-headers-git 9.0.0.6327.f29c1101f,
which causes a conflict and the build fails. Fix this by
changing the name in the definition in mstcpip.h.

PR-URL: https://github.com/libuv/libuv/pull/3345
2021-11-02 11:28:42 -04:00
Nicolas Noble
26b2e5dbb6
win: fix build for mingw32 (#3340)
Commit e9c524aa from pull request https://github.com/libuv/libuv/pull/3149
introduced a hard dependency on `GetHostnameW`, which isn't declared
yet in mingw distributions (see
https://github.com/msys2/MINGW-packages/issues/9667).

This prevents the current version of libuv from building on many mingw
distributions, until such time the next version of mingw is released with
the correct definition for `GetHostnameW`, preventing a lot of projects
depending on libuv from building on mingw properly, as not all
distributions will update to head immediately anyway.

Instead of waiting, let's find the definition ourselves using
`GetProcAddress` and use the pointer instead.

PR-URL: https://github.com/libuv/libuv/pull/3340
2021-11-01 15:09:59 -04:00
Petr Menšík
172d64bc67
build: install cmake package module
If installed into correct location, libuv can be reused in
CMakeLists.txt by:

find_package(libuv)

PR-URL: https://github.com/libuv/libuv/pull/3293
2021-11-01 13:51:06 -04:00
Evan Miller
5246ce458a
udp: fix &/&& typo in macro condition (#3334) 2021-10-20 12:20:23 -04:00
Ben Noordhuis
1e73814fd0
build: add macos-latest to ci matrix (#3331)
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Fixes: https://github.com/libuv/libuv/issues/3325
2021-10-16 15:12:28 +02:00
Darshan Sen
9604b61db6
win,fs: fix error code in uv_fs_read() and uv_fs_write() (#3303)
Just like the Unix counterpart, uv_fs_read() and uv_fs_write() should
throw an EBADF instead of throwing an EPERM when the passed fd has not
been opened with the right flags.

Signed-off-by: Darshan Sen <darshan.sen@postman.com>
2021-10-16 15:11:52 +02:00
Darshan Sen
1cefd94d56
build: add windows build to CI (#3212)
Refs: https://github.com/libuv/libuv/issues/3325
Signed-off-by: Darshan Sen <darshan.sen@postman.com>
2021-10-16 12:25:48 +02:00
Darshan Sen
6cce781b06
bsd: destroy mutex in uv__process_title_cleanup() (#3286)
Signed-off-by: Darshan Sen <darshan.sen@postman.com>
2021-10-16 12:20:50 +02:00
~locpyl-tidnyd
5b00797205
pipe: remove useless assertion (#3302)
This assertion was added when req->write_buffer was a pointer. It was
then checking that write_buffer itself was not NULL. Checking that .base
is not NULL is superfluous because WriteFile will return error 998
(ERROR_NO_ACCESS) if the input buffer is invalid. This assertion fires
on zero-length writes when base==NULL&&len==0.
2021-10-16 12:17:38 +02:00
Jameson Nash
22d6223928
build: add experimental TSAN configuration (#3328) 2021-10-16 12:13:29 +02:00
Jameson Nash
6564ccc900
asan: fix some tests (#3323)
Previously they were just being run incorrectly, but nothing wrong with
the test itself. We were also interpreting an ASAN failure as TEST_SKIP,
so test failures would not actually be reported as CI failures.
2021-10-10 00:57:43 +02:00
Ofek Lev
c273d8b9cf
doc: replace pyuv with uvloop (#3324)
- pyuv is not actively maintained
- uvloop is downloaded 11M/mo, pyuv only 25k/mo

Refs: https://github.com/saghul/pyuv/issues/270#issuecomment-925106097
2021-10-10 00:56:50 +02:00
YAKSH BARIYA
f716265b51
build: fix non-cmake android builds (#3311)
See https://github.com/libuv/libuv/issues/2768#issuecomment-731375392

Patch based upon https://github.com/termux/termux-packages/pull/7529
2021-10-09 15:03:21 +02:00
Darshan Sen
c852be467e
test: remove dns-server.c as it is not used anywhere (#3313)
Signed-off-by: Darshan Sen <darshan.sen@postman.com>
2021-10-09 14:32:31 +02:00
Ben Noordhuis
80373e8eb1
misc: adjust stalebot deadline (#3316)
Three weeks is arguably a little too aggressive and auto-closing is not
a crowd favorite. Bump to four weeks and disable auto-closing.
2021-10-06 23:56:47 +02:00
YAKSH BARIYA
68355e7d15
doc: fix broken links for netbsd's sysctl manpage (#3312) 2021-10-05 21:58:20 +02:00
Ben Noordhuis
7af7318b21
doc: mark SmartOS as Tier 3 support (#3320)
There haven't been active maintainers for this platform for a long time
so back to tier 3 it goes.
2021-10-05 21:46:38 +02:00
Juan José
f6dfbcec76
unix: remove redundant include in unix.h (#3319) 2021-10-05 13:01:25 +02:00
Ben Noordhuis
a39009a5a9
win,fsevent: fix uv_fs_event_stop() assert
Fix a logic error where calling uv_fs_event_stop() from the event
callback tripped on a `handle->dir_handle != INVALID_HANDLE_VALUE`
assert in uv_fs_event_queue_readdirchanges().

Fixes: https://github.com/libuv/libuv/issues/3258
PR-URL: https://github.com/libuv/libuv/pull/3259
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-09-08 11:30:02 -04:00
earnal
7024f8b242
win,spawn: allow UNC path with forward slash
Fixes: https://github.com/libuv/libuv/issues/3159
PR-URL: https://github.com/libuv/libuv/pull/3167
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-09-08 11:27:08 -04:00
Sylvain Corlay
66a3053e70
cmake: use standard installation layout always
Fixes: https://github.com/libuv/libuv/issues/3074
PR-URL: https://github.com/libuv/libuv/pull/3084
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-09-08 10:37:12 -04:00
Ikko Ashimine
50c337a0b1
test: fix typo in test-tty-escape-sequence-processing.c
postion -> position in several comments

PR-URL: https://github.com/libuv/libuv/pull/3284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-09-08 10:02:11 -04:00
Supragya Raj
6530ea2ff2
drop only successfully sent packets post sendmmsg
sendmmsg returns with number of packets sent which can
be less than number of packets requested to be sent. Do
not flush entire write queue and use the returned info
to partially clear the write queue.

Refs: https://github.com/libuv/libuv/issues/3129 (fixes one issue listed)
PR-URL: https://github.com/libuv/libuv/pull/3265
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-08-24 12:20:34 +02:00
Jameson Nash
04289fa326
unix: protect fork in uv_spawn from signals
Years ago, we found that various kernels (linux, macOS) were known to
fail if they try to deliver a signal during this syscall, so we prevent
that from happening. They may have fixed those issues, but it is
generally just a bad time for signals to arrive (glibc blocks them here,
for example, including some more internal ones that it won't let us
touch here).

We try to be a bit conservative, and leave many signals unblocked which
could happen during normal execution and should terminate the process if
they do. There is a small race window after the child starts before we
clear the old handlers, if the user was to send an fake signal from
elsewhere, but that should be quite unlikely.

PR-URL: https://github.com/libuv/libuv/pull/3251
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2021-07-29 12:09:51 -04:00
Mohamed Edrah
84c057a357
docs: fix wrong information about scheduling
Fixes: https://github.com/libuv/libuv/issues/3252
PR-URL: https://github.com/libuv/libuv/pull/3253
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-07-29 12:08:53 -04:00
Jameson Nash
bd7fcf1bfc
run test named ip6_sin6_len
This appears to have been missed in the original PR.

Refs: https://github.com/libuv/libuv/pull/2492
Refs: https://github.com/libuv/libuv/issues/2655 (fixes one issue listed)
PR-URL: https://github.com/libuv/libuv/pull/3246
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-07-21 12:39:13 -04:00
Jameson Nash
574c49f07f Now working on version 1.42.1
Fixes: https://github.com/libuv/libuv/issues/3202
2021-07-20 00:48:41 -04:00
Jameson Nash
8763476155 Add SHA to ChangeLog 2021-07-19 22:44:31 -04:00
Jameson Nash
6ce14710da 2021.07.21, Version 1.42.0 (Stable)
Changes since version 1.41.0:

* doc: fix code highlighting (Darshan Sen)

* test: move to ASSERT_NULL and ASSERT_NOT_NULL test macros (tjarlama)

* zos: build in ascii code page (Shuowang (Wayne) Zhang)

* zos: don't use nanosecond timestamp fields (Shuowang (Wayne) Zhang)

* zos: introduce zoslib (Shuowang (Wayne) Zhang)

* zos: use strnlen() from zoslib (Shuowang (Wayne) Zhang)

* zos: use nanosleep() from zoslib (Shuowang (Wayne) Zhang)

* zos: use __getargv() from zoslib to get exe path (Shuowang (Wayne)
  Zhang)

* zos: treat __rfim_utok as binary (Shuowang (Wayne) Zhang)

* zos: use execvpe() to set environ explictly (Shuowang (Wayne) Zhang)

* zos: use custom proctitle implementation (Shuowang (Wayne) Zhang)

* doc: add instructions for building on z/OS (Shuowang (Wayne) Zhang)

* linux,udp: enable full ICMP error reporting (Ondřej Surý)

* test: fix test-udp-send-unreachable (Ondřej Surý)

* include: fix typo in documentation (Tobias Nießen)

* chore: use for(;;) instead of while (Yash Ladha)

* test: remove string + int warning on udp-pummel (Juan José Arboleda)

* cmake: fix linker flags (Zhao Zhili)

* test: fix stack-use-after-scope (Zhao Zhili)

* unix: expose thread_stack_size() internally (Brandon Cheng)

* darwin: use RLIMIT_STACK for fsevents pthread (Brandon Cheng)

* darwin: abort on pthread_attr_init fail (Brandon Cheng)

* benchmark: remove unreachable code (Matvii Hodovaniuk)

* macos: fix memleaks in uv__get_cpu_speed (George Zhao)

* Make Thread Sanitizer aware of file descriptor close in uv__close()
  (Ondřej Surý)

* darwin: fix iOS compilation and functionality (Hayden)

* linux: work around copy_file_range() cephfs bug (Ben Noordhuis)

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

* zos: fix uv_get_free_memory() (Shuowang (Wayne) Zhang)

* zos: use CVTRLSTG to get total memory accurately (Shuowang (Wayne)
  Zhang)

* ibmi: Handle interface names longer than 10 chars (Kevin Adler)

* docs: update read-the-docs version of sphinx (Jameson Nash)

* unix: refactor uv_try_write (twosee)

* linux-core: add proper divide by zero assert (yiyuaner)

* misc: remove unnecessary _GNU_SOURCE macros (Darshan Sen)

* test: log to stdout to conform TAP spec (bbara)

* win,fs: fix C4090 warning with MSVC (SeverinLeonhardt)

* build: some systems provide dlopen() in libc (Andy Fiddaman)

* include: add EOVERFLOW status code mapping (Darshan Sen)

* unix,fs: use uv__load_relaxed and uv__store_relaxed (Darshan Sen)

* win: fix string encoding issue of uv_os_gethostname (Eagle Liang)

* unix,process: add uv__write_errno helper function (Ricky Zhou)

* Re-merge "unix,stream: clear read/write states on close/eof" (Jameson
  Nash)

* unix,core: fix errno handling in uv__getpwuid_r (Darshan Sen)

* errors: map ESOCKTNOSUPPORT errno (Ryan Liptak)

* doc: uv_read_stop always succeeds (Simon Kissane)

* inet: fix inconsistent return value of inet_ntop6 (twosee)

* darwin: fix -Wsometimes-uninitialized warning (twosee)

* stream: introduce uv_try_write2 function (twosee)

* poll,win: UV_PRIORITIZED option should not assert (twosee)

* src: DragonFlyBSD has mmsghdr struct too (David Carlier)

* cleanup,win: Remove _WIN32 guards on threadpool (James M Snell)

* freebsd: fix an incompatible pointer type warning (Darshan Sen)

* core: Correct the conditionals for {cloexec,nonblock}_ioctl (Ali
  Mohammad Pur)

* win,tcp: make uv_close work more like unix (Jameson Nash)

* doc: more accurate list of valid send_handle's (twosee)

* win,tcp: translate system errors correctly (twosee)

* unix: implement cpu_relax() on ppc64 (Ben Noordhuis)

* docs: move list of project links under PR control (Jameson Nash)

* test: wrong pointer arithmetic multiplier (Erkhes N)

* doc: switch discussion forum to github (Jameson Nash)

* idna: fix OOB read in punycode decoder (Ben Noordhuis)

* build: make sure -fvisibility=hidden is set (Santiago Gimeno)

* illumos: event ports to epoll (tjarlama)

* illumos,tty: UV_TTY_MODE_IO waits for 4 bytes (Joshua M. Clulow)

* doc: add vtjnash GPG ID (Jameson Nash)

* linux: read CPU model information on ppc (Richard Lau)

* darwin: fix uv_barrier race condition (Guilherme Íscaro)

* unix,stream: fix loop hang after uv_shutdown (Jameson Nash)

* doc,udp: note that suggested_size is 1 max-sized dgram (Ryan Liptak)

* mingw: fix building for ARM/AArch64 (Martin Storsjö)

* unix: strnlen is not available on Solaris 10 (Claes Nästén)

* sunos: restore use of event ports (Andy Fiddaman)

* sunos,cmake: use thread-safe errno (Andy Fiddaman)
2021-07-19 22:44:04 -04:00
Andy Fiddaman
7b18d0aa15
sunos,cmake: use thread-safe errno
On illumos, the global errno variable is not thread-safe by default,
requiring that the application be built with gcc's -pthread option, or
that it defines -D_REENTRANT.

This was done already for the autotools build, but not for CMake.

PR-URL: https://github.com/libuv/libuv/pull/3243
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-07-19 22:27:40 -04:00
Andy Fiddaman
5fe597268e
sunos: restore use of event ports
The sunos platform currently covers at least the Solaris and illumos
operating systems. Although these diverged 11 years ago they still share
some common features such as support for event ports.

illumos also has a compatibility wrapper for epoll but this is not
recommended for use over event ports. From the NOTES section of
https://illumos.org/man/5/epoll:

	The epoll facility is implemented for purposes of offering
	compatibility to and portability of Linux-borne
	applications; native applications should continue to prefer
	using event ports... In particular, use of epoll in a
	multithreaded environment is fraught with peril...

Restore the event ports code so that libuv can continue to be used
on Solaris, and to avoid the problems that come with using epoll()
on illumos. The separation of epoll into src/unix/epoll.c has been
retained.

Fixes: https://github.com/libuv/libuv/issues/3241
PR-URL: https://github.com/libuv/libuv/pull/3242
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-07-19 22:19:24 -04:00
Claes Nästén
8ea8f12438
unix: strnlen is not available on Solaris 10
`strnlen` was not available on Solaris 10, so provide a fallback
implementation for it.

PR-URL: https://github.com/libuv/libuv/pull/3152
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-07-19 13:06:51 -04:00
Martin Storsjö
f9ad802fa5
mingw: fix building for ARM/AArch64
Don't use x86 inline assembly in these cases, but fall back to
__sync_fetch_and_or, similar to _InterlockedOr8 in the MSVC case.

This corresponds to what is done in src/unix/atomic-ops.h, where
ARM/AArch64 cases end up implementing cmpxchgi with
__sync_val_compare_and_swap.

PR-URL: https://github.com/libuv/libuv/pull/3236
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-07-14 12:36:30 -04:00
Ryan Liptak
5c85d67bc7
doc,udp: note that suggested_size is 1 max-sized dgram
The intention here is to make working with recvmmsg more
straight-forward, since internally libuv expects buffers that are
multiples of UV__UDP_DGRAM_MAXSIZE, but previously the availability of
that value wasn't readily apparent to the caller.

Closes: https://github.com/libuv/libuv/issues/2822
Closes: https://github.com/libuv/libuv/issues/1025
Closes: https://github.com/libuv/libuv/pull/1114
PR-URL: https://github.com/libuv/libuv/pull/2986
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-07-13 11:20:53 -04:00
Jameson Nash
03f1a6979c
unix,stream: fix loop hang after uv_shutdown
While most users will likely typically call uv_close in their
uv_shutdown callback, some callers (notable nodejs) do not always do
so. This can result in libuv keeping the loop active, even though there
are no outstanding reqs left to handle.

This bug was added in 80f2f826bf, where
the premise of that commit appears to have simply been incorrect, as
demonstrated by the added test.

Refs: https://github.com/libuv/libuv/issues/3202
PR-URL: https://github.com/libuv/libuv/pull/3233
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-07-13 10:54:02 -04:00
Guilherme Íscaro
e49ef4f309
darwin: fix uv_barrier race condition
Prior to this patch a race condition may occur in case a thread tries
to destroy the barrier while other awaiting threads were not notified.
Since the internal mutex and condition variables are destroyed this may
cause an undefined behavior as described by the man pages.

So in order to prevent such scenarios the detroy function will not wait
until all awaiting threads are finished before proceeding.

Fixes: https://github.com/libuv/libuv/issues/3102
PR-URL: https://github.com/libuv/libuv/pull/3162
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-07-09 16:07:18 -04:00
Richard Lau
b12699b1ef
linux: read CPU model information on ppc
Fixes: https://github.com/libuv/libuv/issues/3217
PR-URL: https://github.com/libuv/libuv/pull/3232
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-07-07 16:19:47 -04:00
Jameson Nash
337dbfd968
doc: add vtjnash GPG ID
PR-URL: https://github.com/libuv/libuv/pull/3235
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2021-07-07 15:59:20 -04:00
Joshua M. Clulow
b6d51dc40e
illumos,tty: UV_TTY_MODE_IO waits for 4 bytes
uv_tty_set_mode() allows a tty device to be set to raw mode with
UV_TTY_MODE_RAW, which correctly sets MIN and TIME to appropriate
values for character input. When UV_TTY_MODE_IO is passed, on illumos
systems a compatibility implementation of cfmakeraw() is used that does
_not_ set MIN or TIME. As a result, consumers of IO mode will block
until a minimum of 4 bytes is available on the tty instead of just 1 as
is expected.

PR-URL: https://github.com/libuv/libuv/pull/3219
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-07-02 15:06:18 -04:00
tjarlama
caf22ddbf5
illumos: event ports to epoll
Sunos has added epoll wrappers to offer compatability for binaries
build specifically for linux (https://illumos.org/man/5/epoll). With
this, it's now possible to develop epoll as a generic interface and
share between Linux and SUNOS, similar to kqueue.

Fixes: https://github.com/libuv/libuv/issues/3008
PR-URL: https://github.com/libuv/libuv/pull/3046
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2021-07-02 15:00:37 -04:00
Santiago Gimeno
03d12d1a37
build: make sure -fvisibility=hidden is set
PR-URL: https://github.com/libuv/libuv/pull/3005
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-07-02 14:50:18 -04:00
Ben Noordhuis
b7466e31e4 idna: fix OOB read in punycode decoder
libuv was vulnerable to out-of-bounds reads in the uv__idna_toascii()
function which is used to convert strings to ASCII. This is called by
the DNS resolution function and can lead to information disclosures or
crashes.

Reported by Eric Sesterhenn in collaboration with Cure53 and ExpressVPN.

Reported-By: Eric Sesterhenn <eric.sesterhenn@x41-dsec.de>
Fixes: https://github.com/libuv/libuv/issues/3147
PR-URL: https://github.com/libuv/libuv-private/pull/1
Refs: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-22918
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2021-07-02 14:07:07 -04:00
Jameson Nash
4a27d87a69 doc: switch discussion forum to github
Freenode is gone (replaced by Libera.chat), but IRC was unused anyways.

Fixes: https://github.com/libuv/libuv/issues/3157
Fixes: https://github.com/libuv/libuv/issues/3208
PR-URL: https://github.com/libuv/libuv/pull/3214
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2021-06-30 23:26:40 -04:00
Erkhes N
592cd40af8
test: wrong pointer arithmetic multiplier
PR-URL: https://github.com/libuv/libuv/pull/3216
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-06-30 23:24:35 -04:00
Jameson Nash
9ec6bb914f
docs: move list of project links under PR control
Copied from 
https://github.com/libuv/libuv/wiki/Projects-that-use-libuv, since the 
wiki was vulnerable to spam content.

PR-URL: https://github.com/libuv/libuv/pull/3204
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2021-06-22 13:23:59 -04:00
Darshan Sen
103dbaede3
Revert "win,fs: correct error code in uv_fs_read and uv_fs_write"
This reverts commit 9394216828.

Refs: https://github.com/libuv/libuv/pull/3180
Refs: https://github.com/libuv/libuv/pull/3205
PR-URL: https://github.com/libuv/libuv/pull/3211
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-06-21 16:03:22 -04:00
Ben Noordhuis
963ecc82d0
unix: implement cpu_relax() on ppc64
We also tell the compiler it is not allowed to reorder the PAUSE 
instruction relative to other instructions. It is a mostly theoretical 
issue, but better safe than sorry.

PR-URL: https://github.com/libuv/libuv/pull/2590
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-06-18 23:47:24 -04:00
twosee
9918a17438
win,tcp: translate system errors correctly
PR-URL: https://github.com/libuv/libuv/pull/3200
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-06-18 23:40:00 -04:00
twosee
79d836b996
doc: more accurate list of valid send_handle's
PR-URL: https://github.com/libuv/libuv/pull/3201
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-06-18 23:38:03 -04:00
Jameson Nash
99eb736b4c
win,tcp: make uv_close work more like unix
This is an attempt to fix some resource management issues on Windows. 

Win32 sockets have an issue where it sends an RST packet if there is an 
outstanding overlapped calls. We can avoid that by being certain to 
explicitly cancel our read and write requests first. 

This also removes some conditional cleanup code, since we might as well 
clean it up eagerly (like unix). Otherwise, it looks to me like these 
might cause the accept callbacks to be run after the endgame had freed 
the memory for them. 

The comment here seems mixed up between send and recv buffers. The 
default behavior on calling `closesocket` is already to do a graceful 
shutdown (see 
https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-closesocket
with default l_onoff=zero) if it is the last open handle. The expected 
behavior if there are pending reads in flight is to send an RST packet, 
notifying the client that the server connection was destroyed before 
acknowledging the EOF. 

Additionally, we need to cancel writes explicitly: we need to notify 
Win32 that it is okay to cancel these writes (so it doesn't also 
generate an RST packet on the wire).

Refs: https://github.com/libuv/libuv/pull/3035
Refs: https://github.com/nodejs/node/pull/35946
Refs: https://github.com/nodejs/node/issues/35904
Fixes: https://github.com/libuv/libuv/issues/3034
PR-URL: https://github.com/libuv/libuv/pull/3036
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-06-10 13:12:07 -04:00
Ali Mohammad Pur
6b0051d14d
core: Correct the conditionals for {cloexec,nonblock}_ioctl
These functions are declared with one set of conditionals in the
header, and defined with another set of conditionals in the c file.
This commit makes all decisions regarding `uv__{nonblock,cloexec}_ioctl`
depend on a boolean macro instead.
There's one function that expects `uv__nonblock_ioctl` to be defined,
so that bit of the function is also conditionally compiled.

PR-URL: https://github.com/libuv/libuv/pull/3163
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-06-08 13:10:35 -04:00
Darshan Sen
b201c1a0f0
freebsd: fix an incompatible pointer type warning
Fixes: https://github.com/libuv/libuv/issues/3155
PR-URL: https://github.com/libuv/libuv/pull/3188
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-28 11:42:09 -04:00
James M Snell
a98839d7bf
cleanup,win: Remove _WIN32 guards on threadpool
Fixes: https://github.com/libuv/libuv/issues/2980
Refs: https://github.com/nodejs/node/pull/35021
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-28 11:22:44 -04:00
David CARLIER
07b86b96c8
src: DragonFlyBSD has mmsghdr struct too
Still returns ENOSYS, until the send/recv functions are implemented.

PR-URL: https://github.com/libuv/libuv/pull/3040
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-28 11:18:22 -04:00
twosee
2ce720c6db
poll,win: UV_PRIORITIZED option should not assert
PR-URL: https://github.com/libuv/libuv/pull/3171
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-28 11:11:23 -04:00
Darshan Sen
9394216828
win,fs: correct error code in uv_fs_read and uv_fs_write
Just like the unix counterpart, uv_fs_read and uv_fs_write should throw 
an EBADF instead of manually throwing an EPERM when the passed fd has 
not been opened with the right access flags. 

PR-URL: https://github.com/libuv/libuv/pull/3180
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-28 11:07:51 -04:00
twosee
bcc4f8fdde
stream: introduce uv_try_write2 function
`uv_try_write2(stream, bufs, nbufs, send_handle)` acts like 
`uv_try_write()` and extended write function for sending handles over a 
pipe like `uv_write2`. It always returns `UV_EAGAIN` instead of 
`UV_ENOSYS` on Windows so we can easily write cross-platform code 
without special treatment.

PR-URL: https://github.com/libuv/libuv/pull/3183
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-28 10:57:59 -04:00
twosee
6085bcef8d
darwin: fix -Wsometimes-uninitialized warning
PR-URL: https://github.com/libuv/libuv/pull/3190
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-28 10:52:58 -04:00
twosee
385b7960a0
inet: fix inconsistent return value of inet_ntop6
PR-URL: https://github.com/libuv/libuv/pull/3182
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-27 10:54:33 -04:00
Simon Kissane
4cf638de05 doc: uv_read_stop always succeeds
Fixes: https://github.com/libuv/libuv/issues/3041
PR-URL: https://github.com/libuv/libuv/pull/3076
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-24 16:32:41 -04:00
Ryan Liptak
46451737e6
errors: map ESOCKTNOSUPPORT errno
PR-URL: https://github.com/libuv/libuv/pull/3151
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-05-21 16:34:31 -04:00
Darshan Sen
a064166bd2
unix,core: fix errno handling in uv__getpwuid_r
Fixes: https://github.com/libuv/libuv/issues/3174
PR-URL: https://github.com/libuv/libuv/pull/3177
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-21 16:27:22 -04:00
Jameson Nash
ce15b8405e
Re-merge "unix,stream: clear read/write states on close/eof"
This reverts commit 46f36e3df1.

PR-URL: https://github.com/libuv/libuv/pull/3006
Refs: https://github.com/libuv/libuv/pull/2967
Refs: https://github.com/libuv/libuv/pull/2409
Refs: https://github.com/libuv/libuv/issues/2943
Refs: https://github.com/libuv/libuv/pull/2968
Refs: https://github.com/nodejs/node/pull/36111
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-05-21 16:20:07 -04:00
Ricky Zhou
6dbb1e2e1d
unix,process: add uv__write_errno helper function
No functional changes, but slightly more compact code.

PR-URL: https://github.com/libuv/libuv/pull/3059
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-20 10:53:12 -04:00
Jameson Nash
ac5b21a2c9
Revert "win,build: Add cmake -DSTATIC_VCRT=ON option"
This reverts commit b94934f012.

The required version of cmake (3.15) is newer than we are currently 
using in Android CI (3.10).

PR-URL: https://github.com/libuv/libuv/pull/3172
Refs: https://github.com/libuv/libuv/pull/3085
2021-05-13 23:07:14 -04:00
Eagle Liang
95f88f47f2
win: fix string encoding issue of uv_os_gethostname
Windows API gethostname(buffer, size) return unicode string in char
array. It will cause garbled code if the host name contains non ascii
characters without cast into multi byte char.

This change keep the same encoding with the implementation on
Unix/macOS platform, which is utf-8.

Requires Windows 8 / Server 2012.

Fixes: https://github.com/libuv/libuv/issues/3148
PR-URL: https://github.com/libuv/libuv/pull/3149
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-13 11:42:55 -04:00
Darshan Sen
9864053c9c
unix,fs: use uv__load_relaxed and uv__store_relaxed
This is more clear about the intended semantics with multiple threads.

PR-URL: https://github.com/libuv/libuv/pull/3124
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-13 11:18:43 -04:00
Romain Roffé
b94934f012
win,build: Add cmake -DSTATIC_VCRT=ON option
PR-URL: https://github.com/libuv/libuv/pull/3085
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-13 11:06:22 -04:00
Darshan Sen
9739400d41
include: add EOVERFLOW status code mapping
Refs: https://github.com/nodejs/node/pull/38159#discussion_r610288214
PR-URL: https://github.com/libuv/libuv/pull/3145
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-13 11:01:14 -04:00
Andy Fiddaman
defed50080
build: some systems provide dlopen() in libc
libuv is packaged for OmniOS, an illumos distribution (OpenSolaris fork), and on that platform `libdl.so` is just a legacy stub library that does not need to be linked. `dlopen()` and friends are present in libc.

Changing to using `AC_SEARCH_LIBS()` instead of `AC_CHECK_LIB()` stops the unnecessary linking of libdl.

PR-URL: https://github.com/libuv/libuv/pull/3113
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-12 18:51:36 -04:00
SeverinLeonhardt
882ee25346
win,fs: fix C4090 warning with MSVC
When compiling the current code MSVC prints this warning:

    warning C4090: '=': different 'const' qualifiers

This warning was introduced with dc6fdcd where the `(char*)` cast for
the call to `wcstombs` was removed.

Re-adding this cast to silence the warning.

PR-URL: https://github.com/libuv/libuv/pull/3146
Refs: https://github.com/libuv/libuv/pull/2938
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-12 18:48:29 -04:00
bbara
0714eded19
test: log to stdout to conform TAP spec
The TAP specification [1] explicitely states:
A harness must only read TAP output from standard output and
not from standard error.

[1] https://testanything.org/tap-specification.html

PR-URL: https://github.com/libuv/libuv/pull/3153
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2021-05-12 18:45:47 -04:00
Darshan Sen
5c19f73aa2
misc: remove unnecessary _GNU_SOURCE macros
Since we are building with the `-D_GNU_SOURCE` option turned on, the macro
definitions are not needed anymore.

Refs: https://github.com/libuv/libuv/pull/3165#issuecomment-835747442
PR-URL: https://github.com/libuv/libuv/pull/3168
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2021-05-12 18:42:29 -04:00
yiyuaner
8635170d8f
linux-core: add proper divide by zero assert
PR-URL: https://github.com/libuv/libuv/pull/3166
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2021-05-12 18:41:30 -04:00
twosee
23bebf015b
unix: refactor uv_try_write
This simplifies the code, for better clarify (and performance)!

PR-URL: https://github.com/libuv/libuv/pull/2874
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-05-10 19:44:31 -04:00
Jameson Nash
614bdbc56f
docs: update read-the-docs version of sphinx
This is specified both as best-practice to specify the defaults
explicitly, and as required for updating sphinx from v1.8.5

Refs: https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
PR-URL: https://github.com/libuv/libuv/pull/3154
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-05-10 19:29:25 -04:00
Kevin Adler
af1a79cf49
ibmi: Handle interface names longer than 10 chars
IBM i interface names are based off the associated line description.
Since line descriptions are objects, they have 10 character limit on
their names. However, since IBM i 7.2 interface names may be up to 16
characters long if the interface is for a a VLAN (eg. MYETHLINE1.4094).

To handle this, we must strip off a VLAN ID to get the actual line
description name, since that's what the QDCRLIND API wants. One issue
exists because line descriptions can contain periods and numbers; so
for interface names less than 10 characters long ETH2.4 could be a line
description name or it could be ETH2 with VLAN 4. We follow the
method that the XPF ioctls use: try the interface name directly first
and if an error occurs, try to strip off the VLAN ID.

https://www.ibm.com/docs/en/i/7.4?topic=ssw_ibm_i_74/apis/ioctl.htm#unotes

Fixes: https://github.com/libuv/libuv/issues/3062
PR-URL: https://github.com/libuv/libuv/pull/3144
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-04-28 16:51:30 +01:00
Shuowang (Wayne) Zhang
47e0c5c575
zos: use CVTRLSTG to get total memory accurately
The previous implementation using rcepool would return a value that is
slightly off from the true value of the system's total memory. So use
CVTRLSTG to get total memory instead, which is more accurate. For more
information on CVTRLSTG, see MVS Data Areas Volumes 1 and 3.

Co-authored-by: Gaby Baghdadi <49249542+gabylb@users.noreply.github.com>
PR-URL: https://github.com/libuv/libuv/pull/3141
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-04-04 18:17:07 +02:00
Shuowang (Wayne) Zhang
f15216e9dd
zos: fix uv_get_free_memory()
The previous implementation of `uv_get_free_memory()` on z/OS return
incorrect values. This is because the rceafc field being dereferenced
for the memory values needs to be treated as unsigned int.

Co-authored-by: Igor Todorovski <itodorov@ca.ibm.com>
Co-authored-by: Alex Yung <alex.yung@ibm.com>
Co-authored-by: CW Cheung <ccw.280231@ca.ibm.com>
PR-URL: https://github.com/libuv/libuv/pull/3141
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-04-04 18:16:50 +02:00
Shuowang (Wayne) Zhang
bd4a357b3d
zos: implement uv_get_constrained_memory()
Implementation is based on RLIMIT_MEMLIMIT.

Co-authored-by: Igor Todorovski <itodorov@ca.ibm.com>
PR-URL: https://github.com/libuv/libuv/pull/3133
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-04-04 18:14:17 +02:00
Ben Noordhuis
9737baf004
linux: work around copy_file_range() cephfs bug
Pre-4.20 kernels have a bug where CephFS uses the RADOS copy-from
command when it shouldn't. Fall back to a regular file copy.

Fixes: https://github.com/libuv/libuv/issues/3117
Refs: 6f9718fe41
PR-URL: https://github.com/libuv/libuv/pull/3123
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:59:23 +02:00
Hayden
1addf9b88a
darwin: fix iOS compilation and functionality
PR-URL: https://github.com/libuv/libuv/pull/3106
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:56:18 +02:00
Ondřej Surý
c3fe3cf1bc
Make Thread Sanitizer aware of file descriptor close in uv__close()
Thread Sanitizer can't intercept syscall(SYS_close, fd) that's used
instead of close(fd); on Linux.  That leads to false positives as Thread
Sanitizer thinks the descriptor is still being used by the thread.

clang defines pre- and post- syscall actions, so wrap the close
syscall() into the action macros.  For gcc, use close() from glibc
instead of the syscall. This allows the thread sanitizer to intercept
closing of the file descriptor when libuv is compiled with Thread
Sanitizer.

PR-URL: https://github.com/libuv/libuv/pull/3112
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2021-04-04 17:52:26 +02:00
George Zhao
d2482ae121
macos: fix memleaks in uv__get_cpu_speed
ERROR: LeakSanitizer: detected memory leaks

```
Direct leak of 432 byte(s) in 9 object(s) allocated from:
    #0 0x1062eedc2 in __sanitizer_mz_calloc+0x92 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x46dc2)
    #1 0x7fff20171eb6 in _malloc_zone_calloc+0x3a (libsystem_malloc.dylib:x86_64+0x1beb6)
    #2 0x7fff203ac180 in _CFRuntimeCreateInstance+0x124 (CoreFoundation:x86_64h+0x4180)
    #3 0x7fff203ab906 in __CFStringCreateImmutableFunnel3+0x84d (CoreFoundation:x86_64h+0x3906)
    #4 0x7fff203ab0a1 in CFStringCreateWithCString+0x48 (CoreFoundation:x86_64h+0x30a1)
    #5 0x1056f63e1 in uv__get_cpu_speed darwin.c:267
    #6 0x1056f491e in uv_cpu_info darwin.c:338
```

PR-URL: https://github.com/libuv/libuv/pull/3098
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:50:46 +02:00
Matvii Hodovaniuk
580d1d98e0
benchmark: remove unreachable code
PR-URL: https://github.com/libuv/libuv/pull/3092
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:47:37 +02:00
Brandon Cheng
3e76e47304
darwin: abort on pthread_attr_init fail
`pthread_attr_init` is highly unlikely to fail on macOS. Removing the
fallback behavior here to be consistent with other parts of libuv (e.g.
`src/unix/thread.c`), which simply call `abort()`.

PR-URL: https://github.com/libuv/libuv/pull/3132
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:35:14 +02:00
Brandon Cheng
608ac2e433
darwin: use RLIMIT_STACK for fsevents pthread
This fixes `SIGBUS` crashes on macOS 10.15 due a new change in
`FSEvents.framework` that makes it allocate a large stack array for
event paths. (See the linked nodejs/node issue for details on the
`FSEvents.framework` memory requirements change itself.)

The existing size (`4 * PTHREAD_STACK_MIN` or 32KB) causes a stack
overflow when more than ~1000 events are received at once. Setting this
to `uv__thread_stack_size()` increases it to 8192KB (by default) on
64-bit machines. This value can be configured at runtime on macOS with
`ulimit -s <size-kb>`.

The 32KB limit was originally added to reduce virtual memory
fragmentation on 32-bit systems, which is not a concern on 64-bit
systems.

Fixes: nodejs/node#37697
Refs: joyent/libuv#964
PR-URL: https://github.com/libuv/libuv/pull/3132
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:33:19 +02:00
Brandon Cheng
054a495351
unix: expose thread_stack_size() internally
This function will be used by `uv__fsevents_loop_init` in a future
commit to determine the initial FSEvents pthread stack size.

PR-URL: https://github.com/libuv/libuv/pull/3132
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:32:57 +02:00
Zhao Zhili
e24e5cbc2b
test: fix stack-use-after-scope
In both `test-tcp-open` and `test-udp-open`.

PR-URL: https://github.com/libuv/libuv/pull/3137
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:29:54 +02:00
Zhao Zhili
67994c68fe
cmake: fix linker flags
There is no CMAKE_LINKER_FLAGS_DEBUG.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
PR-URL: https://github.com/libuv/libuv/pull/3137
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:29:27 +02:00
Juan José Arboleda
73084d5604
test: remove string + int warning on udp-pummel
PR-URL: https://github.com/libuv/libuv/pull/3115
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:16:44 +02:00
Yash Ladha
97709e185f
chore: use for(;;) instead of while
In the codebase we have used empty for loop for infinite conditions, so
to bring consistency replaced other occurrences of while in the codebase
with for loop.

PR-URL: https://github.com/libuv/libuv/pull/3128
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:15:35 +02:00
Tobias Nießen
59118e92ca
include: fix typo in documentation
PR-URL: https://github.com/libuv/libuv/pull/3130
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-04-04 17:13:41 +02:00
Ondřej Surý
285a5ea819
test: fix test-udp-send-unreachable
To properly handle sending UDP packet to unreachable address.

PR-URL: https://github.com/libuv/libuv/pull/2872
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-02-17 10:30:13 +01:00
Ondřej Surý
c382d39a85
linux,udp: enable full ICMP error reporting
The Linux kernel suppresses some ICMP error messages by default for UDP
sockets. This commit sets IP_RECVERR/IPV6_RECVERR on the socket to
enable full ICMP error reporting, hopefully resulting in faster failover
to working name servers.

PR-URL: https://github.com/libuv/libuv/pull/2872
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-02-17 10:29:53 +01:00
Shuowang (Wayne) Zhang
c464d21323
doc: add instructions for building on z/OS
PR-URL: https://github.com/libuv/libuv/pull/3060
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-15 17:19:05 +00:00
Shuowang (Wayne) Zhang
c2589424f9
zos: use custom proctitle implementation
ZOSLIB uses `argv[0]` to determine the exepath. So it is necessary to
use an implementation of proctitle that does not modify `argv[0]`. Since
there is currently no support for process titles on z/OS, the custom
proctitle implementation simply stores the desired title in memory.

This resolves failure in tests `get_currentexe` and `process_title` on
z/OS.

PR-URL: https://github.com/libuv/libuv/pull/3060
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-15 17:18:59 +00:00
Shuowang (Wayne) Zhang
f6adf960ce
zos: use execvpe() to set environ explictly
On z/OS, `execvp()` does not set the environment for child process from
`environ` when ran in ASCII mode. Instead, `execvpe()` provided by
ZOSLIB must be used to set the environment explicitly.

PR-URL: https://github.com/libuv/libuv/pull/3060
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-15 17:18:49 +00:00
Shuowang (Wayne) Zhang
880cdc38b8
zos: treat __rfim_utok as binary
`__rfim_utok` is treated as text when it should be treated as binary
while running in ASCII mode, resulting in an unwanted autoconversion. So
undo the conversion explicitly.

PR-URL: https://github.com/libuv/libuv/pull/3060
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-15 17:18:43 +00:00
Shuowang (Wayne) Zhang
d144fea022
zos: use __getargv() from zoslib to get exe path
The ZOSLIB implementation adds support for ASCII code page.

PR-URL: https://github.com/libuv/libuv/pull/3060
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-15 17:18:36 +00:00
Shuowang (Wayne) Zhang
4f36c89cc9
zos: use nanosleep() from zoslib
Since `nanosleep()` is implemented in ZOSLIB, we will remove the libuv
implementation to resolve conflict. The ZOSLIB implementation uses
BPX4CTW (cond_timed_wait).

PR-URL: https://github.com/libuv/libuv/pull/3060
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-15 17:18:30 +00:00
Shuowang (Wayne) Zhang
aef67e5529
zos: use strnlen() from zoslib
Since `strnlen()` is implemented in ZOSLIB, we will remove the libuv
implementation to resolve conflict. The ZOSLIB implementation uses asm.

PR-URL: https://github.com/libuv/libuv/pull/3060
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-15 17:18:25 +00:00
Shuowang (Wayne) Zhang
bf1aea0d5b
zos: introduce zoslib
This commit introduces ZOSLIB for z/OS, which is a C/C++ library that
implements additional POSIX APIs not available in the LE C Runtime
Library, and provides API for EBCDIC <-> ASCII conversion. This library
requires the linker to be set to CXX when building for z/OS. ZOSLIB is
designed to be installed separately, and then linked to libuv with the
`-DZOSLIB_DIR` option.

PR-URL: https://github.com/libuv/libuv/pull/3060
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-15 17:18:16 +00:00
Shuowang (Wayne) Zhang
14d09afa8b
zos: don't use nanosecond timestamp fields
Nanosecond resolution for the timestamp fields `st_atim`, `st_mtim`, and
`st_ctim` are not supported on z/OS.

PR-URL: https://github.com/libuv/libuv/pull/3060
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-15 17:18:09 +00:00
Shuowang (Wayne) Zhang
1073ceaea4
zos: build in ascii code page
PR-URL: https://github.com/libuv/libuv/pull/3060
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-15 17:17:52 +00:00
tjarlama
270d05189c
test: move to ASSERT_NULL and ASSERT_NOT_NULL test macros
Moving to new style test macros will make debugging easier in case
of test failure and improve redability. This commit will replace all
ASSERT macros matching the statement:
`ASSERT(identifier (== or !=) value);`
to:
`ASSERT_(NOT_)NULL(identifier);`

Refs: https://github.com/libuv/libuv/issues/2974
PR-URL: https://github.com/libuv/libuv/pull/3081
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-02-14 10:05:46 +01:00
raisinten
c3d08b5d63
doc: fix code highlighting
Affected docs:
* basics.rst
* filesystem.rst
* eventloops.rst
* networking.rst
* processes.rst
* threads.rst
* utilities.rst

Fixes: https://github.com/libuv/libuv/issues/3033
PR-URL: https://github.com/libuv/libuv/pull/3082
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-02-14 09:13:34 +01:00
cjihrig
4b0d8b2c93
Now working on version 1.41.1
Fixes: https://github.com/libuv/libuv/issues/3086
2021-02-13 12:59:03 -05:00
cjihrig
db1cd9bebc
Add SHA to ChangeLog 2021-02-13 12:57:24 -05:00
cjihrig
1dff88e516
2021.02.14, Version 1.41.0 (Stable)
Changes since version 1.40.0:

* mailmap: update contact information for richardlau (Richard Lau)

* build: add asan checks (gengjiawen)

* unix: report bind error in uv_tcp_connect() (Ben Noordhuis)

* doc: uv_tcp_bind() never returns UV_EADDRINUSE (Ben Noordhuis)

* test: fix pump and tcp_write_batch benchmarks (Santiago Gimeno)

* doc: mark IBM i as Tier 2 support (Jesse Gorzinski)

* doc,poll: add notes (repeated cb & cancel pending cb) (Elad Nachmias)

* linux: fix -Wincompatible-pointer-types warning (Ben Noordhuis)

* linux: fix -Wsign-compare warning (Ben Noordhuis)

* android: add system call api guards (Ben Noordhuis)

* unix,win: harmonize uv_read_start() error handling (Ben Noordhuis)

* unix,win: more uv_read_start() argument validation (Ben Noordhuis)

* build: turn on -fno-strict-aliasing (Ben Noordhuis)

* stream: add uv_pipe and uv_socketpair to the API (Jameson Nash)

* unix,win: initialize timer `timeout` field (Ben Noordhuis)

* bsd-ifaddrs: improve comments (Darshan Sen)

* test: remove unnecessary uv_fs_stat() calls (Ben Noordhuis)

* fs: fix utime/futime timestamp rounding errors (Ben Noordhuis)

* test: ensure reliable floating point comparison (Jameson Nash)

* unix,fs: fix uv_fs_sendfile() (Santiago Gimeno)

* unix: fix uv_fs_stat when using statx (Simon Kadisch)

* linux,macos: fix uv_set_process_title regression (Momtchil Momtchev)

* doc: clarify UDP errors and recvmmsg (Ethel Weston)

* test-getaddrinfo: use example.invalid (Drew DeVault)

* Revert "build: fix android autotools build" (Bernardo Ramos)

* unix,fs: on DVS fs, statx returns EOPNOTSUPP (Mark Klein)

* win, fs: mkdir really return UV_EINVAL for invalid names (Nicholas
  Vavilov)

* tools: migrate tools/make_dist_html.py to python3 (Dominique Dumont)

* unix: fix uv_uptime() on linux (schamberg97)

* unix: check for partial copy_file_range support (Momtchil Momtchev)

* win: bump minimum supported version to windows 8 (Ben Noordhuis)

* poll,unix: ensure safety of rapid fd reuse (Bob Weinand)

* test: fix some warnings (Issam E. Maghni)

* unix: fix uv_uptime() regression (Santiago Gimeno)

* doc: fix versionadded metadata (cjihrig)

* test: fix 'incompatible pointer types' warnings (cjihrig)

* unix: check for EXDEV in uv__fs_sendfile() (Darshan Sen)
2021-02-13 12:57:24 -05:00
Darshan Sen
70f67d8e05
unix: check for EXDEV in uv__fs_sendfile()
copy_file_range will not work when in_fd and out_fd
are not on the same mounted filesystem (pre Linux 5.3).

Refs: https://github.com/nodejs/node/issues/37284
PR-URL: https://github.com/libuv/libuv/pull/3108
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2021-02-13 12:51:46 -05:00
cjihrig
217fdf4265
Revert "macos: use posix_spawn instead of fork"
This reverts commit 39968db643.

This commit caused a number of failures in the Node.js test suite
while attempting to release libuv 1.41.0.

Refs: https://github.com/libuv/libuv/issues/3086
Refs: https://github.com/libuv/libuv/pull/3064
PR-URL: https://github.com/libuv/libuv/pull/3107
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-02-12 17:02:09 -05:00
Juan Pablo Canepa
39968db643 macos: use posix_spawn instead of fork
Applications running on hardened runtime based on Chromium/Electron
create mmap regions using MAP_JIT flag. With macOS Big Sur the fork()
calls done by uv_spawn have become slow. This is because fork() seems
to physically copy all JIT memory regions (no-copy-on-write). On
previous OS, these regions weren't accessible at all in the forked
process, explaining the regression.

The fix is to use posix_spawn() on macOS. This spawns a new process
directly, without copying any memory mappings.

Note that fork() is still used on earlier versions of macOS if the
necessary posix_spawn() platform-specific extensions are not available.

Fixes: https://github.com/libuv/libuv/issues/3050
PR-URL: https://github.com/libuv/libuv/pull/3064
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-02-03 18:30:57 -05:00
cjihrig
9c3d692b39
test: fix 'incompatible pointer types' warnings
Refs: https://github.com/libuv/libuv/pull/2686
PR-URL: https://github.com/libuv/libuv/pull/3088
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2021-01-16 15:07:57 -05:00
Colin Ihrig
493be3ed23
doc: fix versionadded metadata
This commit adds the versionadded metadata for uv_pipe() and
uv_socketpair().

Refs: https://github.com/libuv/libuv/pull/2953
PR-URL: https://github.com/libuv/libuv/pull/3087
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2021-01-04 22:04:25 -05:00
Santiago Gimeno
0101affb68
unix: fix uv_uptime() regression
As it was in the original version of
https://github.com/libuv/libuv/pull/3072, `%lf` must be used in
`sscanf()` as the value is being stored in a `double` and not a `float`.

PR-URL: https://github.com/libuv/libuv/pull/3080
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-12-30 13:13:58 +01:00
Issam E. Maghni
f2c88e037c
test: fix some warnings
Fix declaration after statement and comment syntax.

PR-URL: https://github.com/libuv/libuv/pull/3067
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-12-29 11:51:08 +01:00
Bob Weinand
c9406ba0e3
poll,unix: ensure safety of rapid fd reuse
Consider the following scenario:

uv_poll_init(loop, poll, fd);
uv_poll_start(poll, UV_READABLE, cb);
// the cb gets invoked etc.
uv_poll_stop(poll);

close(fd);
fd = allocate_new_socket(); // allocate_new_socket() is assigned the same fd by "bad luck" from the OS

// some time later:
uv_poll_init(loop, otherpoll, fd);
uv_poll_start(otherpoll, UV_READABLE, cb);

uv_close(poll); // uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.

According to documentation, "however the fd can be safely closed
immediately after a call to uv_poll_stop() or uv_close()."
Though, in this scenario, we close()'d our file descriptor, and by
bad luck we got the same file descriptor again and register a new
handle for it and start polling.

Previously that would lead to an assertion failure, if we were to
properly free the original handle via uv_close().

This commit fixes that by moving the check whether a only a single
poll handle is active to uv_poll_start() instead of the stopping
routines.

Fixes: https://github.com/libuv/libuv/issues/1172
Fixes: https://github.com/bwoebi/php-uv/issues/81
Fixes: https://github.com/b2wdigital/aiologger/issues/82
Fixes: https://github.com/invenia/LibPQ.jl/issues/140
PR-URL: https://github.com/libuv/libuv/pull/2686
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-12-28 11:51:23 -05:00
Ben Noordhuis
a779fccfd1
win: bump minimum supported version to windows 8
* Windows 7 went out of support earlier this year.

* As did Python 2.7. We no longer have to worry about MSVC 2008.
  Python 3.5 and up use VS 2015.

PR-URL: https://github.com/libuv/libuv/pull/2821
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Joao Reis <reis@janeasystems.com>
2020-12-28 12:44:29 +01:00
Momtchil Momtchev
663588e68e
unix: check for partial copy_file_range support
Fixes: https://github.com/libuv/libuv/issues/3069
PR-URL: https://github.com/libuv/libuv/pull/3070
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-12-28 12:22:54 +01:00
schamberg97
b2ccbbb8a4
unix: fix uv_uptime() on linux
First check `/proc/uptime`, then fallback to `clock_gettime()`.

Fixes: https://github.com/libuv/libuv/issues/3068
PR-URL: https://github.com/libuv/libuv/pull/3072
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-12-28 12:18:55 +01:00
Dominique Dumont
4ce3761370
tools: migrate tools/make_dist_html.py to python3
PR-URL: https://github.com/libuv/libuv/pull/2915
Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
2020-12-28 12:06:01 +01:00
Nikolai Vavilov
dd8662b6d2
win, fs: mkdir really return UV_EINVAL for invalid names
Makes uv_fs_mkdir return UV_EINVAL for invalid directory names instead
of UV_ENOENT.

Refs: https://github.com/nodejs/node/issues/31177
PR-URL: https://github.com/libuv/libuv/pull/2601
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-12-28 12:01:51 +01:00
Mark Klein
e756294295
unix,fs: on DVS fs, statx returns EOPNOTSUPP
PR-URL: https://github.com/libuv/libuv/pull/3047
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-12-28 10:12:22 +01:00
Bernardo Ramos
04edfcf686
Revert "build: fix android autotools build"
This reverts commit f961844392.

Fixes: https://github.com/libuv/libuv/issues/2768
Fixes: https://github.com/libuv/libuv/issues/3048
PR-URL: https://github.com/libuv/libuv/pull/3049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-12-28 10:10:29 +01:00
Drew DeVault
7b84b1541c
test-getaddrinfo: use example.invalid
RFC 2606 reserves the .invalid top-level domain for this purpose.

PR-URL: https://github.com/libuv/libuv/pull/3063
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-12-28 09:33:01 +01:00
Ethel Weston
9cc2667f76
doc: clarify UDP errors and recvmmsg
PR-URL: https://github.com/libuv/libuv/pull/3061
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-12-28 09:20:07 +01:00
Momtchil Momtchev
9c6cec803a
linux,macos: fix uv_set_process_title regression
The call to `uv__set_process_title()` had been accidentally removed.

Fixes: https://github.com/libuv/libuv/issues/3037
PR-URL: https://github.com/libuv/libuv/pull/3019
Refs: https://github.com/nodejs/node/issues/35503
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-12-03 18:29:20 +01:00
Simon Kadisch
d3f042817d
unix: fix uv_fs_stat when using statx
Specifically when filling the `st_rdev` field.

Fixes: https://github.com/libuv/libuv/issues/3051
PR-URL: https://github.com/libuv/libuv/pull/3052
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-12-03 17:30:14 +01:00
Santiago Gimeno
263516e0a0
unix,fs: fix uv_fs_sendfile()
Fix the `off_in` argument  in `copy_file_range()`.

Fixes: https://github.com/libuv/libuv/issues/3056
PR-URL: https://github.com/libuv/libuv/pull/3058
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-12-03 17:07:16 +01:00
Jameson Nash
dde98158b5 test: ensure reliable floating point comparison
Without `volatile`, the x87 hardware may re-organize the comparison math
and end up with the wrong answer.

Fixes: one bullet point item of
    https://github.com/libuv/libuv/issues/2655 and the tests from
    https://github.com/libuv/libuv/pull/849 in certain build configurations
PR-URL: https://github.com/libuv/libuv/pull/2747
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-11-28 10:48:40 -05:00
Ben Noordhuis
8d5af5e70e fs: fix utime/futime timestamp rounding errors
`uv_fs_utime()` and `uv_fs_futime()` receive the timestamp as
a `double` and then convert it to `struct timeval` or `struct timespec`
where necessary but the calculation for the sub-second part exhibited
rounding errors for dates in the deep past or the far-flung future,
causing the timestamps to be off by sometimes over half a second on
unix, or to be reinterpreted as unsigned and end up off by more than
just sign but many also decades.

Fixes: https://github.com/nodejs/node/issues/32369 (partially)
PR-URL: https://github.com/libuv/libuv/pull/2747
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-11-28 10:48:18 -05:00
Ben Noordhuis
e823d729ab test: remove unnecessary uv_fs_stat() calls
`check_utime()` already calls `uv_fs_stat()`, no point in doing it
twice.

PR-URL: https://github.com/libuv/libuv/pull/2747
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-11-28 10:48:14 -05:00
Darshan Sen
ba498cb60f
bsd-ifaddrs: improve comments
PR-URL: https://github.com/libuv/libuv/pull/3031
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-11-26 00:49:10 -05:00
Ben Noordhuis
fc2c1a2341
unix,win: initialize timer timeout field
With the addition of `uv_timer_get_due_in()` it's observable with tools like
valgrind that the `timer->timeout` field isn't initialized until the timer
is started.

Fixes the following valgrind warning when running the `timer_init` test:

    ==325215== Conditional jump or move depends on uninitialised value(s)
    ==325215==    at 0x1B0131: uv_timer_get_due_in (timer.c:134)
    ==325215==    by 0x19AF09: run_test_timer_init (test-timer.c:164)
    ==325215==    by 0x119FF1: run_test_part (runner.c:376)
    ==325215==    by 0x11875D: main (run-tests.c:68)
    ==325215==
    ==325215== Conditional jump or move depends on uninitialised value(s)
    ==325215==    at 0x19AF1F: run_test_timer_init (test-timer.c:164)
    ==325215==    by 0x119FF1: run_test_part (runner.c:376)
    ==325215==    by 0x11875D: main (run-tests.c:68)

Fixes: https://github.com/libuv/libuv/issues/3020
PR-URL: https://github.com/libuv/libuv/pull/3038
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-11-18 14:27:56 -05:00
Jameson Nash
4ddc292774
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>
2020-11-09 21:50:09 -05:00
Ben Noordhuis
cbcd0cfc82
build: turn on -fno-strict-aliasing
Turn on `-fno-strict-aliasing` in libuv and add a note in the README for
downstream projects.

Fixes: https://github.com/libuv/libuv/issues/1230
PR-URL: https://github.com/libuv/libuv/pull/2588
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2020-11-06 14:39:00 -05:00
Ben Noordhuis
48cf8c8286 unix,win: more uv_read_start() argument validation
Return `UV_EINVAL` when one or more arguments are NULL.

Fixes: https://github.com/libuv/help/issues/137
PR-URL: https://github.com/libuv/libuv/pull/2795
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2020-11-05 16:41:44 -05:00
Ben Noordhuis
06b7317422 unix,win: harmonize uv_read_start() error handling
The behavior of `uv_read_start()` when the handle is closing or already
busy reading wasn't consistent across platforms. Now it is.

Fixes: https://github.com/libuv/help/issues/137
PR-URL: https://github.com/libuv/libuv/pull/2795
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2020-11-05 16:41:44 -05:00
Ben Noordhuis
04b05605d3
android: add system call api guards
The seccomp filter with older Android SDKs kills the process when libuv
tries to make system calls it doesn't know about.

This commit adds ifdef guards that stop libuv from making those system
calls with affected SDKs.

Fixes: https://github.com/libuv/libuv/issues/2923
PR-URL: https://github.com/libuv/libuv/pull/3027
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-11-05 16:00:46 -05:00
Ben Noordhuis
5166133e24 linux: fix -Wsign-compare warning
Fixes: https://github.com/libuv/libuv/issues/3011
PR-URL: https://github.com/libuv/libuv/pull/3028
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2020-11-05 09:33:29 +01:00
Ben Noordhuis
a00f80812e linux: fix -Wincompatible-pointer-types warning
`ssize_t` is 32 bits on 32 bits architectures, `off_t` is 64 bits
(because libuv builds with `-D_LARGEFILE_SOURCE`.)

Introduced in commit ca10e36149 ("linux: use copy_file_range for
uv_fs_copyfile when possible") merged in July of this year.

Fixes: https://github.com/libuv/libuv/issues/3011
PR-URL: https://github.com/libuv/libuv/pull/3028
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2020-11-05 09:33:09 +01:00
Elad Nachmias
c2afc2f02a
doc,poll: add notes (repeated cb & cancel pending cb)
Added notes to documentation of `uv_poll_t`:
- The callback will be called over-and-over again as long as the socket
remains readable/writable.
- uv_poll_stop() cancels pending callbacks of already happened events.

Fixes: https://github.com/libuv/libuv/issues/1078
PR-URL: https://github.com/libuv/libuv/pull/1100
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-11-04 10:39:29 -05:00
Jesse Gorzinski
11dd3b467f
doc: mark IBM i as Tier 2 support
PR-URL: https://github.com/libuv/libuv/pull/3029
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-11-03 11:39:27 +00:00
Santiago Gimeno
694f23429b
test: fix pump and tcp_write_batch benchmarks
PR-URL: https://github.com/libuv/libuv/pull/2982
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-10-31 16:42:49 +01:00
Ben Noordhuis
03185b785b doc: uv_tcp_bind() never returns UV_EADDRINUSE
It defers the error to uv_listen() or uv_tcp_connect().

PR-URL: https://github.com/libuv/libuv/pull/2218
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-10-27 13:00:59 -04:00
Ben Noordhuis
726af5ebc3 unix: report bind error in uv_tcp_connect()
Fix a bug where libuv forgets about EADDRINUSE errors reported earlier:
uv_tcp_bind() + uv_tcp_connect() seemingly succeed but the socket isn't
actually bound to the requested address.

This bug goes back to at least 2011 if indeed it ever worked at all.

PR-URL: https://github.com/libuv/libuv/pull/2218
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-10-27 13:00:59 -04:00
gengjiawen
97a903309f build: add asan checks
Fixes: https://github.com/libuv/libuv/issues/2999
PR-URL: https://github.com/libuv/libuv/pull/2998
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-10-21 14:52:58 +02:00
Richard Lau
30ff5bf216
mailmap: update contact information for richardlau
PR-URL: https://github.com/libuv/libuv/pull/3010
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-10-02 12:02:39 -04:00
cjihrig
b2a45df044
Now working on version 1.40.1
Fixes: https://github.com/libuv/libuv/issues/3000
2020-09-24 20:37:01 -04:00
cjihrig
6641fe133e
Add SHA to ChangeLog 2020-09-24 20:34:43 -04:00
cjihrig
4e69e33325
2020.09.26, Version 1.40.0 (Stable)
Changes since version 1.39.0:

* udp: add UV_UDP_MMSG_FREE recv_cb flag (Ryan Liptak)

* include: re-map UV__EPROTO from 4046 to -4046 (YuMeiJie)

* doc: correct UV_UDP_MMSG_FREE version added (cjihrig)

* doc: add uv_metrics_idle_time() version metadata (Ryan Liptak)

* win,tty: pass through utf-16 surrogate pairs (Mustafa M)

* unix: fix DragonFly BSD build (Aleksej Lebedev)

* win,udp: fix error code returned by connect() (Santiago Gimeno)

* src: suppress user_timeout maybe-uninitialized (Daniel Bevenius)

* test: fix compiler warning (Vladimír Čunát)

* build: fix the Haiku cmake build (David Carlier)

* linux: fix i386 sendmmsg/recvmmsg support (Ben Noordhuis)

* build: add libuv-static pkg-config file (Nikolay Mitev)

* unix,win: add uv_timer_get_due_in() (Ulrik Strid)

* build,unix: add QNX support (Elad Lahav)

* include: remove incorrect UV__ERR() for EPROTO (cjihrig)
2020-09-24 20:34:43 -04:00
cjihrig
59d875994d
include: remove incorrect UV__ERR() for EPROTO
https://github.com/libuv/libuv/pull/2979 negated the value of
UV__EPROTO on platforms that don't define EPROTO, but it didn't
remove the surrounding UV__ERR() call. This was causing numerous
test failures in Node.js.

Refs: https://github.com/libuv/libuv/issues/3000
PR-URL: https://github.com/libuv/libuv/pull/3003
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-09-24 07:05:19 -04:00
Elad Lahav
ed5b42d5b7
build,unix: add QNX support
Refs: https://github.com/libuv/libuv/pull/2881
PR-URL: https://github.com/libuv/libuv/pull/2991
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-09-22 23:14:46 -04:00
Ulrik Strid
2a1b880f54
unix,win: add uv_timer_get_due_in()
Co-authored-by: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Refs: https://github.com/nodejs/node-report/pull/73
Refs: https://github.com/libuv/libuv/pull/1255
Fixes: https://github.com/libuv/libuv/issues/2950
PR-URL: https://github.com/libuv/libuv/pull/2951
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-09-21 22:15:46 -04:00
Nikolay Mitev
3ee60fa72a
build: add libuv-static pkg-config file
Fixes: https://github.com/libuv/libuv/issues/2988
PR-URL: https://github.com/libuv/libuv/pull/2993
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-09-21 21:53:59 -04:00
Ben Noordhuis
05d4383daa
linux: fix i386 sendmmsg/recvmmsg support
Android/i386 doesn't have separate sendmmsg/recvmmsg system calls,
they're multiplexed through the socketcall system call.

(More precisely, the system calls may be present but the standard
seccomp filter rejects them, whereas socketcall is whitelisted.)

This commit removes the flags and timeout arguments from libuv's
internal system call wrappers because they're always zero and it
makes EINVAL/ENOSYS detection after a failed socketcall() easier.

Fixes: https://github.com/libuv/libuv/issues/2923
PR-URL: https://github.com/libuv/libuv/pull/2925
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-09-20 12:22:33 -04:00
David Carlier
a7b3b0d0e7
build: fix the Haiku cmake build
PR-URL: https://github.com/libuv/libuv/pull/2994
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-09-20 11:47:39 -04:00
Vladimír Čunát
c4e50d9ff5
test: fix compiler warning
PR-URL: https://github.com/libuv/libuv/pull/2992
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-09-20 11:36:47 -04:00
Daniel Bevenius
f4af7ff2d4
src: suppress user_timeout maybe-uninitialized
This commit initializes user_timeout in uv__io_poll to avoid a
maybe-uninitialized warning:

$ cmake .. -DCMAKE_C_FLAGS="-Wmaybe-uninitialized -O3"
...
[ 14%] Building C object CMakeFiles/uv.dir/src/unix/tty.c.o
/libuv/libuv/src/unix/linux-core.c: In function ‘uv__io_poll’:
/libuv/libuv/src/unix/linux-core.c:351:10: warning:
‘user_timeout’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
  351 |       if (timeout == -1)
      |          ^

PR-URL: https://github.com/libuv/libuv/pull/2976
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-09-20 11:33:31 -04:00
Santiago Gimeno
13ca3bfae8
win,udp: fix error code returned by connect()
PR-URL: https://github.com/libuv/libuv/pull/2981
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-09-20 11:07:42 -04:00
Aleksej Lebedev
1136420758
unix: fix DragonFly BSD build
This commit includes patches from dports to fix the DragonFly
BSD build. It also removes the now unused uv_exepath_procfs().

PR-URL: https://github.com/libuv/libuv/pull/2952
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-09-20 11:00:15 -04:00
Mustafa M
aa4fcc49a2 win,tty: pass through utf-16 surrogate pairs
On Windows allow utf-16 surrogate pars to pass through, which allows
conhost on newer Windows versions and other terminal emulators to be
able to render them.

Fixes: https://github.com/libuv/libuv/issues/2909
PR-URL: https://github.com/libuv/libuv/pull/2971
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-09-03 21:38:02 +02:00
Ryan Liptak
8a782f1815
doc: add uv_metrics_idle_time() version metadata
Refs: https://github.com/libuv/libuv/pull/2725
PR-URL: https://github.com/libuv/libuv/pull/2984
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-09-03 11:08:10 -04:00
cjihrig
45478378fd
doc: correct UV_UDP_MMSG_FREE version added
Refs: https://github.com/libuv/libuv/pull/2836
PR-URL: https://github.com/libuv/libuv/pull/2985
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-09-03 11:05:03 -04:00
YuMeiJie
a8bb3b3b2c
include: re-map UV__EPROTO from 4046 to -4046
Refs: https://github.com/libuv/libuv/pull/1687
Fixes: https://github.com/libuv/libuv/issues/2977
PR-URL: https://github.com/libuv/libuv/pull/2979
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-09-02 21:02:43 -04:00
Ryan Liptak
ea17e1cffb
udp: add UV_UDP_MMSG_FREE recv_cb flag
Refs: https://github.com/libuv/libuv/issues/2822
PR-URL: https://github.com/libuv/libuv/pull/2836
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-09-02 20:21:07 -04:00
cjihrig
fa8b4f27c0
Now working on version 1.39.1
Fixes: https://github.com/libuv/libuv/issues/2943
2020-08-24 20:27:18 -04:00
cjihrig
b167e1773f
Add SHA to ChangeLog 2020-08-24 20:25:04 -04:00
cjihrig
25f4b8b8a3
2020.08.26, Version 1.39.0 (Stable)
Changes since version 1.38.1:

* unix: use relaxed loads/stores for clock id (Ben Noordhuis)

* build,win: link to user32.lib and advapi32.lib (George Zhao)

* unix: squelch harmless valgrind warning (ssrlive)

* include: fx c++ style comments warnings (Turbinya)

* build,cmake: Change installation location on MinGW (erw7)

* linux: use copy_file_range for uv_fs_copyfile when possible (Carter
  Li)

* win,tcp: avoid reinserting a pending request (

* docs: improve the descriptions for get memory info (Juan Sebastian
  velez Posada)

* test: add udp-mmsg test (Ryan Liptak)

* udp: add uv_udp_using_recvmmsg query (Ryan Liptak)

* doc: add more error constants (TK-one)

* zos: fix potential event loop stall (Trevor Norris)

* include: add internal fields struct to uv_loop_t (Trevor Norris)

* core: add API to measure event loop idle time (Trevor Norris)

* win,fs: use CreateDirectoryW instead of _wmkdir (Mustafa M)

* win,nfc: fix integer comparison signedness (escherstair)

* win,nfc: use

* win,nfc: removed some unused variables (escherstair)

* win,nfc: add missing return statement (escherstair)

* win,nfc: disable clang-format for

* darwin: use IOKit for uv_cpu_info (Evan Lucas)

* test: fix thread race in process_title_threadsafe (Ben Noordhuis)

* win,fs: avoid implicit access to _doserrno (Jameson Nash)

* test: give hrtime test a custom 20s timeout (Jameson Nash)

* build: add more failed test, for qemu version bump (gengjiawen)

* unix: handle src, dest same in uv_fs_copyfile() (cjihrig)

* unix: error when uv_setup_args() is not called (Ryan Liptak)

* aix: protect uv_exepath() from uv_set_process_title() (Richard Lau)

* fs: clobber req->path on uv_fs_mkstemp() error (tjarlama)

* cmake: fix compile error C2001 on Chinese Windows (司徒玟琅)

* test: avoid double evaluation in ASSERT_BASE macro (tjarlama)

* tcp: fail instantly if local port is unbound (Bartosz Sosnowski)

* doc: fix most sphinx warnings (Jameson Nash)

* nfci: address some style nits (Jameson Nash)

* unix: don't use _POSIX_PATH_MAX (Ben Noordhuis)
2020-08-24 20:25:03 -04:00
cjihrig
46f36e3df1
Revert "unix,stream: clear read/write states on close/eof"
This reverts commit 12be29f185.

The commit in question was introducing failures in the Node.js
test suite.

Refs: https://github.com/libuv/libuv/issues/2943
Refs: https://github.com/libuv/libuv/pull/2967
Refs: https://github.com/libuv/libuv/pull/2409
PR-URL: https://github.com/libuv/libuv/pull/2968
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-08-24 13:38:46 -04:00
Ben Noordhuis
0e6e862049
unix: don't use _POSIX_PATH_MAX
Libuv was using _POSIX_PATH_MAX wrong. Bug introduced in commit b56d279b
("unix: do not require PATH_MAX to be defined") from September 2018.

_POSIX_PATH_MAX is the minimum max path size guaranteed by POSIX, not
the actual max path size of the system libuv runs on. _POSIX_PATH_MAX
is always 256, the real max is often much bigger.

This commit fixes buffer overruns when processing very long paths in
uv_fs_readlink() and uv_fs_realpath() because libuv was not allocating
enough memory to store the result.

Fixes: https://github.com/libuv/libuv/issues/2965
PR-URL: https://github.com/libuv/libuv/pull/2966
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-24 13:24:00 -04:00
Jameson Nash
79c531cb7d
nfci: address some style nits
PR-URL: https://github.com/libuv/libuv/pull/2954
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-08-21 17:25:42 -04:00
Jameson Nash
707dd7f17d
doc: fix most sphinx warnings
PR-URL: https://github.com/libuv/libuv/pull/2956
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-08-18 13:07:04 -04:00
Bartosz Sosnowski
99e88edf73 tcp: fail instantly if local port is unbound
On Windows when connecting to an unavailable port, the connect() will
retry for 2s, even on loopback devices. This uses a call to WSAIoctl to
make the connect() call fail instantly on local connections.

PR-URL: https://github.com/libuv/libuv/pull/2896
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-13 17:07:21 +02:00
tjarlama
904b1c9b47
test: avoid double evaluation in ASSERT_BASE macro
Passing expression as an argument to a function-like macro will replace
all occurrence of the arguments with expressions during preprocessing.
This result in multiple evaluation of the same expression and can
slow-down the program or even change program state. Here ASSERT_BASE
macro gets an expression involving a and b as first argument and macro
definition has a print statement with a and b, which means there is
double evaluation of a and b when the expression evaluates to false. To
avoid double evaluation temporary variables are created to store results
of a and b.

Since the expression argument is dropped from ASSERT_BASE, the macro no
longer works for string assertions. So a new macro, ASSERT_BASE_STR, is
introduced to deal with strings. ASSERT_BASE can still work with
pointers.

Fixes: https://github.com/libuv/libuv/issues/2916
PR-URL: https://github.com/libuv/libuv/pull/2926
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-12 13:13:02 -04:00
司徒玟琅
3fc580ec4a
cmake: fix compile error C2001 on Chinese Windows
Fixes: https://github.com/libuv/libuv/issues/2887
PR-URL: https://github.com/libuv/libuv/pull/2889
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-12 13:07:44 -04:00
tjarlama
e208100fc9
fs: clobber req->path on uv_fs_mkstemp() error
Contents of template variable passed for posix call mkstemp on error
code EINVAL is unknown. On AIX platform, template will get clobbered
on EINVAL and any attempt to read template might result in error.

In libuv, req->path is passed directly to the mkstemp call and
behavior of this string on error is platform dependent. To avoid
portability issues, it's better to have a common behavior on all
platform. For both unix and windows platform libuv will rewrite path
with an empty string on all error cases.

Fixes: https://github.com/libuv/libuv/issues/2913
Refs: https://github.com/nodejs/node/pull/33549
Refs: https://github.com/libuv/libuv/pull/2933
PR-URL: https://github.com/libuv/libuv/pull/2938
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-12 00:27:26 -04:00
Richard Lau
ea92e9c720
aix: protect uv_exepath() from uv_set_process_title()
Store a copy of the original argv[0] to protect `uv_exepath()`
against `uv_set_process_title()` changing the value of argv[0].

Extract common code for finding a program on the current PATH.

Fixes: https://github.com/libuv/libuv/issues/2674
PR-URL: https://github.com/libuv/libuv/pull/2677
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-10 11:27:30 -04:00
Ryan Liptak
07e4168b67
unix: error when uv_setup_args() is not called
This commit updates uv_{get,set}_process_title() to return an
error when uv_setup_args() is needed, but has not been called.

Per-platform behavior after this commit:

- Windows: uv_setup_args() does nothing, get/set process title
  works as before.
- Unix: get/set process title will return ENOBUFS if
  uv_setup_args() wasn't called, if it failed, or if the process
  title memory has been freed by uv__process_title_cleanup()
  (via uv_library_shutdown()).
- AIX: set process title returns ENOBUFS if uv_setup_args()
  wasn't called, if it failed to allocate memory for the argv
  copy, or if the proctitle memory has been freed by
  uv__process_title_cleanup() (via uv_library_shutdown).
  Getting the process title will do the same except it can
  still succeed if uv_setup_args() was called but failed to
  allocate memory for the argv copy.
- BSD: uv_setup_args() is only needed for getting the initial
  process title; if uv_setup_args() is not called then any
  get_process_title calls() before a set_process_title() call
  will return an empty string.
- Platforms that use no-proctitle.c: get will return an empty
  string, set is a no-op (these are the same as before this commit)

Fixes: https://github.com/libuv/libuv/issues/2845
PR-URL: https://github.com/libuv/libuv/pull/2853
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-09 11:52:22 -04:00
cjihrig
278cfa0183
unix: handle src, dest same in uv_fs_copyfile()
This commit handles the case where the source and destination
are the same. This behavior was originally addressed in #2298,
but the test added in that PR doesn't validate the file size
after the operation. This commit also updates the test to check
for that case.

Refs: https://github.com/libuv/libuv/pull/2298
Refs: https://github.com/nodejs/node/issues/34624
PR-URL: https://github.com/libuv/libuv/pull/2947
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-09 11:13:39 -04:00
Jiawen Geng
b2cec846ef
build: add more failed test, for qemu version bump
Fixes: https://github.com/libuv/libuv/pull/2937
PR-URL: https://github.com/libuv/libuv/pull/2939
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-07 10:58:12 -04:00
Jameson Nash
45f2395f5c
test: give hrtime test a custom 20s timeout
The test is supposed to complete in about 3.5s but it can
hit the 10s timeout when run on a system with high load.

Fixes: https://github.com/libuv/libuv/issues/2342 (hopefully?)
Refs: https://github.com/libuv/libuv/pull/2345
PR-URL: https://github.com/libuv/libuv/pull/2944
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-08-06 11:42:08 -04:00
Jameson Nash
ae9d520781
win,fs: avoid implicit access to _doserrno
It is easy to miss that this is accessing MSVC state, while several
users of it were only setting GetLastError.

Refs: https://github.com/libuv/libuv/pull/2921
PR-URL: https://github.com/libuv/libuv/pull/2945
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-08-06 11:40:10 -04:00
Ben Noordhuis
e44781a161 test: fix thread race in process_title_threadsafe
Libuv calls uv__process_title_cleanup() on shutdown, which raced with
one of the threads from the test that calls uv_get_process_title() in
an infinite loop. Change the test to properly shut down the thread
before exiting.

PR-URL: https://github.com/libuv/libuv/pull/2946
Refs: https://github.com/libuv/libuv/pull/2853#issuecomment-665259082
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-06 10:18:29 +02:00
Evan Lucas
87f0765159 darwin: use IOKit for uv_cpu_info
This switches uv_cpu_info from using sysctlbyname to
using IOKit to get the speed of the processors.
macOS on ARM does not currently have the hw.cpufrequency
sysctl. We are able to reliable get the clock frequency
on all architectures by using IOKit.

Fixes: https://github.com/libuv/libuv/issues/2911
PR-URL: https://github.com/libuv/libuv/pull/2914
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-08-04 21:18:32 +02:00
escherstair
cc506dd97c win,nfc: disable clang-format for #include order
PR-URL: https://github.com/libuv/libuv/pull/2854
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-04 12:09:07 -04:00
escherstair
3cd7ee7278 win,nfc: add missing return statement
PR-URL: https://github.com/libuv/libuv/pull/2854
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-04 12:08:55 -04:00
escherstair
98035e2ac1 win,nfc: removed some unused variables
PR-URL: https://github.com/libuv/libuv/pull/2854
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-04 12:07:41 -04:00
escherstair
ffca3fb77b win,nfc: use #pragma warnings() for MSVC only
PR-URL: https://github.com/libuv/libuv/pull/2854
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Co-authored-by: Anna Henningsen <github@addaleax.net>
2020-08-04 11:39:31 -04:00
escherstair
f6e74b1e41 win,nfc: fix integer comparison signedness
PR-URL: https://github.com/libuv/libuv/pull/2854
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-04 11:37:07 -04:00
Mustafa M
509214d669
win,fs: use CreateDirectoryW instead of _wmkdir
No functional changes are intended [NFCI], but this may make it easier
in the future to implement and respect the `modes` flag.

PR-URL: https://github.com/libuv/libuv/pull/2921
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-04 11:06:11 -04:00
Trevor Norris
e8effd4556 core: add API to measure event loop idle time
The API addition `uv_metrics_idle_time()` is a thread safe call that
allows the user to retrieve the amount of time the event loop has spent
in the kernel's event provider (i.e. poll). It was done this way to
allow retrieving this value without needing to interrupt the execution
of the event loop. This option can be enabled by passing
`UV_METRICS_IDLE_TIME` to `uv_loop_configure()`.

One important aspect of this change is, when enabled, to always first
call the event provider with a `timeout == 0`. This allows libuv to know
whether any events were waiting in the event queue when the event
provider was called. The importance of this is because libuv is tracking
the amount of "idle time", not "poll time". Thus the provider entry time
is not recorded when `timeout == 0` (the event provider never idles in
this case).

While this does add a small amount of overhead, when enabled, but the
overhead decreases when the event loop has a heavier load. This is
because poll events will be waiting when the event provider is called.
Thus never actually recording the provider entry time.

Checking if `uv_loop_t` is configured with `UV_METRICS_IDLE_TIME` always
happens in `uv__metrics_set_provider_entry_time()` and
`uv__metrics_update_idle_time()`. Making the conditional logic wrapping
each call simpler and allows for instrumentation to always hook into
those two function calls.

Rather than placing the fields directly on `uv__loop_internal_fields_t`
add the struct `uv__loop_metrics_t` as a location for future metrics API
additions.

Tests and additional documentation has been included.

PR-URL: https://github.com/libuv/libuv/pull/2725
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-04 10:31:42 -04:00
Trevor Norris
70bbc093f1 include: add internal fields struct to uv_loop_t
Add struct `uv__loop_internal_fields_t` as a location for future
additions to `uv_loop_t` while also maintaining v1.x compatibility.

Currently `uv__loop_internal_fields_t` only contains the `flags` field.
The reason for adding the `flags` field is because the same field was
never added to `UV_LOOP_PRIVATE_FIELDS` in Windows as it was in Unix.

The idea for creating a struct and attaching it to `uv_loop_t` for
future API enhancements was taken from a comment by bnoordhuis in:
https://github.com/libuv/libuv/issues/2506#issuecomment-540050665

Also add `internal_fields` to `uv_loop_t` to store the pointer to
`uv__loop_internal_fields_t`. This naming makes more sense than just
using `active_reqs.unused[1]`. To maintain ABI compatibility, shrink the
`unused` array.

PR-URL: https://github.com/libuv/libuv/pull/2725
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-04 10:31:18 -04:00
Trevor Norris
d0e323971e zos: fix potential event loop stall
This is a port of 70002c80 to z/OS to fix the same potential issue that
could effectively enter an infinite loop (but not a busy loop) under
certain conditions when polling for events.

PR-URL: https://github.com/libuv/libuv/pull/2725
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-04 10:26:57 -04:00
JinHyuk Kim
0a8c1c53b6
doc: add more error constants
PR-URL: https://github.com/libuv/libuv/pull/2932
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-07-31 14:29:54 -04:00
Ryan Liptak
6b5aa669db
udp: add uv_udp_using_recvmmsg query
Allows for determining if a buffer large enough for multiple dgrams
should be allocated in alloc_cb of uv_udp_recvstart, for example.
Contributes towards #2822.

PR-URL: https://github.com/libuv/libuv/pull/2830
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-07-28 23:28:18 -04:00
Ryan Liptak
540d723fa4
test: add udp-mmsg test
PR-URL: https://github.com/libuv/libuv/pull/2818
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-07-28 20:14:42 -04:00
Juan Sebastian velez Posada
f7d162477a
docs: improve the descriptions for get memory info
PR-URL: https://github.com/libuv/libuv/pull/2780
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-07-28 17:10:34 -04:00
Michael Penick
f779fd4f05
win,tcp: avoid reinserting a pending request (#2688)
This fix avoids inserting a duplicate pending request in the case where
`WSARecv()` returns an error (e.g. when a connection has been terminated
by its peer) when `uv_read_start()` is called in a read callback.

Fixes: https://github.com/libuv/libuv/issues/2687
PR-URL: https://github.com/libuv/libuv/pull/2688
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-07-28 13:59:08 -04:00
Carter Li
ca10e36149 linux: use copy_file_range for uv_fs_copyfile when possible
Refs: https://github.com/libuv/libuv/issues/925#issuecomment-234696227
PR-URL: https://github.com/libuv/libuv/pull/2352
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-07-28 11:58:04 -04:00
erw7
66632e7a44 build,cmake: Change installation location on MinGW
MinGW prefers a POSIX like file system hierarchy. Therefore, it is appropriate
that the installation destination is the same as UNIX.

PR-URL: https://github.com/libuv/libuv/pull/2697
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-07-28 10:27:49 -04:00
OleksandrKvl
12be29f185 unix,stream: clear read/write states on close/eof
Fixes: https://github.com/libuv/libuv/issues/1798
Refs: https://github.com/libuv/libuv/pull/1825
PR-URL: https://github.com/libuv/libuv/pull/2409
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Co-Authored-By: Jameson Nash <vtjnash@gmail.com>
2020-07-28 09:05:05 -04:00
Turbinya
e0cb4f06c9 include: fx c++ style comments warnings
PR-URL: https://github.com/libuv/libuv/pull/2890
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-07-20 11:49:19 +02:00
ssrlive
1e60e85ac5 unix: squelch harmless valgrind warning
PR-URL: https://github.com/libuv/libuv/pull/2895
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-07-20 11:42:48 +02:00
George Zhao
fd0e24d2cb build,win: link to user32.lib and advapi32.lib
PR-URL: https://github.com/libuv/libuv/pull/2908
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-07-20 11:38:01 +02:00
Ben Noordhuis
10a9c25a12 unix: use relaxed loads/stores for clock id
This was part of commit c70dd705 ("unix: use relaxed loads/stores for
feature checks") and was reviewed as such but I accidentally dropped
it in the rebase before the final merge.

Fixes: https://github.com/libuv/libuv/issues/2884
PR-URL: https://github.com/libuv/libuv/pull/2886
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-07-10 10:10:00 +02:00
cjihrig
032f2b1251
Now working on version 1.38.2
Fixes: https://github.com/libuv/libuv/issues/2898
2020-07-03 12:53:03 -04:00
cjihrig
5b0398262a
Add SHA to ChangeLog 2020-07-03 12:51:27 -04:00
cjihrig
e8b989ea1f
2020.07.04, Version 1.38.1 (Stable)
Changes since version 1.38.0:

* test: use last matching qemu version (cjihrig)

* win, util: rearrange uv_hrtime (Bartosz Sosnowski)

* test: skip signal_multiple_loops test on QEMU (gengjiawen)

* build: add android build to CI (gengjiawen)

* test: extend fs_event_error_reporting timeout (cjihrig)

* build: link libkvm on netbsd only (Alexander Tokmakov)

* linux: refactor /proc file reader logic (Ben Noordhuis)

* linux: read load average from /proc/loadavg (Ben Noordhuis)

* android: remove patch code for below 21 (gengjiawen)

* win: fix visual studio 2008 build (Arenoros)

* win,tty: fix deadlock caused by inconsistent state (lander0s)

* unix: use relaxed loads/stores for feature checks (Ben Noordhuis)

* build: don't .gitignore m4/ax_pthread.m4 (Ben Noordhuis)

* unix: fix gcc atomics feature check (Ben Noordhuis)

* darwin: work around clock jumping back in time (Ben Noordhuis)

* udp: fix write_queue cleanup on sendmmsg error (Santiago Gimeno)

* src: build fix for Android (David Carlier)
2020-07-03 12:51:27 -04:00
David Carlier
40bab5ed71 src: build fix for Android
pipe2 needs GNU source defined.

PR-URL: https://github.com/libuv/libuv/pull/2857
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2020-07-03 15:23:00 +02:00
Santiago Gimeno
84305d8560
udp: fix write_queue cleanup on sendmmsg error
This issue manifested on `connected` udp sockets trying to send
datagrams to a non-existent server and returning `ECONNREFUSED` because
an ICMP error was received before the actual sending was performed.

PR-URL: https://github.com/libuv/libuv/pull/2899
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-07-02 21:29:42 +02:00
Ben Noordhuis
4685be236b darwin: work around clock jumping back in time
It was reported that mach_absolute_time() can jump backward in time when
the machine is suspended. Use mach_continuous_time() when available to
work around that (macOS 10.12 and up.)

Fixes: https://github.com/libuv/libuv/issues/2891
PR-URL: https://github.com/libuv/libuv/pull/2894
Reviewed-By: Phil Willoughby <philwill@fb.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-07-01 10:34:21 +02:00
Ben Noordhuis
41f57320ba unix: fix gcc atomics feature check
`__atomic_load_n()` and friends were added in gcc 4.7.0 but we still
have some centos6 machines with a vintage gcc 4.4.7 from 2012 in the
CI matrix.

PR-URL: https://github.com/libuv/libuv/pull/2888
Refs: https://github.com/libuv/libuv/pull/2886
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-06-18 08:56:19 +02:00
Ben Noordhuis
20756b1a9f build: don't .gitignore m4/ax_pthread.m4
It was reported that the addition of that file without adding an
exception to m4/.gitignore breaks the tarball autotools build because
the file isn't distributed.

Fixes: https://github.com/libuv/libuv/issues/2862
PR-URL: https://github.com/libuv/libuv/pull/2885
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-06-16 11:46:14 +02:00
Ben Noordhuis
c70dd705bc unix: use relaxed loads/stores for feature checks
Make ThreadSanitizer stop complaining about the static variables that
libuv uses to record the presence (or lack) of system calls and other
kernel features.

Fixes: https://github.com/libuv/libuv/issues/2884
PR-URL: https://github.com/libuv/libuv/pull/2886
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-06-16 11:42:51 +02:00
lander0s
aeab873bbe win,tty: fix deadlock caused by inconsistent state
The variable uv__read_console_status is left as IN_PROGRESS when the
operation is canceled ahead of time by the main thread requesting a
trap (race condition?).

This confuses the next call to uv__cancel_read_console(...) causing
a deadlock due to a semaphore acquisition that is never released by
the reading thread.

Setting the status variable back to COMPLETE or NOT_STARTED fixes
the issue.

Ref: https://github.com/nodejs/node/issues/32999

PR-URL: https://github.com/libuv/libuv/pull/2882
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2020-06-15 18:27:54 +02:00
Arenoros
ff3ab317a2 win: fix visual studio 2008 build
Fixes: https://github.com/libuv/libuv/issues/2861
PR-URL: https://github.com/libuv/libuv/pull/2869
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-06-12 12:31:58 +02:00
gengjiawen
e50b631daf android: remove patch code for below 21
PR-URL: https://github.com/libuv/libuv/pull/2880
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-06-12 12:22:06 +02:00
Ben Noordhuis
1c22b44380 linux: read load average from /proc/loadavg
It was reported that uv_loadavg() reports the wrong values inside an
lxc container.

Libuv calls sysinfo(2) but that isn't intercepted by lxc. /proc/loadavg
however is because /proc is a FUSE fs inside the container.

This commit makes libuv try /proc/loadavg first and fall back to
sysinfo(2) in case /proc isn't mounted.

This commit is very similar to commit 3a1be725 ("linux: read free/total
memory from /proc/meminfo") from April 2019.

Fixes: https://github.com/nodejs/node/issues/33791
PR-URL: https://github.com/libuv/libuv/pull/2876
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-06-12 12:17:33 +02:00
Ben Noordhuis
1a89003635 linux: refactor /proc file reader logic
Move common logic into a separate function that will be reused in a
follow-up commit. This commit also adds a minor correctness fix in
that the `read(2)` system call is now retried on `EINTR`.

PR-URL: https://github.com/libuv/libuv/pull/2876
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-06-12 12:17:21 +02:00
Alexander Tokmakov
2967557b66 build: link libkvm on netbsd only
PR-URL: https://github.com/libuv/libuv/pull/2875
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-06-08 11:09:27 +02:00
cjihrig
c70ce9b95f
test: extend fs_event_error_reporting timeout
This test was consistently timing out on macOS. Some printf()
debugging on the CI showed that the test was still making forward
progress, but legitimately timed out. This commit bumps the test
timeout to a value that should provide much more than enough time.

Fixes: https://github.com/libuv/libuv/issues/2775
PR-URL: https://github.com/libuv/libuv/pull/2865
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2020-06-02 16:47:58 -04:00
gengjiawen
93c90191b6
build: add android build to CI
Fixes: https://github.com/libuv/libuv/issues/2855
PR-URL: https://github.com/libuv/libuv/pull/2858
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-06-02 16:39:11 -04:00
gengjiawen
91a38b18c6
test: skip signal_multiple_loops test on QEMU
Fixes: https://github.com/libuv/libuv/issues/2859
PR-URL: https://github.com/libuv/libuv/pull/2860
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-06-02 10:35:17 -04:00
Bartosz Sosnowski
7967448696 win, util: rearrange uv_hrtime
Rearrange math operations in uv_hrtime. This is a workaround for a
probable compiler bug in VS2019.

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

PR-URL: https://github.com/libuv/libuv/pull/2866
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-05-25 17:59:11 +02:00
cjihrig
0356c65f04
test: use last matching qemu version
The QEMU CI broke recently. The calculation to determine the QEMU
version to install now returns multiple versions. This commit
updates the logic to only take the last result (which I think will
be the newest matching version).

PR-URL: https://github.com/libuv/libuv/pull/2864
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-05-24 16:32:32 -04:00
cjihrig
cc51217a31
Now working on version 1.38.1
Fixes: https://github.com/libuv/libuv/issues/2844
2020-05-17 11:36:52 -04:00
cjihrig
a580ae867d
Add SHA to ChangeLog 2020-05-17 11:34:37 -04:00
cjihrig
1ab9ea3790
2020.05.18, Version 1.38.0 (Stable)
Changes since version 1.37.0:

* test: skip poll_duplex and poll_unidirectional on PASE (Xu Meng)

* linux: make cpu_times consistently be milliseconds (James Ross)

* win: DRY uv_poll_start() and uv_poll_stop() (Ben Noordhuis)

* win: DRY uv_poll_close() (Ben Noordhuis)

* unix,win: add uv_library_shutdown() (Ben Noordhuis)

* unix: yield cpu when spinlocking on async handle (Ben Noordhuis)

* win: remove dep on GetQueuedCompletionStatusEx (Colin Finck)

* doc: correct source lines (Shohei YOSHIDA)

* build,android: fix typo (twosee)

* doc: uv_cancel() handles uv_random_t requests (Philip Chimento)

* doc: fix unescaped character (Philip Chimento)

* build,cmake: fix compilation on old MinGW (erw7)

* build: remove unnessesary MSVC warnings (Bartosz Sosnowski)

* win: make uv_udp_init_ex() accept UV_UDP_RECVMMSG (Ben Noordhuis)

* unix: simplify uv__udp_init_ex() (Ben Noordhuis)

* win: remove MAX_PATH limitations (Bartosz Sosnowski)

* build, win: add long path aware manifest (Bartosz Sosnowski)

* doc: check/idle/prepare functions always succeed (Ben Noordhuis)

* darwin: fix build with non-apple compilers (Ben Noordhuis)

* win: support environment variables > 32767 chars (Ben Noordhuis)

* unix: fully initialize struct msghdr (Ben Noordhuis)

* doc: add uv_replace_allocator thread safety warning (twosee)

* unix: fix int overflow when copying large files (Michal Artazov)

* fs: report original error (Bartosz Sosnowski)

* win, fs: add IO_REPARSE_TAG_APPEXECLINK support (Bartosz Sosnowski)

* doc: fix formatting (Ben Noordhuis)

* unix: fix memory leak when uv_loop_init() fails (Anna Henningsen)

* unix: shrink uv_udp_set_source_membership() stack (Ben Noordhuis)

* unix,win: fix wrong sizeof argument to memcpy() (Ben Noordhuis)

* build: check for libraries not provided by libc (Jeroen Roovers)

* doc: fix the order of arguments to calloc() (MasterDuke17)

* unix: don't abort when getrlimit() fails (Ben Noordhuis)

* test: support common user profile on IBMi (Xu Meng)

* build: test on more platforms via QEMU in CI (gengjiawen)
2020-05-17 11:34:37 -04:00
gengjiawen
1c976110d5
build: test on more platforms via QEMU in CI
This commit runs the test suite via QEMU on GitHub Actions on
a variety of platforms.

Fixes: https://github.com/libuv/libuv/issues/2842
PR-URL: https://github.com/libuv/libuv/pull/2846
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-05-17 10:03:20 -04:00
Xu Meng
fcedadcacb
test: support common user profile on IBMi
Previously libuv was tested under the user class QSECOFR on IBM i.
But most IBM i users does not have that authority.
Refine some assertions to support common user profiles on IBM i.

Fixes: https://github.com/libuv/libuv/issues/2851
PR-URL: https://github.com/libuv/libuv/pull/2852
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-05-17 09:41:55 -04:00
Ben Noordhuis
18c7530a75
unix: don't abort when getrlimit() fails
It was reported that `getrlimit(RLIMIT_STACK)` fails on some aarch64
systems due to a glibc bug, where the getrlimit() system call wrapper
invokes the wrong system call.

Libuv could work around that by issuing a `prlimit(2)` system call
instead but since it can't assume that said system call is available
(it was added in Linux 2.6.36, libuv's baseline is 2.6.32) it seems
easier to just use the default 2M stack size when the call fails.

Fixes: https://github.com/nodejs/node/issues/33244
Refs: https://bugzilla.redhat.com/show_bug.cgi?id=1813089
PR-URL: https://github.com/libuv/libuv/pull/2848
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2020-05-17 09:25:50 -04:00
MasterDuke17
5a0779ba32
doc: fix the order of arguments to calloc()
PR-URL: https://github.com/libuv/libuv/pull/2835
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-05-17 09:22:00 -04:00
Jeroen Roovers
b4fe4f6ad9
build: check for libraries not provided by libc
Using AC_CHECK_LIB ignores symbols already provided by
other libraries, or in other words it links libuv against
libraries that it does not need.

Attempts to remove specific libraries were met with arguments
that older libc versions would still require them.[0]

Fix this by using AC_SEARCH_LIBS instead of AC_CHECK_LIB while
using AX_PTHREAD for POSIX threads.

[0] E.g. https://github.com/libuv/libuv/pull/2493

PR-URL: https://github.com/libuv/libuv/pull/2823
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-05-17 09:16:13 -04:00
Ben Noordhuis
36549815ee unix,win: fix wrong sizeof argument to memcpy()
Libuv was copying `sizeof(struct sockaddr_storage)` bytes from source to
destination but the source was only `sizeof(struct sockaddr_in6)` bytes
big, or approximately 128 vs. 16 bytes.

Fixes: https://github.com/libuv/libuv/issues/2840
PR-URL: https://github.com/libuv/libuv/pull/2841
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-05-12 12:39:35 +02:00
Ben Noordhuis
78c65d0f10 unix: shrink uv_udp_set_source_membership() stack
Replace two biggish `struct sockaddr_storage` instances with a union
of `struct sockaddr_in` and `struct sockaddr_in6`, the latter being
the largest that function supports.

PR-URL: https://github.com/libuv/libuv/pull/2841
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-05-12 12:39:04 +02:00
Anna Henningsen
55dede5b6f
unix: fix memory leak when uv_loop_init() fails
`uv_signal_init()` leads to the allocation of an IO watcher,
so if the loop initialization fails at a later point,
the `loop->watchers` list needs to be released.

PR-URL: https://github.com/libuv/libuv/pull/2837
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-05-09 21:17:20 +02:00
Ben Noordhuis
7ccea60b1f doc: fix formatting
Fixes: https://github.com/libuv/libuv/issues/2831
PR-URL: https://github.com/libuv/libuv/pull/2833
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-05-07 10:53:56 +02:00
Bartosz Sosnowski
e7ebae2624 win, fs: add IO_REPARSE_TAG_APPEXECLINK support
Adds support for IO_REPARSE_TAG_APPEXECLINK reparse points, used by
Windows Store.

Ref: https://github.com/nodejs/node/issues/33024

PR-URL: https://github.com/libuv/libuv/pull/2812
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-29 13:50:20 +02:00
Bartosz Sosnowski
457285827c fs: report original error
Exposes the original system error of the filesystem syscalls. Adds a new
uv_fs_get_system_error which returns orignal errno on Linux or
GetLastError on Windows.

Ref: https://github.com/libuv/libuv/issues/2348

PR-URL: https://github.com/libuv/libuv/pull/2810
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-04-29 13:14:57 +02:00
Michal Artazov
2bbf7d5c8c unix: fix int overflow when copying large files
I was getting some weird results when copying a 5GB file on Alpine
Linux on Raspberry Pi. Out of the 5GB only 1.1GB would get copied and
the process would finish without an error. After some digging I found
out that there's a problem that some data types have smaller number of
bytes on Alpine Linux on Raspberry Pi than on other platforms
apparently.

When getting the size of the file in bytes, stat holds the size in
off_t data type, like this:

    struct stat {
        ...
        off_t     st_size;    /* total size, in bytes */
        ...
    };

In my case, off_t has 8 bytes which is enough to hold a value up to
some exabytes. The problem is that it gets assigned to bytes_to_send
variable, which is size_t. In my case, size_t is only 4 bytes, which
is only good for about 4GB. If the file is any larger, there's an
overflow when assigning it from stat to bytes_to_send. That's easy
to fix, I just changed the data type of bytes_to_send to off_t.
However there's more.

The other 2 variables - in_offset and bytes_written also have to be
able to hold the size of the entire file, therefore it makes sense to
change them to off_t as well.

The last problem is that bytes_to_send is passed down to
uv_fs_sendfile() which converts it to size_t again. I could go and
change the types everywhere across the whole codebase to off_t but
that could break other things, so it seams a bit too much. A much
better solution is to have a proxy variable bytes_chunk that is
size_t type and copy as much bytes as possible at a time that can
fit into size_t. That way it will work the same as before on other
platforms, where size_t is more than 4 bytes.

PR-URL: https://github.com/libuv/libuv/pull/2758
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-04-28 23:29:28 +02:00
twosee
06b2f13bad doc: add uv_replace_allocator thread safety warning
PR-URL: https://github.com/libuv/libuv/pull/2815/
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-04-28 23:16:06 +02:00
Ben Noordhuis
43b456dcb3 unix: fully initialize struct msghdr
Commit 3d713663 ("freebsd,linux: add recvmmsg() + sendmmsg() udp
implementation") forgot to zero some of the members of the msghdr
struct. It seems to work by accident, not by design.

PR-URL: https://github.com/libuv/libuv/pull/2819
Refs: https://github.com/libuv/libuv/pull/2818
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-04-28 23:10:34 +02:00
Ben Noordhuis
db96a61c26 win: support environment variables > 32767 chars
The Windows documentation states these should not be possible
but several people have reported that they do in fact happen.

Try with a smallish stack-allocated buffer first and switch to
a heap-allocated buffer if the first one is too small.

Fixes: https://github.com/libuv/libuv/issues/2587
PR-URL: https://github.com/libuv/libuv/pull/2589
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-04-28 20:11:12 +02:00
Ben Noordhuis
75c8850c91 darwin: fix build with non-apple compilers
The header files for ApplicationServices and CoreFoundation contain
C language extensions that Apple's compiler understands but gcc does
not, notably blocks:

https://en.wikipedia.org/wiki/Blocks_(C_language_extension)

Work around that by defining the types inline and stop including
the headers. It's inelegant but the alternatives are worse.

Fixes: https://github.com/libuv/libuv/issues/2805
PR-URL: https://github.com/libuv/libuv/pull/2811
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-28 20:07:59 +02:00
Ben Noordhuis
25368e2db1 doc: check/idle/prepare functions always succeed
Make the documentation reflect that the init/start/stop functions
for check/idle/prepare handles always succeed.

PR-URL: https://github.com/libuv/libuv/pull/2803
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-04-28 20:06:55 +02:00
Bartosz Sosnowski
be0e957f18 build, win: add long path aware manifest
Adds manifest file that makes the test runner work with long filenames
when those are enabled in the system.

PR-URL: https://github.com/libuv/libuv/pull/2789
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-28 18:41:46 +02:00
Bartosz Sosnowski
da7e50bbd8 win: remove MAX_PATH limitations
Since Windows 10 1607 some WinApi functions no longer have a MAX_PATH
limit on the filenames length. This removes this hard-coded path length
limit from various places in libuv, switching to dynamically allocating
string buffers.

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

PR-URL: https://github.com/libuv/libuv/pull/2788
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-28 18:06:42 +02:00
Ben Noordhuis
4d3779c08c unix: simplify uv__udp_init_ex()
PR-URL: https://github.com/libuv/libuv/pull/2809
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-04-28 17:58:36 +02:00
Ben Noordhuis
aa7b62efd9 win: make uv_udp_init_ex() accept UV_UDP_RECVMMSG
Commit 5736658b ("udp: add flag to enable recvmmsg(2) explicitly") added
the flag but didn't update the validation logic in src/win/udp.c.

This commit moves the validation logic to src/uv-common.c. The flag is
now accepted as a no-op on Windows.

Fixes: https://github.com/libuv/libuv/issues/2806
PR-URL: https://github.com/libuv/libuv/pull/2809
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-04-28 17:57:35 +02:00
Bartosz Sosnowski
e1180a6417 build: remove unnessesary MSVC warnings
Removes warnings W4100, W4127, W4201, W4206, W4210, W4232, W4456, W4457,
W4459, W4706 and W4996 when building with MSVC.

PR-URL: https://github.com/libuv/libuv/pull/2777
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-04-28 17:22:27 +02:00
erw7
6b3df0577d build,cmake: fix compilation on old MinGW
_WIN32_WINNT specifies the minimum version of the operating system
supported by the code, so change it to the minimum version supported by
libuv.
If _WIN32_WINNT=0x0600, PSAPI_VERSION=1 is set and it is necessary to link
psapi, so it adds psapi unconditionally to the linked library.

Fixes: https://github.com/libuv/libuv/issues/2742
Refs: https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=vs-2019
PR-URL: https://github.com/libuv/libuv/pull/2748
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-04-27 17:42:46 +09:00
Philip Chimento
002fe6e5f2 doc: fix unescaped character
This was causing a warning during the documentation build.

PR-URL: https://github.com/libuv/libuv/pull/2797
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-22 12:44:50 +02:00
Philip Chimento
a87bb3c5f6 doc: uv_cancel() handles uv_random_t requests
This seems to be the case from reading the code of uv_cancel().

Also fixes a broken link due to a markup typo.

PR-URL: https://github.com/libuv/libuv/pull/2797
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-22 12:44:12 +02:00
twosee
13886c5293 build,android: fix typo
PR-URL: https://github.com/libuv/libuv/pull/2798
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-22 12:41:58 +02:00
Shohei YOSHIDA
99f8ffcc4e doc: correct source lines
PR-URL: https://github.com/libuv/libuv/pull/2802
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-04-22 12:40:32 +02:00
Colin Finck
aa93eb2583 win: remove dep on GetQueuedCompletionStatusEx
Libuv already works without that API since commit 153ea114ff but still
had it as a hard requirement in the import table. This code uses the
`pGetQueuedCompletionStatusEx` function pointer instead, hence it also
works on systems that don't export `GetQueuedCompletionStatusEx`.

This simple fix improves compatibility of libuv with ReactOS and
Windows XP (latter using Vista+ compatibility libraries like
https://github.com/MyTDT-Mysoft/DllCompat)

PR-URL: https://github.com/libuv/libuv/pull/2800
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-04-22 12:37:49 +02:00
Ben Noordhuis
a9d9d4ea1b 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>
2020-04-22 12:28:13 +02:00
Ben Noordhuis
72fe3543fe unix,win: add uv_library_shutdown()
Make it possible to explicitly tell libuv to release any resources
it's still holding onto (memory, threads, file descriptors, etc.)

Before this commit, cleanup was performed in various destructors.
This commit centralizes the cleanup logic, enabling the addition of
`uv_library_shutdown()`, but maintains the current observable behavior
of cleaning up when libuv is unloaded by means of `dlclose(3)`.

Fixes: https://github.com/libuv/libuv/issues/2763
PR-URL: https://github.com/libuv/libuv/pull/2764
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-04-22 12:24:36 +02:00
Ben Noordhuis
b29612fe59 win: DRY uv_poll_close()
PR-URL: https://github.com/libuv/libuv/pull/2746
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: erw7 <erw7.github@gmail.com>
2020-04-22 12:23:00 +02:00
Ben Noordhuis
887cf62c32 win: DRY uv_poll_start() and uv_poll_stop()
PR-URL: https://github.com/libuv/libuv/pull/2746
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: erw7 <erw7.github@gmail.com>
2020-04-22 12:22:58 +02:00
James Ross
37a8affbd3 linux: make cpu_times consistently be milliseconds
On Linux, cpu_times have been calculated differently to all other
platforms for a while. Other platforms (FreeBSD, Mac, Windows) are all
in milliseconds, but Linux has been returning values ten times larger.

libuv has not previously documented what unit cpu_times uses, even
though NodeJS did - as milliseconds.

Here we're both documenting that the cpu_times are indeed in
milliseconds, and fixing the inconsistency on Linux.

Fixes: https://github.com/libuv/libuv/issues/2773
PR-URL: https://github.com/libuv/libuv/pull/2796
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-04-22 10:46:07 +02:00
Xu Meng
f52786b4ba
test: skip poll_duplex and poll_unidirectional on PASE
Issuing a shutdown() on IBM i PASE with parameter SHUT_WR
also sends a normal close sequence to the partner program.
This leads to timing issues and ECONNRESET failures in the
test poll_duplex and poll_unidirectional.

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_74/apis/shutdn.htm

PR-URL: https://github.com/libuv/libuv/pull/2782
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-20 09:45:26 -04:00
cjihrig
0e00e14003
Now working on version 1.37.1
Fixes: https://github.com/libuv/libuv/issues/2801
2020-04-19 12:17:40 -04:00
cjihrig
87af835905
Add SHA to ChangeLog 2020-04-19 12:15:57 -04:00
cjihrig
02a9e1be25
2020.04.20, Version 1.37.0 (Stable)
Changes since version 1.36.0:

* timer: remove redundant check in heap compare (Yash Ladha)

* udp: add flag to enable recvmmsg(2) explicitly (Saúl Ibarra Corretgé)
2020-04-19 12:15:57 -04:00
Saúl Ibarra Corretgé
5736658bee
udp: add flag to enable recvmmsg(2) explicitly
Instead of implicitly enabling it by checking the supplied buffer size
to alloc_cb, have a dedicated flag that must be set on `uv_udp_init_ex`.

Fixes: https://github.com/libuv/libuv/issues/2791
Closes: https://github.com/libuv/libuv/pull/2792
PR-URL: https://github.com/libuv/libuv/pull/2799
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-19 11:40:24 -04:00
Yash Ladha
0fd993195f timer: remove redundant check in heap compare
`timer_less_than()` function is basically a comparator function
that returns true or false. In the end of the function we were
checking for the comparison of id, but the later if is redundant
as we are anyways in the end are returning `0`. That extra check
can thus be safely removed.

PR-URL: https://github.com/libuv/libuv/pull/2785
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-16 14:54:51 +02:00
cjihrig
80c18ffaf5
Now working on version 1.36.1
Fixes: https://github.com/libuv/libuv/issues/2787
2020-04-15 12:33:35 -04:00
cjihrig
40e8804287
Add SHA to ChangeLog 2020-04-15 12:31:22 -04:00
401 changed files with 32211 additions and 17010 deletions

View File

@ -2,7 +2,7 @@
If you want to report a bug, you are in the right place! If you want to report a bug, you are in the right place!
If you need help or have a question, go here: If you need help or have a question, go here:
https://github.com/libuv/help/issues/new https://github.com/libuv/libuv/discussions
If you are reporting a libuv test failure, please ensure that you are not If you are reporting a libuv test failure, please ensure that you are not
running the test as root. running the test as root.

7
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

24
.github/stale.yml vendored
View File

@ -1,24 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 21
# Number of days of inactivity before a stale issue is closed
# Set to false to disable. If disabled, issues still need to be closed
# manually, but will remain marked as stale.
daysUntilClose: 120
# Issues with these labels will never be considered stale
exemptLabels:
- v2
- enhancement
- good first issue
- feature-request
- doc
- bug
- not-stale
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

25
.github/workflows/CI-docs.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: CI-docs
on:
pull_request:
paths:
- 'docs/**'
- '!docs/code/**'
- '.github/workflows/CI-docs.yml'
jobs:
docs-src:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies
- run: pip install -r docs/requirements.txt
- name: html
run: |
make -C docs html
- name: linkcheck
run: |
make -C docs linkcheck

33
.github/workflows/CI-sample.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: ci-sample
on:
pull_request:
paths:
- '**'
- '!docs/**'
- '!.**'
- 'docs/code/**'
- '.github/workflows/CI-sample.yml'
push:
branches:
- v[0-9].*
- master
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: setup
run: cmake -E make_directory ${{runner.workspace}}/libuv/docs/code/build
- name: configure
# you may like use Ninja on unix-like OS, but for windows, the only easy way is to use Visual Studio if you want Ninja
run: cmake ..
working-directory: ${{runner.workspace}}/libuv/docs/code/build
- name: build
run: cmake --build .
working-directory: ${{runner.workspace}}/libuv/docs/code/build

182
.github/workflows/CI-unix.yml vendored Normal file
View File

@ -0,0 +1,182 @@
name: CI-unix
on:
pull_request:
paths:
- '**'
- '!docs/**'
- '!src/win/**'
- '!.**'
- '.github/workflows/CI-unix.yml'
push:
branches:
- v[0-9].*
- master
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: configure
run: |
./autogen.sh
mkdir build
(cd build && ../configure)
- name: distcheck
run: |
make -C build distcheck
build-android:
runs-on: ubuntu-latest
env:
ANDROID_AVD_HOME: /root/.android/avd
steps:
- uses: actions/checkout@v4
- name: Envinfo
run: npx envinfo
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Build and Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 30
arch: x86_64
target: google_apis
ram-size: 2048M
emulator-options: -no-audio -no-window -gpu off -no-boot-anim -netdelay none -netspeed full -writable-system -no-snapshot-save -no-snapshot-load -no-snapshot
disable-animations: true
script: |
echo "::group::Configure"
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="x86_64" -DANDROID_PLATFORM=android-30
echo "::endgroup::"
echo "::group::Build"
cmake --build build
## Correct some ld bugs that cause problems with libuv tests
wget "https://github.com/termux/termux-elf-cleaner/releases/download/v2.2.1/termux-elf-cleaner" -P build
chmod a+x build/termux-elf-cleaner
build/termux-elf-cleaner --api-level 30 ./build/uv_run_tests
build/termux-elf-cleaner --api-level 30 ./build/uv_run_tests_a
adb shell "su 0 setenforce 0" # to allow some syscalls like link, chmod, etc.
## Push the build and test fixtures to the device
adb push build /data/local/tmp
adb shell mkdir /data/local/tmp/build/test
adb push test/fixtures /data/local/tmp/build/test
echo "::endgroup::"
## Run the tests
file build/uv_run_tests_a
adb shell "cd /data/local/tmp/build && env UV_TEST_TIMEOUT_MULTIPLIER=5 ./uv_run_tests_a"
build-macos:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14]
steps:
- uses: actions/checkout@v4
- name: Envinfo
run: npx envinfo
- name: Disable Firewall
run: |
/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 0
/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
- name: Setup
run: |
brew install ninja automake libtool
- name: Configure
run: |
mkdir build
cd build
cmake .. -DBUILD_TESTING=ON -G Ninja
- name: Build
run: |
cmake --build build
ls -lh
- name: platform_output
run: |
./build/uv_run_tests platform_output
- name: platform_output_a
run: |
./build/uv_run_tests_a platform_output
- name: Test
run: |
cd build && ctest -V
- name: Autotools configure
if: always()
run: |
./autogen.sh
mkdir build-auto
(cd build-auto && ../configure)
make -C build-auto -j4
build-ios:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14]
steps:
- uses: actions/checkout@v4
- name: Configure
run: |
mkdir build-ios
cd build-ios
cmake .. -GXcode -DCMAKE_SYSTEM_NAME:STRING=iOS -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED:BOOL=NO -DCMAKE_CONFIGURATION_TYPES:STRING=Release
- name: Build
run: |
cmake --build build-ios
ls -lh build-ios
build-cross-qemu:
runs-on: ubuntu-24.04
name: build-cross-qemu-${{ matrix.config.target }}
strategy:
fail-fast: false
matrix:
config:
- {target: arm, toolchain: gcc-arm-linux-gnueabi, cc: arm-linux-gnueabi-gcc, qemu: qemu-arm }
- {target: armhf, toolchain: gcc-arm-linux-gnueabihf, cc: arm-linux-gnueabihf-gcc, qemu: qemu-arm }
- {target: aarch64, toolchain: gcc-aarch64-linux-gnu, cc: aarch64-linux-gnu-gcc, qemu: qemu-aarch64 }
- {target: riscv64, toolchain: gcc-riscv64-linux-gnu, cc: riscv64-linux-gnu-gcc, qemu: qemu-riscv64 }
- {target: ppc, toolchain: gcc-powerpc-linux-gnu, cc: powerpc-linux-gnu-gcc, qemu: qemu-ppc }
- {target: ppc64, toolchain: gcc-powerpc64-linux-gnu, cc: powerpc64-linux-gnu-gcc, qemu: qemu-ppc64 }
- {target: ppc64le, toolchain: gcc-powerpc64le-linux-gnu, cc: powerpc64le-linux-gnu-gcc, qemu: qemu-ppc64le }
- {target: s390x, toolchain: gcc-s390x-linux-gnu, cc: s390x-linux-gnu-gcc, qemu: qemu-s390x }
- {target: mips, toolchain: gcc-mips-linux-gnu, cc: mips-linux-gnu-gcc, qemu: qemu-mips }
- {target: mips64, toolchain: gcc-mips64-linux-gnuabi64, cc: mips64-linux-gnuabi64-gcc, qemu: qemu-mips64 }
- {target: mipsel, toolchain: gcc-mipsel-linux-gnu, cc: mipsel-linux-gnu-gcc, qemu: qemu-mipsel }
- {target: mips64el, toolchain: gcc-mips64el-linux-gnuabi64, cc: mips64el-linux-gnuabi64-gcc,qemu: qemu-mips64el }
- {target: arm (u64 slots), toolchain: gcc-arm-linux-gnueabi, cc: arm-linux-gnueabi-gcc, qemu: qemu-arm }
- {target: aarch64 (u64 slots), toolchain: gcc-aarch64-linux-gnu, cc: aarch64-linux-gnu-gcc, qemu: qemu-aarch64 }
- {target: ppc (u64 slots), toolchain: gcc-powerpc-linux-gnu, cc: powerpc-linux-gnu-gcc, qemu: qemu-ppc }
- {target: ppc64 (u64 slots), toolchain: gcc-powerpc64-linux-gnu, cc: powerpc64-linux-gnu-gcc, qemu: qemu-ppc64 }
steps:
- uses: actions/checkout@v4
- name: Install qemu and ${{ matrix.config.toolchain }}
run: |
sudo apt update
sudo apt install qemu-user qemu-user-binfmt ${{ matrix.config.toolchain }} -y
- name: Configure with ${{ matrix.config.cc }}
run: |
mkdir build
cd build
cmake .. -DBUILD_TESTING=ON -DQEMU=ON -DCMAKE_C_COMPILER=${{ matrix.config.cc }}
- name: Build
run: |
cmake --build build
ls -lh build
- name: Test
run: |
${{ matrix.config.qemu }} build/uv_run_tests_a

129
.github/workflows/CI-win.yml vendored Normal file
View File

@ -0,0 +1,129 @@
name: CI-win
on:
pull_request:
paths:
- '**'
- '!docs/**'
- '!src/unix/**'
- '!.**'
- '.github/workflows/CI-win.yml'
push:
branches:
- v[0-9].*
- master
jobs:
build-windows:
runs-on: windows-${{ matrix.config.server }}
name: build-${{ join(matrix.config.*, '-') }}
strategy:
fail-fast: false
matrix:
config:
- {toolchain: Visual Studio 16 2019, arch: Win32, server: 2019}
- {toolchain: Visual Studio 16 2019, arch: x64, server: 2019}
- {toolchain: Visual Studio 17 2022, arch: Win32, server: 2022}
- {toolchain: Visual Studio 17 2022, arch: x64, server: 2022}
- {toolchain: Visual Studio 17 2022, arch: x64, server: 2022, config: ASAN}
- {toolchain: Visual Studio 17 2022, arch: x64, server: 2022, config: UBSAN}
- {toolchain: Visual Studio 17 2022, arch: arm64, server: 2022}
steps:
- uses: actions/checkout@v4
- name: Build
run:
cmake -S . -B build -DBUILD_TESTING=ON
-G "${{ matrix.config.toolchain }}" -A ${{ matrix.config.arch }}
${{ matrix.config.config == 'ASAN' && '-DASAN=on -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded' || '' }}
cmake --build build --config RelWithDebInfo
${{ matrix.config.config == 'ASAN' && 'Copy-Item -Path "build\\*.exe" -Destination "build\\RelWithDebInfo\\"' || '' }}
${{ matrix.config.config == 'ASAN' && 'Copy-Item -Path "build\\*.dll" -Destination "build\\RelWithDebInfo\\"' || '' }}
ls -l build
ls -l build\\RelWithDebInfo
- name: platform_output_a
if: ${{ matrix.config.arch != 'arm64' }}
shell: cmd
run:
build\\RelWithDebInfo\\uv_run_tests_a.exe platform_output
- name: platform_output
if: ${{ matrix.config.arch != 'arm64' }}
shell: cmd
run:
build\\RelWithDebInfo\\uv_run_tests.exe platform_output
- name: Test
# only valid with libuv-master with the fix for
# https://github.com/libuv/leps/blob/master/005-windows-handles-not-fd.md
if: ${{ matrix.config.config != 'ASAN' && matrix.config.arch != 'arm64' }}
shell: cmd
run:
cd build
ctest -C RelWithDebInfo -V
- name: Test only static
if: ${{ matrix.config.config == 'ASAN' && matrix.config.arch != 'arm64' }}
shell: cmd
run:
build\\RelWithDebInfo\\uv_run_tests_a.exe
build-mingw:
runs-on: ubuntu-latest
name: build-mingw-${{ matrix.config.arch }}
strategy:
fail-fast: false
matrix:
config:
- {arch: i686, server: 2022, libgcc: dw2 }
- {arch: x86_64, server: 2022, libgcc: seh }
steps:
- uses: actions/checkout@v4
- name: Install mingw32 environment
run: |
sudo apt update
sudo apt install mingw-w64 ninja-build -y
- name: Build
run: |
cmake -S . -B build -G Ninja -DHOST_ARCH=${{ matrix.config.arch }} -DBUILD_TESTING=ON -DCMAKE_TOOLCHAIN_FILE=cmake-toolchains/cross-mingw32.cmake
cmake --build build
cmake --install build --prefix "`pwd`/build/usr"
mkdir -p build/usr/test build/usr/bin
cp -av test/fixtures build/usr/test
cp -av build/uv_run_tests_a.exe build/uv_run_tests.exe build/uv_run_tests_a_no_ext build/uv_run_tests_no_ext \
`${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libgcc_s_${{ matrix.config.libgcc }}-1.dll` \
`${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libwinpthread-1.dll` \
`${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libatomic-1.dll` \
build/usr/bin
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: mingw-${{ matrix.config.arch }}
path: build/usr/**/*
retention-days: 2
test-mingw:
runs-on: windows-${{ matrix.config.server }}
name: test-mingw-${{ matrix.config.arch }}
needs: build-mingw
strategy:
fail-fast: false
matrix:
config:
- {arch: i686, server: 2022}
- {arch: x86_64, server: 2022}
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: mingw-${{ matrix.config.arch }}
- name: Test
shell: cmd
run: |
bin\uv_run_tests_a.exe
- name: Test
shell: cmd
run: |
bin\uv_run_tests.exe

128
.github/workflows/sanitizer.yml vendored Normal file
View File

@ -0,0 +1,128 @@
name: Sanitizer checks
on:
pull_request:
paths:
- '**'
- '!docs/**'
- '!.**'
- '.github/workflows/sanitizer.yml'
push:
branches:
- v[0-9].*
- master
jobs:
sanitizers-linux:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup
run: |
sudo apt-get install ninja-build
- name: Envinfo
run: npx envinfo
# [AM]SAN fail on newer kernels due to a bigger PIE slide
- name: Disable ASLR
run: |
sudo sysctl -w kernel.randomize_va_space=0
- name: ASAN Build
run: |
mkdir build-asan
(cd build-asan && cmake .. -G Ninja -DBUILD_TESTING=ON -DASAN=ON -DCMAKE_BUILD_TYPE=Debug)
cmake --build build-asan
- name: ASAN Test
run: |
./build-asan/uv_run_tests_a
- name: MSAN Build
run: |
mkdir build-msan
(cd build-msan && cmake .. -G Ninja -DBUILD_TESTING=ON -DMSAN=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang)
cmake --build build-msan
- name: MSAN Test
run: |
./build-msan/uv_run_tests_a
- name: TSAN Build
run: |
mkdir build-tsan
(cd build-tsan && cmake .. -G Ninja -DBUILD_TESTING=ON -DTSAN=ON -DCMAKE_BUILD_TYPE=Release)
cmake --build build-tsan
- name: TSAN Test
# Note: path must be absolute because some tests chdir.
# TSan exits with an error when it can't find the file.
run: |
env TSAN_OPTIONS="suppressions=$PWD/tsansupp.txt" ./build-tsan/uv_run_tests_a
- name: UBSAN Build
run: |
mkdir build-ubsan
(cd build-ubsan && cmake .. -G Ninja -DBUILD_TESTING=ON -DUBSAN=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang)
cmake --build build-ubsan
- name: UBSAN Test
run: |
./build-ubsan/uv_run_tests_a
sanitizers-macos:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Envinfo
run: npx envinfo
- name: ASAN Build
run: |
mkdir build-asan
(cd build-asan && cmake .. -DBUILD_TESTING=ON -DASAN=ON -DCMAKE_BUILD_TYPE=Debug)
cmake --build build-asan
- name: ASAN Test
run: |
./build-asan/uv_run_tests_a
- name: TSAN Build
run: |
mkdir build-tsan
(cd build-tsan && cmake .. -DBUILD_TESTING=ON -DTSAN=ON -DCMAKE_BUILD_TYPE=Release)
cmake --build build-tsan
- name: TSAN Test
run: |
./build-tsan/uv_run_tests_a
- name: UBSAN Build
run: |
mkdir build-ubsan
(cd build-ubsan && cmake .. -DBUILD_TESTING=ON -DUBSAN=ON -DCMAKE_BUILD_TYPE=Debug)
cmake --build build-ubsan
- name: UBSAN Test
run: |
./build-ubsan/uv_run_tests_a
sanitizers-windows:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Setup
run: |
choco install ninja
# Note: clang shipped with VS2022 has an issue where the UBSAN runtime doesn't link.
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
version: "17"
- name: Envinfo
run: npx envinfo
- name: UBSAN Build
run: |
mkdir build-ubsan
cmake -B build-ubsan -G Ninja -DBUILD_TESTING=ON -DUBSAN=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang
cmake --build build-ubsan
- name: UBSAN Test
run: |
./build-ubsan/uv_run_tests_a

5
.gitignore vendored
View File

@ -7,9 +7,11 @@
*.sdf *.sdf
*.suo *.suo
.vs/ .vs/
.vscode/
*.VC.db *.VC.db
*.VC.opendb *.VC.opendb
core core
.cache
vgcore.* vgcore.*
.buildstamp .buildstamp
.dirstamp .dirstamp
@ -67,9 +69,12 @@ ipch
# Clion / IntelliJ project files # Clion / IntelliJ project files
/.idea/ /.idea/
cmake-build-debug/
*.xcodeproj *.xcodeproj
*.xcworkspace *.xcworkspace
# make dist output # make dist output
libuv-*.tar.* libuv-*.tar.*
/dist.libuv.org/
/libuv-release-tool/

View File

@ -1,7 +1,10 @@
A. Hauptmann <andreashauptmann@t-online.de> A. Hauptmann <andreashauptmann@t-online.de>
AJ Heller <aj@drfloob.com> <hork@google.com>
Aaron Bieber <qbit@deftly.net> <deftly@gmail.com> Aaron Bieber <qbit@deftly.net> <deftly@gmail.com>
Alan Gutierrez <alan@prettyrobots.com> <alan@blogometer.com> Alan Gutierrez <alan@prettyrobots.com> <alan@blogometer.com>
Andrius Bentkus <andrius.bentkus@gmail.com> <toxedvirus@gmail.com> Andrius Bentkus <andrius.bentkus@gmail.com> <toxedvirus@gmail.com>
Andy Fiddaman <andy@omniosce.org> <omnios@citrus-it.co.uk>
Andy Pan <panjf2000@gmail.com> <i@andypan.me>
Bert Belder <bertbelder@gmail.com> <i@bertbelder.com> Bert Belder <bertbelder@gmail.com> <i@bertbelder.com>
Bert Belder <bertbelder@gmail.com> <info@2bs.nl> Bert Belder <bertbelder@gmail.com> <info@2bs.nl>
Bert Belder <bertbelder@gmail.com> <user@ChrUbuntu.(none)> Bert Belder <bertbelder@gmail.com> <user@ChrUbuntu.(none)>
@ -10,27 +13,36 @@ Brian White <mscdex@mscdex.net>
Brian White <mscdex@mscdex.net> <mscdex@gmail.com> Brian White <mscdex@mscdex.net> <mscdex@gmail.com>
Caleb James DeLisle <cjd@hyperboria.ca> <cjd@cjdns.fr> Caleb James DeLisle <cjd@hyperboria.ca> <cjd@cjdns.fr>
Christoph Iserlohn <christoph.iserlohn@innoq.com> Christoph Iserlohn <christoph.iserlohn@innoq.com>
Darshan Sen <raisinten@gmail.com>
Darshan Sen <raisinten@gmail.com> <darshan.sen@postman.com>
David Carlier <devnexen@gmail.com>
Devchandra Meetei Leishangthem <dlmeetei@gmail.com> Devchandra Meetei Leishangthem <dlmeetei@gmail.com>
Fedor Indutny <fedor.indutny@gmail.com> <fedor@indutny.com> Fedor Indutny <fedor.indutny@gmail.com> <fedor@indutny.com>
Frank Denis <github@pureftpd.org> Frank Denis <github@pureftpd.org>
Hüseyin Açacak <110401522+huseyinacacak-janea@users.noreply.github.com> <huseyin@janeasystems.com>
Imran Iqbal <imrani@ca.ibm.com> <imran@imraniqbal.org> Imran Iqbal <imrani@ca.ibm.com> <imran@imraniqbal.org>
Isaac Z. Schlueter <i@izs.me> Isaac Z. Schlueter <i@izs.me>
Jason Williams <necmon@yahoo.com> Jason Williams <necmon@yahoo.com>
Jesse Gorzinski <jgorzinski@gmail.com> Jesse Gorzinski <jgorzinski@gmail.com>
Jesse Gorzinski <jgorzinski@gmail.com> <jgorzins@us.ibm.com> Jesse Gorzinski <jgorzinski@gmail.com> <jgorzins@us.ibm.com>
Juan José Arboleda <soyjuanarbol@gmail.com>
Justin Venus <justin.venus@gmail.com> <justin.venus@orbitz.com> Justin Venus <justin.venus@gmail.com> <justin.venus@orbitz.com>
Keno Fischer <kenof@stanford.edu> <kfischer+github@college.harvard.edu> Keno Fischer <kenof@stanford.edu> <kfischer+github@college.harvard.edu>
Keno Fischer <kenof@stanford.edu> <kfischer@college.harvard.edu> Keno Fischer <kenof@stanford.edu> <kfischer@college.harvard.edu>
Leith Bade <leith@leithalweapon.geek.nz> <leith@mapbox.com> Leith Bade <leith@leithalweapon.geek.nz> <leith@mapbox.com>
Leonard Hecker <leonard.hecker91@gmail.com> <leonard@hecker.io> Leonard Hecker <leonard.hecker91@gmail.com> <leonard@hecker.io>
Lewis Russell <me@lewisr.dev> <lewis6991@gmail.com>
Maciej Małecki <maciej.malecki@notimplemented.org> <me@mmalecki.com> Maciej Małecki <maciej.malecki@notimplemented.org> <me@mmalecki.com>
Marc Schlaich <marc.schlaich@googlemail.com> <marc.schlaich@gmail.com> Marc Schlaich <marc.schlaich@googlemail.com> <marc.schlaich@gmail.com>
Michael <michael_dawson@ca.ibm.com> Michael <michael_dawson@ca.ibm.com>
Michael Neumann <mneumann@think.localnet> <mneumann@ntecs.de> Michael Neumann <mneumann@think.localnet> <mneumann@ntecs.de>
Michael Penick <michael.penick@datastax.com> <mpenick@users.noreply.github.com>
Nicholas Vavilov <vvnicholas@gmail.com> Nicholas Vavilov <vvnicholas@gmail.com>
Nick Logan <ugexe@cpan.org> <nlogan@gmail.com> Nick Logan <ugexe@cpan.org> <nlogan@gmail.com>
Olivier Valentin <ovalenti@redhat.com> <valentio@free.fr>
Rasmus Christian Pedersen <zerhacken@yahoo.com> Rasmus Christian Pedersen <zerhacken@yahoo.com>
Rasmus Christian Pedersen <zerhacken@yahoo.com> <ruysch@outlook.com> Rasmus Christian Pedersen <zerhacken@yahoo.com> <ruysch@outlook.com>
Richard Lau <rlau@redhat.com> <riclau@uk.ibm.com>
Robert Mustacchi <rm@joyent.com> <rm@fingolfin.org> Robert Mustacchi <rm@joyent.com> <rm@fingolfin.org>
Ryan Dahl <ryan@joyent.com> <ry@tinyclouds.org> Ryan Dahl <ryan@joyent.com> <ry@tinyclouds.org>
Ryan Emery <seebees@gmail.com> Ryan Emery <seebees@gmail.com>
@ -38,14 +50,22 @@ Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Sam Roberts <vieuxtech@gmail.com> <sam@strongloop.com> Sam Roberts <vieuxtech@gmail.com> <sam@strongloop.com>
San-Tai Hsu <vanilla@fatpipi.com> San-Tai Hsu <vanilla@fatpipi.com>
Santiago Gimeno <santiago.gimeno@quantion.es> <santiago.gimeno@gmail.com> Santiago Gimeno <santiago.gimeno@quantion.es> <santiago.gimeno@gmail.com>
Saúl Ibarra Corretgé <saghul@gmail.com> Saúl Ibarra Corretgé <s@saghul.net>
Saúl Ibarra Corretgé <s@saghul.net> <saghul@gmail.com>
Saúl Ibarra Corretgé <saghul@gmail.com> <s@saghul.net> Saúl Ibarra Corretgé <saghul@gmail.com> <s@saghul.net>
Shigeki Ohtsu <ohtsu@iij.ad.jp> <ohtsu@ohtsu.org> Shigeki Ohtsu <ohtsu@iij.ad.jp> <ohtsu@ohtsu.org>
Shuowang (Wayne) Zhang <shuowang.zhang@ibm.com>
TK-one <tk5641@naver.com>
Timothy J. Fontaine <tjfontaine@gmail.com> Timothy J. Fontaine <tjfontaine@gmail.com>
Yasuhiro Matsumoto <mattn.jp@gmail.com> Yasuhiro Matsumoto <mattn.jp@gmail.com>
Yazhong Liu <yorkiefixer@gmail.com> Yazhong Liu <yorkiefixer@gmail.com>
Yuki Okumura <mjt@cltn.org> Yuki Okumura <mjt@cltn.org>
cjihrig <cjihrig@gmail.com>
gengjiawen <technicalcute@gmail.com>
jBarz <jBarz@users.noreply.github.com> <jbarboza@ca.ibm.com> jBarz <jBarz@users.noreply.github.com> <jbarboza@ca.ibm.com>
jBarz <jBarz@users.noreply.github.com> <jbarz@users.noreply.github.com> jBarz <jBarz@users.noreply.github.com> <jbarz@users.noreply.github.com>
ptlomholt <pt@lomholt.com> ptlomholt <pt@lomholt.com>
theanarkh <2923878201@qq.com> <theratliter@gmail.com>
tjarlama <59913901+tjarlama@users.noreply.github.com> <tjarlama@gmail.com>
ywave620 <rogertyang@tencent.com> <60539365+ywave620@users.noreply.github.com>
zlargon <zlargon1988@gmail.com> zlargon <zlargon1988@gmail.com>

15
.readthedocs.yaml Normal file
View File

@ -0,0 +1,15 @@
version: 2
sphinx:
builder: html
configuration: docs/src/conf.py
fail_on_warning: false
build:
os: "ubuntu-22.04"
tools:
python: "3.9"
python:
install:
- requirements: docs/requirements.txt

174
AUTHORS
View File

@ -114,7 +114,6 @@ Dylan Cali <calid1984@gmail.com>
Austin Foxley <austinf@cetoncorp.com> Austin Foxley <austinf@cetoncorp.com>
Benjamin Saunders <ben.e.saunders@gmail.com> Benjamin Saunders <ben.e.saunders@gmail.com>
Geoffry Song <goffrie@gmail.com> Geoffry Song <goffrie@gmail.com>
Rasmus Christian Pedersen <ruysch@outlook.com>
William Light <wrl@illest.net> William Light <wrl@illest.net>
Oleg Efimov <o.efimov@corp.badoo.com> Oleg Efimov <o.efimov@corp.badoo.com>
Lars Gierth <larsg@systemli.org> Lars Gierth <larsg@systemli.org>
@ -123,7 +122,6 @@ Justin Venus <justin.venus@gmail.com>
Kristian Evensen <kristian.evensen@gmail.com> Kristian Evensen <kristian.evensen@gmail.com>
Linus Mårtensson <linus.martensson@sonymobile.com> Linus Mårtensson <linus.martensson@sonymobile.com>
Navaneeth Kedaram Nambiathan <navaneethkn@gmail.com> Navaneeth Kedaram Nambiathan <navaneethkn@gmail.com>
Yorkie <yorkiefixer@gmail.com>
StarWing <weasley.wx@gmail.com> StarWing <weasley.wx@gmail.com>
thierry-FreeBSD <thierry@FreeBSD.org> thierry-FreeBSD <thierry@FreeBSD.org>
Isaiah Norton <isaiah.norton@gmail.com> Isaiah Norton <isaiah.norton@gmail.com>
@ -212,7 +210,7 @@ guworks <ground.up.works@gmail.com>
RossBencina <rossb@audiomulch.com> RossBencina <rossb@audiomulch.com>
Roger A. Light <roger@atchoo.org> Roger A. Light <roger@atchoo.org>
chenttuuvv <chenttuuvv@yahoo.com> chenttuuvv <chenttuuvv@yahoo.com>
Richard Lau <riclau@uk.ibm.com> Richard Lau <rlau@redhat.com>
ronkorving <rkorving@wizcorp.jp> ronkorving <rkorving@wizcorp.jp>
Corbin Simpson <MostAwesomeDude@gmail.com> Corbin Simpson <MostAwesomeDude@gmail.com>
Zachary Hamm <zsh@imipolexg.org> Zachary Hamm <zsh@imipolexg.org>
@ -424,3 +422,173 @@ Lin Zhang <linroid@gmail.com>
Sk Sajidul Kadir <sheikh.sajid522@gmail.com> Sk Sajidul Kadir <sheikh.sajid522@gmail.com>
twosee <twose@qq.com> twosee <twose@qq.com>
Rikard Falkeborn <rikard.falkeborn@gmail.com> Rikard Falkeborn <rikard.falkeborn@gmail.com>
Yash Ladha <yashladhapankajladha123@gmail.com>
James Ross <git@james-ross.co.uk>
Colin Finck <colin@reactos.org>
Shohei YOSHIDA <syohex@gmail.com>
Philip Chimento <philip.chimento@gmail.com>
Michal Artazov <michal@artazov.cz>
Jeroen Roovers <jer@gentoo.org>
MasterDuke17 <MasterDuke17@users.noreply.github.com>
Alexander Tokmakov <avtokmakov@yandex-team.ru>
Arenoros <arenoros@gmail.com>
lander0s <dh.landeros08@gmail.com>
Turbinya <wownucleos@gmail.com>
OleksandrKvl <oleksandrdvl@gmail.com>
Carter Li <carter.li@eoitek.com>
Juan Sebastian velez Posada <jvelezpo@users.noreply.github.com>
escherstair <ernestviga@gmail.com>
Evan Lucas <evanlucas@me.com>
tjarlama <59913901+tjarlama@users.noreply.github.com>
司徒玟琅 <sanjusss@qq.com>
YuMeiJie <yumeijie@huawei.com>
Aleksej Lebedev <root@zta.lk>
Nikolay Mitev <github@hmel.org>
Ulrik Strid <ulrik.strid@outlook.com>
Elad Lahav <elahav@qnx.com>
Elad Nachmias <eladn@pazam.net>
Darshan Sen <raisinten@gmail.com>
Simon Kadisch <simon.kadisch@k13-engineering.at>
Momtchil Momtchev <momtchil@momtchev.com>
Ethel Weston <66453757+ethelweston@users.noreply.github.com>
Drew DeVault <sir@cmpwn.com>
Mark Klein <klein@cscs.ch>
schamberg97 <50446906+schamberg97@users.noreply.github.com>
Bob Weinand <bobwei9@hotmail.com>
Issam E. Maghni <issam.e.maghni@mailbox.org>
Juan Pablo Canepa <jpcanepa@gmail.com>
Shuowang (Wayne) Zhang <shuowang.zhang@ibm.com>
Ondřej Surý <ondrej@sury.org>
Juan José Arboleda <soyjuanarbol@gmail.com>
Zhao Zhili <zhilizhao@tencent.com>
Brandon Cheng <brandon.cheng@protonmail.com>
Matvii Hodovaniuk <matvii@hodovani.uk>
Hayden <me@diatr.us>
yiyuaner <yguoaz@gmail.com>
bbara <bbara93@gmail.com>
SeverinLeonhardt <Severin.Leonhardt@teamviewer.com>
Andy Fiddaman <andy@omniosce.org>
Romain Roffé <rofferom@gmail.com>
Eagle Liang <eagleliang@gmail.com>
Ricky Zhou <ives199511@gmail.com>
Simon Kissane <skissane@gmail.com>
James M Snell <jasnell@gmail.com>
Ali Mohammad Pur <Ali.mpfard@gmail.com>
Erkhes N <71805796+rexes-ND@users.noreply.github.com>
Joshua M. Clulow <josh@sysmgr.org>
Guilherme Íscaro <cabelitostos@gmail.com>
Martin Storsjö <martin@martin.st>
Claes Nästén <pekdon@gmail.com>
Mohamed Edrah <43171151+MSE99@users.noreply.github.com>
Supragya Raj <supragyaraj@gmail.com>
Ikko Ashimine <eltociear@gmail.com>
Sylvain Corlay <sylvain.corlay@gmail.com>
earnal <etienne.arnal@gmail.com>
YAKSH BARIYA <yakshbari4@gmail.com>
Ofek Lev <ofekmeister@gmail.com>
~locpyl-tidnyd <81016946+locpyl-tidnyd@users.noreply.github.com>
Evan Miller <emmiller@gmail.com>
Petr Menšík <pemensik@redhat.com>
Nicolas Noble <nicolasnoble@users.noreply.github.com>
AJ Heller <aj@drfloob.com>
Stacey Marshall <stacey.marshall@gmail.com>
Jesper Storm Bache <jsbache@users.noreply.github.com>
Campbell He <duskmoon314@users.noreply.github.com>
Andrey Hohutkin <andrey.hohutkin@gmail.com>
deal <halx99@live.com>
David Machaj <46852402+dmachaj@users.noreply.github.com>
Jessica Clarke <jrtc27@jrtc27.com>
Jeremy Rose <nornagon@nornagon.net>
woclass <git@wo-class.cn>
Luca Adrian L <info@lucalindhorst.de>
WenTao Ou <owt5008137@live.com>
jonilaitinen <joni.laitinen@iki.fi>
UMU <UMU618@users.noreply.github.com>
Paul Evans <leonerd@leonerd.org.uk>
wyckster <wyckster@hotmail.com>
Vittore F. Scolari <vittore.scolari@gmail.com>
roflcopter4 <15476346+roflcopter4@users.noreply.github.com>
V-for-Vasili <vasili.skurydzin@protonmail.com>
Denny C. Dai <dennycd@me.com>
Hannah Shi <hannahshisfb@gmail.com>
tuftedocelot <tuftedocelot@fastmail.fm>
blogdaren <blogdaren@163.com>
chucksilvers <chuq@chuq.com>
Sergey Fedorov <vital.had@gmail.com>
theanarkh <2923878201@qq.com>
Samuel Cabrero <samuelcabrero@gmail.com>
自发对称破缺 <429839446@qq.com>
Luan Devecchi <luan@engineer.com>
Steven Schveighoffer <schveiguy@gmail.com>
number201724 <number201724@me.com>
Daniel <reymond315qq@gmail.com>
Christian Clason <christian.clason@uni-due.de>
ywave620 <rogertyang@tencent.com>
jensbjorgensen <jbj1@ultraemail.net>
daomingq <daoming.qiu@intel.com>
Qix <Qix-@users.noreply.github.com>
Edward Humes <29870961+aurxenon@users.noreply.github.com>
Tim Besard <tim.besard@gmail.com>
Sergey Rubanov <chi187@gmail.com>
Stefan Stojanovic <StefanStojanovic@users.noreply.github.com>
Zvicii <zvicii@qq.com>
dundargoc <33953936+dundargoc@users.noreply.github.com>
Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
panran <310762957@qq.com>
Tamás Bálint Misius <lbphacker@gmail.com>
Bruno Passeri <Varstahl@users.noreply.github.com>
Jason Zhang <xzha4350@gmail.com>
Lewis Russell <me@lewisr.dev>
sivadeilra <arlie.davis@gmail.com>
cui fliter <imcusg@gmail.com>
Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
Stefan Karpinski <stefan@karpinski.org>
liuxiang88 <94350585+liuxiang88@users.noreply.github.com>
Jeffrey H. Johnson <trnsz@pobox.com>
Abdirahim Musse <33973272+abmusse@users.noreply.github.com>
小明 <7737673+caobug@users.noreply.github.com>
Shuduo Sang <sangshuduo@gmail.com>
Keith Winstein <keithw@cs.stanford.edu>
michalbiesek <michalbiesek@gmail.com>
Alois Klink <alois@aloisklink.com>
SmorkalovG <smorkalov.g@gmail.com>
Pleuvens <pleuvens.fervil@gmail.com>
jolai <58589285+laijonathan@users.noreply.github.com>
Julien Roncaglia <fox@vbfox.net>
prubel <paul@rubels.net>
Per Allansson <65364157+per-allansson@users.noreply.github.com>
Matheus Izvekov <mizvekov@gmail.com>
Christian Heimlich <chris@pcserenity.com>
Hao Hu <33607772+hhu8@users.noreply.github.com>
matoro <12038583+matoro@users.noreply.github.com>
Bo Anderson <mail@boanderson.me>
Ardi Nugraha <33378542+ardi-nugraha@users.noreply.github.com>
Anton Bachin <antonbachin@yahoo.com>
Trevor Flynn <trevorflynn@liquidcrystalstudios.com>
Andy Pan <panjf2000@gmail.com>
Viacheslav Muravyev <slavamuravey@mail.ru>
Anthony Alayo <anthony.alayo@gmail.com>
Thomas Walter <31201229+waltoss@users.noreply.github.com>
hiiizxf <385122613@qq.com>
Geddy <guandichao@163.com>
Farzin Monsef <monseffarzin@gmail.com>
tgolang <154592711+tgolang@users.noreply.github.com>
josedelinux <josedelinux@hotmail.com>
Hüseyin Açacak <110401522+huseyinacacak-janea@users.noreply.github.com>
Uilian Ries <uilianries@gmail.com>
Olivier Valentin <ovalenti@redhat.com>
郑苏波 (Super Zheng) <superzheng@tencent.com>
zeertzjq <zeertzjq@outlook.com>
Ian Butterworth <i.r.butterworth@gmail.com>
握猫猫 <164346864@qq.com>
Zuohui Yang <274048862@qq.com>
Edigleysson Silva (Edy) <edigleyssonsilva@gmail.com>
Raihaan Shouhell <raihaanhimself@gmail.com>
Rialbat <miha-wead@mail.ru>
Adam <adam@NetBSD.org>
Poul T Lomholt <ptlomholt@users.noreply.github.com>
Thad House <ThadHouse@users.noreply.github.com>
Julian A Avar C <28635807+julian-a-avar-c@users.noreply.github.com>
amcgoogan <105525867+amcgoogan@users.noreply.github.com>
Rafael Gonzaga <rafael.nunu@hotmail.com>

View File

@ -1,8 +1,13 @@
cmake_minimum_required(VERSION 3.4) cmake_minimum_required(VERSION 3.10)
project(libuv LANGUAGES C)
cmake_policy(SET CMP0057 NEW) # Enable IN_LIST operator if(POLICY CMP0091)
cmake_policy(SET CMP0064 NEW) # Support if (TEST) operator cmake_policy(SET CMP0091 NEW) # Enable MSVC_RUNTIME_LIBRARY setting
endif()
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW) # disable /W3 warning, if possible
endif()
project(libuv LANGUAGES C)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
@ -17,13 +22,82 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON) set(CMAKE_C_EXTENSIONS ON)
set(CMAKE_C_STANDARD 90) set(CMAKE_C_STANDARD 90)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(LIBUV_BUILD_SHARED "Build shared lib" ON)
cmake_dependent_option(LIBUV_BUILD_TESTS cmake_dependent_option(LIBUV_BUILD_TESTS
"Build the unit tests when BUILD_TESTING is enabled and we are the root project" ON "Build the unit tests when BUILD_TESTING is enabled and we are the root project" ON
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF) "BUILD_TESTING;LIBUV_BUILD_SHARED;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
cmake_dependent_option(LIBUV_BUILD_BENCH cmake_dependent_option(LIBUV_BUILD_BENCH
"Build the benchmarks when building unit tests and we are the root project" ON "Build the benchmarks when building unit tests and we are the root project" ON
"LIBUV_BUILD_TESTS" OFF) "LIBUV_BUILD_TESTS" OFF)
# Qemu Build
option(QEMU "build for qemu" OFF)
if(QEMU)
list(APPEND uv_defines __QEMU__=1)
endif()
# Note: these are mutually exclusive.
option(ASAN "Enable AddressSanitizer (ASan)" OFF)
option(MSAN "Enable MemorySanitizer (MSan)" OFF)
option(TSAN "Enable ThreadSanitizer (TSan)" OFF)
option(UBSAN "Enable UndefinedBehaviorSanitizer (UBSan)" OFF)
if(MSAN AND NOT CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang")
message(SEND_ERROR "MemorySanitizer requires clang. Try again with -DCMAKE_C_COMPILER=clang")
endif()
if(ASAN)
list(APPEND uv_defines __ASAN__=1)
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|GNU|Clang")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
elseif(MSVC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address")
else()
message(SEND_ERROR "AddressSanitizer support requires clang, gcc, or msvc. Try again with -DCMAKE_C_COMPILER.")
endif()
endif()
if(MSAN)
list(APPEND uv_defines __MSAN__=1)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=memory")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=memory")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=memory")
endif()
if(TSAN)
list(APPEND uv_defines __TSAN__=1)
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|GNU|Clang")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=thread")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=thread")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=thread")
else()
message(SEND_ERROR "ThreadSanitizer support requires clang or gcc. Try again with -DCMAKE_C_COMPILER.")
endif()
endif()
if(UBSAN)
cmake_minimum_required(VERSION 3.13)
list(APPEND uv_defines __UBSAN__=1)
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|GNU|Clang")
add_compile_options("-fsanitize=undefined" "-fno-sanitize-recover=undefined")
if (NOT WIN32)
add_link_options("-fsanitize=undefined")
endif()
if(MSVC)
add_compile_options("/Oy-")
else()
add_compile_options("-fno-omit-frame-pointer")
endif()
else()
message(SEND_ERROR "UndefinedBehaviorSanitizer support requires clang or gcc. Try again with -DCMAKE_C_COMPILER.")
endif()
endif()
# Compiler check # Compiler check
string(CONCAT is-msvc $<OR: string(CONCAT is-msvc $<OR:
$<C_COMPILER_ID:MSVC>, $<C_COMPILER_ID:MSVC>,
@ -31,6 +105,18 @@ string(CONCAT is-msvc $<OR:
>) >)
check_c_compiler_flag(/W4 UV_LINT_W4) check_c_compiler_flag(/W4 UV_LINT_W4)
check_c_compiler_flag(/wd4100 UV_LINT_NO_UNUSED_PARAMETER_MSVC)
check_c_compiler_flag(/wd4127 UV_LINT_NO_CONDITIONAL_CONSTANT_MSVC)
check_c_compiler_flag(/wd4201 UV_LINT_NO_NONSTANDARD_MSVC)
check_c_compiler_flag(/wd4206 UV_LINT_NO_NONSTANDARD_EMPTY_TU_MSVC)
check_c_compiler_flag(/wd4210 UV_LINT_NO_NONSTANDARD_FILE_SCOPE_MSVC)
check_c_compiler_flag(/wd4232 UV_LINT_NO_NONSTANDARD_NONSTATIC_DLIMPORT_MSVC)
check_c_compiler_flag(/wd4456 UV_LINT_NO_HIDES_LOCAL)
check_c_compiler_flag(/wd4457 UV_LINT_NO_HIDES_PARAM)
check_c_compiler_flag(/wd4459 UV_LINT_NO_HIDES_GLOBAL)
check_c_compiler_flag(/wd4706 UV_LINT_NO_CONDITIONAL_ASSIGNMENT_MSVC)
check_c_compiler_flag(/wd4996 UV_LINT_NO_UNSAFE_MSVC)
check_c_compiler_flag(-Wall UV_LINT_WALL) # DO NOT use this under MSVC check_c_compiler_flag(-Wall UV_LINT_WALL) # DO NOT use this under MSVC
# TODO: Place these into its own function # TODO: Place these into its own function
@ -38,18 +124,52 @@ check_c_compiler_flag(-Wno-unused-parameter UV_LINT_NO_UNUSED_PARAMETER)
check_c_compiler_flag(-Wstrict-prototypes UV_LINT_STRICT_PROTOTYPES) check_c_compiler_flag(-Wstrict-prototypes UV_LINT_STRICT_PROTOTYPES)
check_c_compiler_flag(-Wextra UV_LINT_EXTRA) check_c_compiler_flag(-Wextra UV_LINT_EXTRA)
check_c_compiler_flag(/utf-8 UV_LINT_UTF8_MSVC)
set(lint-no-unused-parameter $<$<BOOL:${UV_LINT_NO_UNUSED_PARAMETER}>:-Wno-unused-parameter>) set(lint-no-unused-parameter $<$<BOOL:${UV_LINT_NO_UNUSED_PARAMETER}>:-Wno-unused-parameter>)
set(lint-strict-prototypes $<$<BOOL:${UV_LINT_STRICT_PROTOTYPES}>:-Wstrict-prototypes>) set(lint-strict-prototypes $<$<BOOL:${UV_LINT_STRICT_PROTOTYPES}>:-Wstrict-prototypes>)
set(lint-extra $<$<BOOL:${UV_LINT_EXTRA}>:-Wextra>) set(lint-extra $<$<BOOL:${UV_LINT_EXTRA}>:-Wextra>)
set(lint-w4 $<$<BOOL:${UV_LINT_W4}>:/W4>) set(lint-w4 $<$<BOOL:${UV_LINT_W4}>:/W4>)
set(lint-no-unused-parameter-msvc $<$<BOOL:${UV_LINT_NO_UNUSED_PARAMETER_MSVC}>:/wd4100>)
set(lint-no-conditional-constant-msvc $<$<BOOL:${UV_LINT_NO_CONDITIONAL_CONSTANT_MSVC}>:/wd4127>)
set(lint-no-nonstandard-msvc $<$<BOOL:${UV_LINT_NO_NONSTANDARD_MSVC}>:/wd4201>)
set(lint-no-nonstandard-empty-tu-msvc $<$<BOOL:${UV_LINT_NO_NONSTANDARD_EMPTY_TU_MSVC}>:/wd4206>)
set(lint-no-nonstandard-file-scope-msvc $<$<BOOL:${UV_LINT_NO_NONSTANDARD_FILE_SCOPE_MSVC}>:/wd4210>)
set(lint-no-nonstandard-nonstatic-dlimport-msvc $<$<BOOL:${UV_LINT_NO_NONSTANDARD_NONSTATIC_DLIMPORT_MSVC}>:/wd4232>)
set(lint-no-hides-local-msvc $<$<BOOL:${UV_LINT_NO_HIDES_LOCAL}>:/wd4456>)
set(lint-no-hides-param-msvc $<$<BOOL:${UV_LINT_NO_HIDES_PARAM}>:/wd4457>)
set(lint-no-hides-global-msvc $<$<BOOL:${UV_LINT_NO_HIDES_GLOBAL}>:/wd4459>)
set(lint-no-conditional-assignment-msvc $<$<BOOL:${UV_LINT_NO_CONDITIONAL_ASSIGNMENT_MSVC}>:/wd4706>)
set(lint-no-unsafe-msvc $<$<BOOL:${UV_LINT_NO_UNSAFE_MSVC}>:/wd4996>)
# Unfortunately, this one is complicated because MSVC and clang-cl support -Wall # Unfortunately, this one is complicated because MSVC and clang-cl support -Wall
# but using it is like calling -Weverything # but using it is like calling -Weverything
string(CONCAT lint-default $< string(CONCAT lint-default $<
$<AND:$<BOOL:${UV_LINT_WALL}>,$<NOT:${is-msvc}>>:-Wall $<AND:$<BOOL:${UV_LINT_WALL}>,$<NOT:${is-msvc}>>:-Wall
>) >)
set(lint-utf8-msvc $<$<BOOL:${UV_LINT_UTF8_MSVC}>:/utf-8>)
list(APPEND uv_cflags ${lint-strict-prototypes} ${lint-extra} ${lint-default} ${lint-w4}) list(APPEND uv_cflags ${lint-strict-prototypes} ${lint-extra} ${lint-default} ${lint-w4})
list(APPEND uv_cflags ${lint-no-unused-parameter}) list(APPEND uv_cflags ${lint-no-unused-parameter})
list(APPEND uv_cflags ${lint-no-unused-parameter-msvc})
list(APPEND uv_cflags ${lint-no-conditional-constant-msvc})
list(APPEND uv_cflags ${lint-no-nonstandard-msvc})
list(APPEND uv_cflags ${lint-no-nonstandard-empty-tu-msvc})
list(APPEND uv_cflags ${lint-no-nonstandard-file-scope-msvc})
list(APPEND uv_cflags ${lint-no-nonstandard-nonstatic-dlimport-msvc})
list(APPEND uv_cflags ${lint-no-hides-local-msvc})
list(APPEND uv_cflags ${lint-no-hides-param-msvc})
list(APPEND uv_cflags ${lint-no-hides-global-msvc})
list(APPEND uv_cflags ${lint-no-conditional-assignment-msvc})
list(APPEND uv_cflags ${lint-no-unsafe-msvc})
list(APPEND uv_cflags ${lint-utf8-msvc} )
check_c_compiler_flag(-fno-strict-aliasing UV_F_STRICT_ALIASING)
list(APPEND uv_cflags $<$<BOOL:${UV_F_STRICT_ALIASING}>:-fno-strict-aliasing>)
if (MSVC)
# Error on calling undeclared functions.
list(APPEND uv_cflags "/we4013")
endif()
set(uv_sources set(uv_sources
src/fs-poll.c src/fs-poll.c
@ -57,6 +177,8 @@ set(uv_sources
src/inet.c src/inet.c
src/random.c src/random.c
src/strscpy.c src/strscpy.c
src/strtok.c
src/thread-common.c
src/threadpool.c src/threadpool.c
src/timer.c src/timer.c
src/uv-common.c src/uv-common.c
@ -64,25 +186,17 @@ set(uv_sources
src/version.c) src/version.c)
if(WIN32) if(WIN32)
if (CMAKE_SYSTEM_VERSION VERSION_GREATER 10) # Windows 10 list(APPEND uv_defines WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0A00 _CRT_DECLARE_NONSTDC_NAMES=0)
set(windows-version 0x0A00)
elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.3) # Windows 8.1
set(windows-version 0x0603)
elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.2) # Windows 8
set(windows-version 0x0602)
elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.1) # Windows 7
set(windows-version 0x0601)
elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.0) # Windows Vista
set(windows-version 0x0600)
else()
message(FATAL_ERROR "Windows Vista is the minimum version supported")
endif()
list(APPEND uv_defines WIN32_LEAN_AND_MEAN _WIN32_WINNT=${windows-version})
list(APPEND uv_libraries list(APPEND uv_libraries
$<$<STREQUAL:${windows-version},0x0600>:psapi> psapi
user32
advapi32
iphlpapi iphlpapi
userenv userenv
ws2_32) ws2_32
dbghelp
ole32
shell32)
list(APPEND uv_sources list(APPEND uv_sources
src/win/async.c src/win/async.c
src/win/core.c src/win/core.c
@ -113,7 +227,7 @@ if(WIN32)
list(APPEND uv_test_sources src/win/snprintf.c test/runner-win.c) list(APPEND uv_test_sources src/win/snprintf.c test/runner-win.c)
else() else()
list(APPEND uv_defines _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE) list(APPEND uv_defines _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Android|OS390") if(NOT CMAKE_SYSTEM_NAME MATCHES "Android|OS390|QNX")
# TODO: This should be replaced with find_package(Threads) if possible # TODO: This should be replaced with find_package(Threads) if possible
# Android has pthread as part of its c library, not as a separate # Android has pthread as part of its c library, not as a separate
# libpthread.so. # libpthread.so.
@ -155,21 +269,17 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Android") if(CMAKE_SYSTEM_NAME STREQUAL "Android")
list(APPEND uv_libs dl) list(APPEND uv_defines _GNU_SOURCE)
list(APPEND uv_libraries dl)
list(APPEND uv_sources list(APPEND uv_sources
src/unix/android-ifaddrs.c src/unix/linux.c
src/unix/linux-core.c
src/unix/linux-inotify.c
src/unix/linux-syscalls.c
src/unix/procfs-exepath.c src/unix/procfs-exepath.c
src/unix/pthread-fixes.c
src/unix/random-getentropy.c src/unix/random-getentropy.c
src/unix/random-getrandom.c src/unix/random-getrandom.c
src/unix/random-sysctl-linux.c src/unix/random-sysctl-linux.c)
src/unix/sysinfo-loadavg.c)
endif() endif()
if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Android|Linux|OS390") if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Android|Linux")
list(APPEND uv_sources src/unix/proctitle.c) list(APPEND uv_sources src/unix/proctitle.c)
endif() endif()
@ -179,7 +289,6 @@ endif()
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD") if(CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
list(APPEND uv_sources src/unix/posix-hrtime.c src/unix/bsd-proctitle.c) list(APPEND uv_sources src/unix/posix-hrtime.c src/unix/bsd-proctitle.c)
list(APPEND uv_libraries kvm)
endif() endif()
if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD") if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
@ -202,21 +311,31 @@ if(APPLE)
src/unix/fsevents.c) src/unix/fsevents.c)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "GNU")
list(APPEND uv_defines _GNU_SOURCE _POSIX_C_SOURCE=200112 _XOPEN_SOURCE=500)
list(APPEND uv_libraries dl)
list(APPEND uv_sources
src/unix/bsd-ifaddrs.c
src/unix/no-fsevents.c
src/unix/no-proctitle.c
src/unix/posix-hrtime.c
src/unix/posix-poll.c
src/unix/hurd.c)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND uv_defines _GNU_SOURCE _POSIX_C_SOURCE=200112) list(APPEND uv_defines _GNU_SOURCE _POSIX_C_SOURCE=200112)
list(APPEND uv_libraries dl rt) list(APPEND uv_libraries dl rt)
list(APPEND uv_sources list(APPEND uv_sources
src/unix/linux-core.c src/unix/linux.c
src/unix/linux-inotify.c
src/unix/linux-syscalls.c
src/unix/procfs-exepath.c src/unix/procfs-exepath.c
src/unix/random-getrandom.c src/unix/random-getrandom.c
src/unix/random-sysctl-linux.c src/unix/random-sysctl-linux.c)
src/unix/sysinfo-loadavg.c)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
list(APPEND uv_sources src/unix/netbsd.c) list(APPEND uv_sources src/unix/netbsd.c)
list(APPEND uv_libraries kvm)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
@ -224,9 +343,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "OS390") if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
list(APPEND uv_defines PATH_MAX=255) enable_language(CXX)
list(APPEND uv_defines PATH_MAX=1024)
list(APPEND uv_defines _AE_BIMODAL) list(APPEND uv_defines _AE_BIMODAL)
list(APPEND uv_defines _ALL_SOURCE) list(APPEND uv_defines _ALL_SOURCE)
list(APPEND uv_defines _ENHANCED_ASCII_EXT=0xFFFFFFFF)
list(APPEND uv_defines _ISOC99_SOURCE) list(APPEND uv_defines _ISOC99_SOURCE)
list(APPEND uv_defines _LARGE_TIME_API) list(APPEND uv_defines _LARGE_TIME_API)
list(APPEND uv_defines _OPEN_MSGQ_EXT) list(APPEND uv_defines _OPEN_MSGQ_EXT)
@ -237,14 +358,30 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
list(APPEND uv_defines _UNIX03_SOURCE) list(APPEND uv_defines _UNIX03_SOURCE)
list(APPEND uv_defines _UNIX03_THREADS) list(APPEND uv_defines _UNIX03_THREADS)
list(APPEND uv_defines _UNIX03_WITHDRAWN) list(APPEND uv_defines _UNIX03_WITHDRAWN)
list(APPEND uv_defines _XOPEN_SOURCE=600)
list(APPEND uv_defines _XOPEN_SOURCE_EXTENDED) list(APPEND uv_defines _XOPEN_SOURCE_EXTENDED)
list(APPEND uv_sources list(APPEND uv_sources
src/unix/pthread-fixes.c
src/unix/os390.c src/unix/os390.c
src/unix/os390-syscalls.c) src/unix/os390-syscalls.c
list(APPEND uv_cflags -Wc,DLL -Wc,exportall -Wc,xplink) src/unix/os390-proctitle.c)
list(APPEND uv_libraries -Wl,xplink) list(APPEND uv_cflags
list(APPEND uv_test_libraries -Wl,xplink) -q64
-qascii
-qexportall
-qgonumber
-qlongname
-qlibansi
-qfloat=IEEE
-qtune=10
-qarch=10
-qasm
-qasmlib=sys1.maclib:sys1.modgen)
find_library(ZOSLIB
NAMES zoslib
PATHS ${ZOSLIB_DIR}
PATH_SUFFIXES lib
)
list(APPEND uv_libraries ${ZOSLIB})
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "OS400") if(CMAKE_SYSTEM_NAME STREQUAL "OS400")
@ -257,20 +394,63 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS400")
src/unix/aix-common.c src/unix/aix-common.c
src/unix/ibmi.c src/unix/ibmi.c
src/unix/no-fsevents.c src/unix/no-fsevents.c
src/unix/no-proctitle.c
src/unix/posix-poll.c) src/unix/posix-poll.c)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
list(APPEND uv_defines __EXTENSIONS__ _XOPEN_SOURCE=500) if(CMAKE_SYSTEM_VERSION STREQUAL "5.10")
list(APPEND uv_defines SUNOS_NO_IFADDRS)
list(APPEND uv_libraries rt)
endif()
list(APPEND uv_defines __EXTENSIONS__ _XOPEN_SOURCE=500 _REENTRANT)
list(APPEND uv_libraries kstat nsl sendfile socket) list(APPEND uv_libraries kstat nsl sendfile socket)
list(APPEND uv_sources src/unix/no-proctitle.c src/unix/sunos.c) list(APPEND uv_sources
src/unix/no-proctitle.c
src/unix/sunos.c)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
list(APPEND uv_defines _BSD_SOURCE)
list(APPEND uv_libraries bsd network)
list(APPEND uv_sources
src/unix/haiku.c
src/unix/bsd-ifaddrs.c
src/unix/no-fsevents.c
src/unix/no-proctitle.c
src/unix/posix-hrtime.c
src/unix/posix-poll.c)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
list(APPEND uv_sources
src/unix/posix-hrtime.c
src/unix/posix-poll.c
src/unix/qnx.c
src/unix/bsd-ifaddrs.c
src/unix/no-proctitle.c
src/unix/no-fsevents.c)
list(APPEND uv_libraries socket)
endif() endif()
if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD") if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD")
list(APPEND uv_test_libraries util) list(APPEND uv_test_libraries util)
endif() endif()
if(CYGWIN OR MSYS)
list(APPEND uv_defines _GNU_SOURCE)
list(APPEND uv_sources
src/unix/cygwin.c
src/unix/bsd-ifaddrs.c
src/unix/no-fsevents.c
src/unix/no-proctitle.c
src/unix/posix-hrtime.c
src/unix/posix-poll.c
src/unix/procfs-exepath.c
src/unix/sysinfo-loadavg.c
src/unix/sysinfo-memory.c)
endif()
if(LIBUV_BUILD_SHARED)
add_library(uv SHARED ${uv_sources}) add_library(uv SHARED ${uv_sources})
target_compile_definitions(uv target_compile_definitions(uv
INTERFACE INTERFACE
@ -285,7 +465,13 @@ target_include_directories(uv
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>) $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
target_include_directories(uv PUBLIC $<BUILD_INTERFACE:${ZOSLIB_DIR}/include>)
set_target_properties(uv PROPERTIES LINKER_LANGUAGE CXX)
endif()
target_link_libraries(uv ${uv_libraries}) target_link_libraries(uv ${uv_libraries})
set_target_properties(uv PROPERTIES OUTPUT_NAME "uv")
endif()
add_library(uv_a STATIC ${uv_sources}) add_library(uv_a STATIC ${uv_sources})
target_compile_definitions(uv_a PRIVATE ${uv_defines}) target_compile_definitions(uv_a PRIVATE ${uv_defines})
@ -296,7 +482,15 @@ target_include_directories(uv_a
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>) $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
target_include_directories(uv_a PUBLIC $<BUILD_INTERFACE:${ZOSLIB_DIR}/include>)
set_target_properties(uv_a PROPERTIES LINKER_LANGUAGE CXX)
endif()
target_link_libraries(uv_a ${uv_libraries}) target_link_libraries(uv_a ${uv_libraries})
set_target_properties(uv_a PROPERTIES OUTPUT_NAME "uv")
if(WIN32)
set_target_properties(uv_a PROPERTIES PREFIX "lib")
endif()
if(LIBUV_BUILD_TESTS) if(LIBUV_BUILD_TESTS)
# Small hack: use ${uv_test_sources} now to get the runner skeleton, # Small hack: use ${uv_test_sources} now to get the runner skeleton,
@ -309,6 +503,7 @@ if(LIBUV_BUILD_TESTS)
test/benchmark-fs-stat.c test/benchmark-fs-stat.c
test/benchmark-getaddrinfo.c test/benchmark-getaddrinfo.c
test/benchmark-loop-count.c test/benchmark-loop-count.c
test/benchmark-queue-work.c
test/benchmark-million-async.c test/benchmark-million-async.c
test/benchmark-million-timers.c test/benchmark-million-timers.c
test/benchmark-multi-accept.c test/benchmark-multi-accept.c
@ -322,7 +517,6 @@ if(LIBUV_BUILD_TESTS)
test/benchmark-thread.c test/benchmark-thread.c
test/benchmark-udp-pummel.c test/benchmark-udp-pummel.c
test/blackhole-server.c test/blackhole-server.c
test/dns-server.c
test/echo-server.c test/echo-server.c
test/run-benchmarks.c test/run-benchmarks.c
test/runner.c) test/runner.c)
@ -339,7 +533,6 @@ if(LIBUV_BUILD_TESTS)
test/test-async-null-cb.c test/test-async-null-cb.c
test/test-async.c test/test-async.c
test/test-barrier.c test/test-barrier.c
test/test-callback-order.c
test/test-callback-stack.c test/test-callback-stack.c
test/test-close-fd.c test/test-close-fd.c
test/test-close-order.c test/test-close-order.c
@ -379,8 +572,10 @@ if(LIBUV_BUILD_TESTS)
test/test-hrtime.c test/test-hrtime.c
test/test-idle.c test/test-idle.c
test/test-idna.c test/test-idna.c
test/test-iouring-pollhup.c
test/test-ip4-addr.c test/test-ip4-addr.c
test/test-ip6-addr.c test/test-ip6-addr.c
test/test-ip-name.c
test/test-ipc-heavy-traffic-deadlock-bug.c test/test-ipc-heavy-traffic-deadlock-bug.c
test/test-ipc-send-recv.c test/test-ipc-send-recv.c
test/test-ipc.c test/test-ipc.c
@ -390,8 +585,11 @@ if(LIBUV_BUILD_TESTS)
test/test-loop-handles.c test/test-loop-handles.c
test/test-loop-stop.c test/test-loop-stop.c
test/test-loop-time.c test/test-loop-time.c
test/test-metrics.c
test/test-multiple-listen.c test/test-multiple-listen.c
test/test-mutexes.c test/test-mutexes.c
test/test-not-readable-nor-writable-on-read-error.c
test/test-not-writable-after-shutdown.c
test/test-osx-select.c test/test-osx-select.c
test/test-pass-always.c test/test-pass-always.c
test/test-ping-pong.c test/test-ping-pong.c
@ -410,6 +608,7 @@ if(LIBUV_BUILD_TESTS)
test/test-poll-close-doesnt-corrupt-stack.c test/test-poll-close-doesnt-corrupt-stack.c
test/test-poll-close.c test/test-poll-close.c
test/test-poll-closesocket.c test/test-poll-closesocket.c
test/test-poll-multiple-handles.c
test/test-poll-oob.c test/test-poll-oob.c
test/test-poll.c test/test-poll.c
test/test-process-priority.c test/test-process-priority.c
@ -417,12 +616,14 @@ if(LIBUV_BUILD_TESTS)
test/test-process-title.c test/test-process-title.c
test/test-queue-foreach-delete.c test/test-queue-foreach-delete.c
test/test-random.c test/test-random.c
test/test-readable-on-eof.c
test/test-ref.c test/test-ref.c
test/test-run-nowait.c test/test-run-nowait.c
test/test-run-once.c test/test-run-once.c
test/test-semaphore.c test/test-semaphore.c
test/test-shutdown-close.c test/test-shutdown-close.c
test/test-shutdown-eof.c test/test-shutdown-eof.c
test/test-shutdown-simultaneous.c
test/test-shutdown-twice.c test/test-shutdown-twice.c
test/test-signal-multiple-loops.c test/test-signal-multiple-loops.c
test/test-signal-pending-on-close.c test/test-signal-pending-on-close.c
@ -431,10 +632,12 @@ if(LIBUV_BUILD_TESTS)
test/test-spawn.c test/test-spawn.c
test/test-stdio-over-pipes.c test/test-stdio-over-pipes.c
test/test-strscpy.c test/test-strscpy.c
test/test-strtok.c
test/test-tcp-alloc-cb-fail.c test/test-tcp-alloc-cb-fail.c
test/test-tcp-bind-error.c test/test-tcp-bind-error.c
test/test-tcp-bind6-error.c test/test-tcp-bind6-error.c
test/test-tcp-close-accept.c test/test-tcp-close-accept.c
test/test-tcp-close-after-read-timeout.c
test/test-tcp-close-while-connecting.c test/test-tcp-close-while-connecting.c
test/test-tcp-close.c test/test-tcp-close.c
test/test-tcp-close-reset.c test/test-tcp-close-reset.c
@ -447,8 +650,12 @@ if(LIBUV_BUILD_TESTS)
test/test-tcp-oob.c test/test-tcp-oob.c
test/test-tcp-open.c test/test-tcp-open.c
test/test-tcp-read-stop.c test/test-tcp-read-stop.c
test/test-tcp-reuseport.c
test/test-tcp-read-stop-start.c
test/test-tcp-rst.c
test/test-tcp-shutdown-after-write.c test/test-tcp-shutdown-after-write.c
test/test-tcp-try-write.c test/test-tcp-try-write.c
test/test-tcp-write-in-a-row.c
test/test-tcp-try-write-error.c test/test-tcp-try-write-error.c
test/test-tcp-unexpected-read.c test/test-tcp-unexpected-read.c
test/test-tcp-write-after-connect.c test/test-tcp-write-after-connect.c
@ -456,8 +663,12 @@ if(LIBUV_BUILD_TESTS)
test/test-tcp-write-queue-order.c test/test-tcp-write-queue-order.c
test/test-tcp-write-to-half-open-connection.c test/test-tcp-write-to-half-open-connection.c
test/test-tcp-writealot.c test/test-tcp-writealot.c
test/test-test-macros.c
test/test-thread-affinity.c
test/test-thread-equal.c test/test-thread-equal.c
test/test-thread.c test/test-thread.c
test/test-thread-name.c
test/test-thread-priority.c
test/test-threadpool-cancel.c test/test-threadpool-cancel.c
test/test-threadpool.c test/test-threadpool.c
test/test-timer-again.c test/test-timer-again.c
@ -470,9 +681,11 @@ if(LIBUV_BUILD_TESTS)
test/test-udp-alloc-cb-fail.c test/test-udp-alloc-cb-fail.c
test/test-udp-bind.c test/test-udp-bind.c
test/test-udp-connect.c test/test-udp-connect.c
test/test-udp-connect6.c
test/test-udp-create-socket-early.c test/test-udp-create-socket-early.c
test/test-udp-dgram-too-big.c test/test-udp-dgram-too-big.c
test/test-udp-ipv6.c test/test-udp-ipv6.c
test/test-udp-mmsg.c
test/test-udp-multicast-interface.c test/test-udp-multicast-interface.c
test/test-udp-multicast-interface6.c test/test-udp-multicast-interface6.c
test/test-udp-multicast-join.c test/test-udp-multicast-join.c
@ -483,13 +696,16 @@ if(LIBUV_BUILD_TESTS)
test/test-udp-send-and-recv.c test/test-udp-send-and-recv.c
test/test-udp-send-hang-loop.c test/test-udp-send-hang-loop.c
test/test-udp-send-immediate.c test/test-udp-send-immediate.c
test/test-udp-sendmmsg-error.c
test/test-udp-send-unreachable.c test/test-udp-send-unreachable.c
test/test-udp-try-send.c test/test-udp-try-send.c
test/test-udp-recv-in-a-row.c
test/test-udp-reuseport.c
test/test-uname.c test/test-uname.c
test/test-walk-handles.c test/test-walk-handles.c
test/test-watcher-cross-stop.c) test/test-watcher-cross-stop.c)
add_executable(uv_run_tests ${uv_test_sources}) add_executable(uv_run_tests ${uv_test_sources} uv_win_longpath.manifest)
target_compile_definitions(uv_run_tests target_compile_definitions(uv_run_tests
PRIVATE ${uv_defines} USING_UV_SHARED=1) PRIVATE ${uv_defines} USING_UV_SHARED=1)
target_compile_options(uv_run_tests PRIVATE ${uv_cflags}) target_compile_options(uv_run_tests PRIVATE ${uv_cflags})
@ -501,16 +717,36 @@ if(LIBUV_BUILD_TESTS)
set_tests_properties(uv_test PROPERTIES ENVIRONMENT set_tests_properties(uv_test PROPERTIES ENVIRONMENT
"LIBPATH=${CMAKE_BINARY_DIR}:$ENV{LIBPATH}") "LIBPATH=${CMAKE_BINARY_DIR}:$ENV{LIBPATH}")
endif() endif()
add_executable(uv_run_tests_a ${uv_test_sources}) if(WIN32)
add_custom_command(TARGET uv_run_tests POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:uv_run_tests>"
"$<TARGET_FILE_DIR:uv_run_tests>/uv_run_tests_no_ext")
endif()
add_executable(uv_run_tests_a ${uv_test_sources} uv_win_longpath.manifest)
target_compile_definitions(uv_run_tests_a PRIVATE ${uv_defines}) target_compile_definitions(uv_run_tests_a PRIVATE ${uv_defines})
target_compile_options(uv_run_tests_a PRIVATE ${uv_cflags}) target_compile_options(uv_run_tests_a PRIVATE ${uv_cflags})
if(QEMU)
target_link_libraries(uv_run_tests_a uv_a ${uv_test_libraries} -static)
else()
target_link_libraries(uv_run_tests_a uv_a ${uv_test_libraries}) target_link_libraries(uv_run_tests_a uv_a ${uv_test_libraries})
endif()
add_test(NAME uv_test_a add_test(NAME uv_test_a
COMMAND uv_run_tests_a COMMAND uv_run_tests_a
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
set_target_properties(uv_run_benchmarks_a PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(uv_run_tests PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(uv_run_tests_a PROPERTIES LINKER_LANGUAGE CXX)
endif()
if(WIN32)
add_custom_command(TARGET uv_run_tests_a POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:uv_run_tests_a>"
"$<TARGET_FILE_DIR:uv_run_tests_a>/uv_run_tests_a_no_ext")
endif()
endif() endif()
if(UNIX)
# Now for some gibbering horrors from beyond the stars... # Now for some gibbering horrors from beyond the stars...
foreach(lib IN LISTS uv_libraries) foreach(lib IN LISTS uv_libraries)
list(APPEND LIBS "-l${lib}") list(APPEND LIBS "-l${lib}")
@ -520,27 +756,59 @@ if(UNIX)
file(STRINGS configure.ac configure_ac REGEX ^AC_INIT) file(STRINGS configure.ac configure_ac REGEX ^AC_INIT)
string(REGEX MATCH "([0-9]+)[.][0-9]+[.][0-9]+" PACKAGE_VERSION "${configure_ac}") string(REGEX MATCH "([0-9]+)[.][0-9]+[.][0-9]+" PACKAGE_VERSION "${configure_ac}")
set(UV_VERSION_MAJOR "${CMAKE_MATCH_1}") set(UV_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(prefix ${CMAKE_INSTALL_PREFIX})
configure_file(libuv-static.pc.in libuv-static.pc @ONLY)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES LICENSE-extra DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES ${PROJECT_BINARY_DIR}/libuv-static.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(TARGETS uv_a EXPORT libuvConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT libuvConfig
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libuv
NAMESPACE libuv::)
if(LIBUV_BUILD_SHARED)
# The version in the filename is mirroring the behaviour of autotools. # The version in the filename is mirroring the behaviour of autotools.
set_target_properties(uv PROPERTIES set_target_properties(uv PROPERTIES
VERSION ${UV_VERSION_MAJOR}.0.0 VERSION ${UV_VERSION_MAJOR}.0.0
SOVERSION ${UV_VERSION_MAJOR}) SOVERSION ${UV_VERSION_MAJOR})
set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(prefix ${CMAKE_INSTALL_PREFIX})
configure_file(libuv.pc.in libuv.pc @ONLY) configure_file(libuv.pc.in libuv.pc @ONLY)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES ${PROJECT_BINARY_DIR}/libuv.pc install(FILES ${PROJECT_BINARY_DIR}/libuv.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(TARGETS uv LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS uv EXPORT libuvConfig
install(TARGETS uv_a ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif() endif()
if(WIN32) if(MSVC)
install(DIRECTORY include/ DESTINATION include) set(CMAKE_DEBUG_POSTFIX d)
install(FILES LICENSE DESTINATION .) get_filename_component(CMAKE_C_COMPILER_DIR ${CMAKE_C_COMPILER} DIRECTORY)
install(TARGETS uv uv_a if(ASAN)
RUNTIME DESTINATION lib/$<CONFIG> file(INSTALL "${CMAKE_C_COMPILER_DIR}/llvm-symbolizer.exe" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
ARCHIVE DESTINATION lib/$<CONFIG>) file(INSTALL "${CMAKE_C_COMPILER_DIR}/clang_rt.asan_dynamic-x86_64.dll" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(INSTALL "${CMAKE_C_COMPILER_DIR}/clang_rt.asan_dbg_dynamic-x86_64.dll" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
endif() endif()
endif()
if(BUILD_SHARED_LIBS)
set(LIB_SELECTED uv)
else()
set(LIB_SELECTED uv_a)
endif()
add_library(libuv::libuv ALIAS ${LIB_SELECTED})
message(STATUS "summary of build options:
Install prefix: ${CMAKE_INSTALL_PREFIX}
Target system: ${CMAKE_SYSTEM_NAME}
Compiler:
C compiler: ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID})
CFLAGS: ${CMAKE_C_FLAGS_${_build_type}} ${CMAKE_C_FLAGS}
")

View File

@ -23,11 +23,11 @@ The stable branch is effectively frozen; patches that change the libuv
API/ABI or affect the run-time behavior of applications get rejected. API/ABI or affect the run-time behavior of applications get rejected.
In case of doubt, open an issue in the [issue tracker][], post your question In case of doubt, open an issue in the [issue tracker][], post your question
to the [libuv mailing list], or contact one of [project maintainers][] on [IRC][]. to the [libuv discussions forum], or message the [libuv mailing list].
Especially do so if you plan to work on something big. Nothing is more Especially do so if you plan to work on something big. Nothing is more
frustrating than seeing your hard work go to waste because your vision frustrating than seeing your hard work go to waste because your vision does not
does not align with that of a project maintainers. align with that of the [project maintainers].
### BRANCH ### BRANCH
@ -166,6 +166,6 @@ not send out notifications when you add commits.
[issue tracker]: https://github.com/libuv/libuv/issues [issue tracker]: https://github.com/libuv/libuv/issues
[libuv mailing list]: http://groups.google.com/group/libuv [libuv mailing list]: http://groups.google.com/group/libuv
[IRC]: http://webchat.freenode.net/?channels=libuv [libuv discussions forum]: https://github.com/libuv/libuv/discussions
[Google C/C++ style guide]: https://google.github.io/styleguide/cppguide.html [Google C/C++ style guide]: https://google.github.io/styleguide/cppguide.html
[project maintainers]: https://github.com/libuv/libuv/blob/master/MAINTAINERS.md [project maintainers]: https://github.com/libuv/libuv/blob/master/MAINTAINERS.md

1695
ChangeLog

File diff suppressed because it is too large Load Diff

51
LICENSE
View File

@ -1,6 +1,3 @@
libuv is licensed for use as follows:
====
Copyright (c) 2015-present libuv project contributors. Copyright (c) 2015-present libuv project contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
@ -20,51 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE. IN THE SOFTWARE.
====
This license applies to parts of libuv originating from the
https://github.com/joyent/libuv repository:
====
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
====
This license applies to all parts of libuv that are not externally
maintained libraries.
The externally maintained libraries used by libuv are:
- tree.h (from FreeBSD), copyright Niels Provos. Two clause BSD license.
- inet_pton and inet_ntop implementations, contained in src/inet.c, are
copyright the Internet Systems Consortium, Inc., and licensed under the ISC
license.
- stdint-msvc2008.h (from msinttypes), copyright Alexander Chemeris. Three
clause BSD license.
- pthread-fixes.c, copyright Google Inc. and Sony Mobile Communications AB.
Three clause BSD license.
- android-ifaddrs.h, android-ifaddrs.c, copyright Berkeley Software Design
Inc, Kenneth MacKay and Emergya (Cloud4all, FP7/2007-2013, grant agreement
n° 289016). Three clause BSD license.

36
LICENSE-extra Normal file
View File

@ -0,0 +1,36 @@
This license applies to parts of libuv originating from the
https://github.com/joyent/libuv repository:
====
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
====
This license applies to all parts of libuv that are not externally
maintained libraries.
The externally maintained libraries used by libuv are:
- tree.h (from FreeBSD), copyright Niels Provos. Two clause BSD license.
- inet_pton and inet_ntop implementations, contained in src/inet.c, are
copyright the Internet Systems Consortium, Inc., and licensed under the ISC
license.

112
LINKS.md Normal file
View File

@ -0,0 +1,112 @@
### Apps / VM
* [AliceO2](https://github.com/AliceO2Group/AliceO2): The framework and detector specific code for the reconstruction, calibration and simulation for the ALICE experiment at CERN.
* [Beam](https://github.com/BeamMW/beam): A scalable, confidential cryptocurrency based on the Mimblewimble protocol.
* [BIND 9](https://bind.isc.org/): DNS software system including an authoritative server, a recursive resolver and related utilities.
* [cjdns](https://github.com/cjdelisle/cjdns): Encrypted self-configuring network/VPN routing engine
* [clearskies_core](https://github.com/larroy/clearskies_core): Clearskies file synchronization program. (C++11)
* [CMake](https://cmake.org) open-source, cross-platform family of tools designed to build, test and package software
* [Cocos-Engine](https://github.com/cocos/cocos-engine): The runtime framework for Cocos Creator editor.
* [Coherence](https://github.com/liesware/coherence/): Cryptographic server for modern web apps.
* [DPS8M](https://dps8m.gitlab.io): GE Honeywell Bull DPS8/M and 6180/L68 mainframe simulator.
* [DPS-For-IoT](https://github.com/intel/dps-for-iot/wiki): Fully distributed publish/subscribe protocol.
* [HashLink](https://github.com/HaxeFoundation/hashlink): Haxe run-time with libuv support included.
* [Haywire](https://github.com/kellabyte/Haywire): Asynchronous HTTP server.
* [H2O](https://github.com/h2o/h2o): An optimized HTTP server with support for HTTP/1.x and HTTP/2.
* [Igropyr](https://github.com/guenchi/Igropyr): a async Scheme http server base on libuv.
* [Julia](http://julialang.org/): Scientific computing programming language
* [Kestrel](https://github.com/dotnet/aspnetcore/tree/main/src/Servers/Kestrel): web server (C# + libuv + [ASP.NET Core](http://github.com/aspnet))
* [Knot DNS Resolver](https://www.knot-resolver.cz/): A minimalistic DNS caching resolver
* [Lever](http://leverlanguage.com): runtime, libuv at the 0.9.0 release
* [libnode](https://github.com/plenluno/libnode): C++ implementation of Node.js
* [libstorj](https://github.com/Storj/libstorj): Library for interacting with Storj network
* [libuv_message_framing](https://github.com/litesync/libuv_message_framing) Message-based communication for libuv
* [luaw](https://github.com/raksoras/luaw): Lua web server backed by libuv
* [Luvit](http://luvit.io): Node.JS for the Lua Inventor
* [mo](https://github.com/wehu/mo): Scheme (guile) + libuv runtime
* [MoarVM](https://github.com/MoarVM/MoarVM): a VM for [Rakudo](http://rakudo.org/) [Raku](http://raku.org)
* [Mysocks](https://github.com/zhou0/mysocks): a cross-platform [Shadowsocks](https://shadowsocks.org) client
* [mediasoup](http://mediasoup.org): Powerful WebRTC SFU for Node.js
* [Neovim](https://neovim.io/): A major refactor of Vim.
* [node9](https://github.com/jvburnes/node9): A portable, hybrid, distributed OS based on Inferno, LuaJIT and Libuv
* [node.js](http://www.nodejs.org/): Javascript (using Google's V8) + libuv
* [node.native](https://github.com/d5/node.native): node.js-like API for C++11
* [nodeuv](https://github.com/nodeuv): An organization with several c++ wrappers for libs which are used in node.js.
* [phastlight](https://github.com/phastlight/phastlight): Command line tool and web server written in PHP 5.3+ inspired by Node.js
* [pilight](https://www.pilight.org/): home automation ("domotica")
* [pixie](https://github.com/pixie-lang/pixie): clojure-inspired lisp with a tracing JIT
* [Pixie-io](https://github.com/pixie-io/pixie): Open-source observability tool for Kubernetes applications.
* [potion](https://github.com/perl11/potion)/[p2](https://github.com/perl11/p2): runtime
* [racer](https://libraries.io/rubygems/racer): Ruby web server written as an C extension
* [scala-native-loop](https://github.com/scala-native/scala-native-loop): Extensible event loop and async-oriented IO for Scala Native; powered by libuv
* [Socket Runtime](https://sockets.sh): A runtime for creating native cross-platform software on mobile and desktop using HTML, CSS, and JavaScript
* [spider-gazelle](https://github.com/cotag/spider-gazelle): Ruby web server using libuv bindings
* [Suave](http://suave.io/): A simple web development F# library providing a lightweight web server and a set of combinators to manipulate route flow and task composition
* [Swish](https://github.com/becls/swish/): Concurrency engine with Erlang-like concepts. Includes a web server.
* [Trevi](https://github.com/Yoseob/Trevi): A powerful Swift Web Application Server Framework Project
* [Urbit](http://urbit.org): runtime
* [uv_callback](https://github.com/litesync/uv_callback) libuv thread communication
* [uvloop](https://github.com/MagicStack/uvloop): Ultra fast implementation of python's asyncio event loop on top of libuv
* [WPILib](https://github.com/wpilibsuite/allwpilib): Libraries for creating robot programs for the roboRIO.
* [Wren CLI](https://github.com/wren-lang/wren-cli): For io, process, scheduler and timer modules
### Other
* [libtuv](https://github.com/Samsung/libtuv): libuv fork for IoT and embedded systems
### Bindings
* [Ring](http://ring-lang.net)
* [RingLibuv](http://ring-lang.sourceforge.net/doc1.7/libuv.html)
* Ruby
* [libuv](https://github.com/cotag/libuv)
* [uvrb](https://github.com/avalanche123/uvrb)
* [ruv](https://github.com/aq1018/ruv)
* [rbuv](https://github.com/rbuv/rbuv)
* [mruby-uv](https://github.com/mattn/mruby-uv): mruby binding
* Lua
* [luv](https://github.com/creationix/luv)
* [lev](https://github.com/connectFree/lev)
* [lluv](https://github.com/moteus/lua-lluv)
* C++11
* [uvpp](https://github.com/larroy/uvpp) - Not complete, exposes very few aspects of `libuv`
* [nsuv](https://github.com/nodesource/nsuv) - Template wrapper focused on enforcing compile-time type safety when propagating data
* C++17
* [uvw](https://github.com/skypjack/uvw) - Header-only, event based, tiny and easy to use *libuv* wrapper in modern C++.
* Python
* [Pyuv](https://github.com/saghul/pyuv)
* [uvloop](https://github.com/MagicStack/uvloop) - Ultra fast asyncio event loop.
* [gevent](http://www.gevent.org) - Coroutine-based concurrency library for Python
* C#
* [NetUV](http://github.com/StormHub/NetUV)
* [LibuvSharp](http://github.com/txdv/LibuvSharp)
* Perl 5
* [UV](https://metacpan.org/pod/UV)
* [Raku](https://raku.org/)
* [MoarVM](https://github.com/MoarVM/MoarVM) [uses](http://6guts.wordpress.com/2013/05/31/moarvm-a-virtual-machine-for-nqp-and-rakudo/) libuv
* PHP
* [php-uv](https://github.com/bwoebi/php-uv)
* Go
* [go-uv](https://github.com/mattn/go-uv)
* OCaml
* [luv](https://github.com/aantron/luv)
* [uwt](https://github.com/fdopen/uwt)
* ooc
* [ooc-uv](https://github.com/nddrylliog/ooc-uv)
* dylan
* [uv-dylan](https://github.com/waywardmonkeys/uv-dylan)
* R
* [httpuv](https://github.com/rstudio/httpuv): HTTP and WebSocket server library for R
* [fs](https://fs.r-lib.org/): Cross-platform file system operations
* Java
* [libuv-java](https://java.net/projects/avatar-js/sources/libuv-java/show): Java bindings
* Nim
* [nimuv](https://github.com/2vg/nimuv): Nim bindings
* Lisp
* [cl-libuv](https://github.com/orthecreedence/cl-libuv) Common Lisp bindings
* [cl-async](https://github.com/orthecreedence/cl-async) Common Lisp async abstraction on top of cl-libuv
* [Céu](http://www.ceu-lang.org)
* [Céu-libuv](https://github.com/fsantanna/ceu-libuv)
* Delphi
* [node.pas](https://github.com/vovach777/node.pas) NodeJS-like ecosystem
* Haskell
* [Z.Haskell](https://z.haskell.world)
* C3
* [libuv.c3l](https://github.com/velikoss/libuv.c3l)

View File

@ -1,22 +1,16 @@
# Project Maintainers # Project Maintainers
libuv is currently managed by the following individuals: libuv is currently managed by the following individuals:
* **Anna Henningsen** ([@addaleax](https://github.com/addaleax))
* **Bartosz Sosnowski** ([@bzoz](https://github.com/bzoz))
* **Ben Noordhuis** ([@bnoordhuis](https://github.com/bnoordhuis)) * **Ben Noordhuis** ([@bnoordhuis](https://github.com/bnoordhuis))
- GPG key: D77B 1E34 243F BAF0 5F8E 9CC3 4F55 C8C8 46AB 89B9 (pubkey-bnoordhuis) - GPG key: D77B 1E34 243F BAF0 5F8E 9CC3 4F55 C8C8 46AB 89B9 (pubkey-bnoordhuis)
* **Bert Belder** ([@piscisaureus](https://github.com/piscisaureus))
* **Colin Ihrig** ([@cjihrig](https://github.com/cjihrig)) * **Colin Ihrig** ([@cjihrig](https://github.com/cjihrig))
- GPG key: 94AE 3667 5C46 4D64 BAFA 68DD 7434 390B DBE9 B9C5 (pubkey-cjihrig) - GPG key: 94AE 3667 5C46 4D64 BAFA 68DD 7434 390B DBE9 B9C5 (pubkey-cjihrig)
- GPG key: 5735 3E0D BDAA A7E8 39B6 6A1A FF47 D5E4 AD8B 4FDC (pubkey-cjihrig-kb) - GPG key: 5735 3E0D BDAA A7E8 39B6 6A1A FF47 D5E4 AD8B 4FDC (pubkey-cjihrig-kb)
* **Fedor Indutny** ([@indutny](https://github.com/indutny))
- GPG key: AF2E EA41 EC34 47BF DD86 FED9 D706 3CCE 19B7 E890 (pubkey-indutny)
* **Imran Iqbal** ([@imran-iq](https://github.com/imran-iq))
- GPG key: 9DFE AA5F 481B BF77 2D90 03CE D592 4925 2F8E C41A (pubkey-iwuzhere)
* **Jameson Nash** ([@vtjnash](https://github.com/vtjnash)) * **Jameson Nash** ([@vtjnash](https://github.com/vtjnash))
* **John Barboza** ([@jbarz](https://github.com/jbarz)) - GPG key: AEAD 0A4B 6867 6775 1A0E 4AEF 34A2 5FB1 2824 6514 (pubkey-vtjnash)
- GPG key: CFBB 9CA9 A5BE AFD7 0E2B 3C5A 79A6 7C55 A367 9C8B (pubkey2022-vtjnash)
* **Jiawen Geng** ([@gengjiawen](https://github.com/gengjiawen))
* **Kaoru Takanashi** ([@erw7](https://github.com/erw7)) * **Kaoru Takanashi** ([@erw7](https://github.com/erw7))
- GPG Key: 5804 F999 8A92 2AFB A398 47A0 7183 5090 6134 887F (pubkey-erw7) - GPG Key: 5804 F999 8A92 2AFB A398 47A0 7183 5090 6134 887F (pubkey-erw7)
* **Richard Lau** ([@richardlau](https://github.com/richardlau)) * **Richard Lau** ([@richardlau](https://github.com/richardlau))
@ -25,6 +19,18 @@ libuv is currently managed by the following individuals:
- GPG key: 612F 0EAD 9401 6223 79DF 4402 F28C 3C8D A33C 03BE (pubkey-santigimeno) - GPG key: 612F 0EAD 9401 6223 79DF 4402 F28C 3C8D A33C 03BE (pubkey-santigimeno)
* **Saúl Ibarra Corretgé** ([@saghul](https://github.com/saghul)) * **Saúl Ibarra Corretgé** ([@saghul](https://github.com/saghul))
- GPG key: FDF5 1936 4458 319F A823 3DC9 410E 5553 AE9B C059 (pubkey-saghul) - GPG key: FDF5 1936 4458 319F A823 3DC9 410E 5553 AE9B C059 (pubkey-saghul)
* **Trevor Norris** ([@trevnorris](https://github.com/trevnorris))
- GPG key: AEFC 279A 0C93 0676 7E58 29A1 251C A676 820D C7F3 (pubkey-trevnorris)
## Project Maintainers emeriti
* **Anna Henningsen** ([@addaleax](https://github.com/addaleax))
* **Bartosz Sosnowski** ([@bzoz](https://github.com/bzoz))
* **Bert Belder** ([@piscisaureus](https://github.com/piscisaureus))
* **Fedor Indutny** ([@indutny](https://github.com/indutny))
- GPG key: AF2E EA41 EC34 47BF DD86 FED9 D706 3CCE 19B7 E890 (pubkey-indutny)
* **Imran Iqbal** ([@imran-iq](https://github.com/imran-iq))
* **John Barboza** ([@jbarz](https://github.com/jbarz))
## Storing a maintainer key in Git ## Storing a maintainer key in Git

View File

@ -27,8 +27,8 @@ uvinclude_HEADERS = include/uv/errno.h \
CLEANFILES = CLEANFILES =
lib_LTLIBRARIES = libuv.la lib_LTLIBRARIES = libuv.la
libuv_la_CFLAGS = @CFLAGS@ libuv_la_CFLAGS = $(AM_CFLAGS)
libuv_la_LDFLAGS = -no-undefined -version-info 1:0:0 libuv_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 1:0:0
libuv_la_SOURCES = src/fs-poll.c \ libuv_la_SOURCES = src/fs-poll.c \
src/heap-inl.h \ src/heap-inl.h \
src/idna.c \ src/idna.c \
@ -38,12 +38,15 @@ libuv_la_SOURCES = src/fs-poll.c \
src/random.c \ src/random.c \
src/strscpy.c \ src/strscpy.c \
src/strscpy.h \ src/strscpy.h \
src/thread-common.c \
src/threadpool.c \ src/threadpool.c \
src/timer.c \ src/timer.c \
src/uv-data-getter-setters.c \ src/uv-data-getter-setters.c \
src/uv-common.c \ src/uv-common.c \
src/uv-common.h \ src/uv-common.h \
src/version.c src/version.c \
src/strtok.c \
src/strtok.h
if SUNOS if SUNOS
# Can't be turned into a CC_CHECK_CFLAGS in configure.ac, it makes compilers # Can't be turned into a CC_CHECK_CFLAGS in configure.ac, it makes compilers
@ -56,7 +59,7 @@ if WINNT
uvinclude_HEADERS += include/uv/win.h include/uv/tree.h uvinclude_HEADERS += include/uv/win.h include/uv/tree.h
AM_CPPFLAGS += -I$(top_srcdir)/src/win \ AM_CPPFLAGS += -I$(top_srcdir)/src/win \
-DWIN32_LEAN_AND_MEAN \ -DWIN32_LEAN_AND_MEAN \
-D_WIN32_WINNT=0x0600 -D_WIN32_WINNT=0x0A00
libuv_la_SOURCES += src/win/async.c \ libuv_la_SOURCES += src/win/async.c \
src/win/atomicops-inl.h \ src/win/atomicops-inl.h \
src/win/core.c \ src/win/core.c \
@ -94,7 +97,6 @@ else # WINNT
uvinclude_HEADERS += include/uv/unix.h uvinclude_HEADERS += include/uv/unix.h
AM_CPPFLAGS += -I$(top_srcdir)/src/unix AM_CPPFLAGS += -I$(top_srcdir)/src/unix
libuv_la_SOURCES += src/unix/async.c \ libuv_la_SOURCES += src/unix/async.c \
src/unix/atomic-ops.h \
src/unix/core.c \ src/unix/core.c \
src/unix/dl.c \ src/unix/dl.c \
src/unix/fs.c \ src/unix/fs.c \
@ -108,7 +110,6 @@ libuv_la_SOURCES += src/unix/async.c \
src/unix/process.c \ src/unix/process.c \
src/unix/random-devurandom.c \ src/unix/random-devurandom.c \
src/unix/signal.c \ src/unix/signal.c \
src/unix/spinlock.h \
src/unix/stream.c \ src/unix/stream.c \
src/unix/tcp.c \ src/unix/tcp.c \
src/unix/thread.c \ src/unix/thread.c \
@ -120,18 +121,26 @@ endif # WINNT
EXTRA_DIST = test/fixtures/empty_file \ EXTRA_DIST = test/fixtures/empty_file \
test/fixtures/load_error.node \ test/fixtures/load_error.node \
test/fixtures/lorem_ipsum.txt \ test/fixtures/lorem_ipsum.txt \
test/fixtures/one_file/one_file \
include \ include \
docs \ docs \
img \ img \
CONTRIBUTING.md \ CONTRIBUTING.md \
LICENSE \ LICENSE \
LICENSE-extra \
README.md README.md
TESTS = test/run-tests TESTS = test/run-tests
check_PROGRAMS = test/run-tests check_PROGRAMS = test/run-tests
test_run_tests_CFLAGS = test_run_tests_CFLAGS = $(AM_CFLAGS)
if WINNT
check-am: test/run-tests_no_ext
test/run-tests_no_ext: test/run-tests$(EXEEXT)
cp test/run-tests$(EXEEXT) test/run-tests_no_ext
endif
if SUNOS if SUNOS
# Can't be turned into a CC_CHECK_CFLAGS in configure.ac, it makes compilers # Can't be turned into a CC_CHECK_CFLAGS in configure.ac, it makes compilers
@ -139,9 +148,8 @@ if SUNOS
test_run_tests_CFLAGS += -pthreads test_run_tests_CFLAGS += -pthreads
endif endif
test_run_tests_LDFLAGS = test_run_tests_LDFLAGS = $(AM_LDFLAGS)
test_run_tests_SOURCES = test/blackhole-server.c \ test_run_tests_SOURCES = test/blackhole-server.c \
test/dns-server.c \
test/echo-server.c \ test/echo-server.c \
test/run-tests.c \ test/run-tests.c \
test/runner.c \ test/runner.c \
@ -151,7 +159,6 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-async.c \ test/test-async.c \
test/test-async-null-cb.c \ test/test-async-null-cb.c \
test/test-barrier.c \ test/test-barrier.c \
test/test-callback-order.c \
test/test-callback-stack.c \ test/test-callback-stack.c \
test/test-close-fd.c \ test/test-close-fd.c \
test/test-close-order.c \ test/test-close-order.c \
@ -191,8 +198,10 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-hrtime.c \ test/test-hrtime.c \
test/test-idle.c \ test/test-idle.c \
test/test-idna.c \ test/test-idna.c \
test/test-iouring-pollhup.c \
test/test-ip4-addr.c \ test/test-ip4-addr.c \
test/test-ip6-addr.c \ test/test-ip6-addr.c \
test/test-ip-name.c \
test/test-ipc-heavy-traffic-deadlock-bug.c \ test/test-ipc-heavy-traffic-deadlock-bug.c \
test/test-ipc-send-recv.c \ test/test-ipc-send-recv.c \
test/test-ipc.c \ test/test-ipc.c \
@ -203,8 +212,11 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-loop-stop.c \ test/test-loop-stop.c \
test/test-loop-time.c \ test/test-loop-time.c \
test/test-loop-configure.c \ test/test-loop-configure.c \
test/test-metrics.c \
test/test-multiple-listen.c \ test/test-multiple-listen.c \
test/test-mutexes.c \ test/test-mutexes.c \
test/test-not-readable-nor-writable-on-read-error.c \
test/test-not-writable-after-shutdown.c \
test/test-osx-select.c \ test/test-osx-select.c \
test/test-pass-always.c \ test/test-pass-always.c \
test/test-ping-pong.c \ test/test-ping-pong.c \
@ -224,18 +236,21 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-poll-close.c \ test/test-poll-close.c \
test/test-poll-close-doesnt-corrupt-stack.c \ test/test-poll-close-doesnt-corrupt-stack.c \
test/test-poll-closesocket.c \ test/test-poll-closesocket.c \
test/test-poll-multiple-handles.c \
test/test-poll-oob.c \ test/test-poll-oob.c \
test/test-process-priority.c \ test/test-process-priority.c \
test/test-process-title.c \ test/test-process-title.c \
test/test-process-title-threadsafe.c \ test/test-process-title-threadsafe.c \
test/test-queue-foreach-delete.c \ test/test-queue-foreach-delete.c \
test/test-random.c \ test/test-random.c \
test/test-readable-on-eof.c \
test/test-ref.c \ test/test-ref.c \
test/test-run-nowait.c \ test/test-run-nowait.c \
test/test-run-once.c \ test/test-run-once.c \
test/test-semaphore.c \ test/test-semaphore.c \
test/test-shutdown-close.c \ test/test-shutdown-close.c \
test/test-shutdown-eof.c \ test/test-shutdown-eof.c \
test/test-shutdown-simultaneous.c \
test/test-shutdown-twice.c \ test/test-shutdown-twice.c \
test/test-signal-multiple-loops.c \ test/test-signal-multiple-loops.c \
test/test-signal-pending-on-close.c \ test/test-signal-pending-on-close.c \
@ -244,11 +259,13 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-spawn.c \ test/test-spawn.c \
test/test-stdio-over-pipes.c \ test/test-stdio-over-pipes.c \
test/test-strscpy.c \ test/test-strscpy.c \
test/test-strtok.c \
test/test-tcp-alloc-cb-fail.c \ test/test-tcp-alloc-cb-fail.c \
test/test-tcp-bind-error.c \ test/test-tcp-bind-error.c \
test/test-tcp-bind6-error.c \ test/test-tcp-bind6-error.c \
test/test-tcp-close-accept.c \ test/test-tcp-close-accept.c \
test/test-tcp-close-while-connecting.c \ test/test-tcp-close-while-connecting.c \
test/test-tcp-close-after-read-timeout.c \
test/test-tcp-close.c \ test/test-tcp-close.c \
test/test-tcp-close-reset.c \ test/test-tcp-close-reset.c \
test/test-tcp-create-socket-early.c \ test/test-tcp-create-socket-early.c \
@ -259,6 +276,9 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-tcp-flags.c \ test/test-tcp-flags.c \
test/test-tcp-open.c \ test/test-tcp-open.c \
test/test-tcp-read-stop.c \ test/test-tcp-read-stop.c \
test/test-tcp-reuseport.c \
test/test-tcp-read-stop-start.c \
test/test-tcp-rst.c \
test/test-tcp-shutdown-after-write.c \ test/test-tcp-shutdown-after-write.c \
test/test-tcp-unexpected-read.c \ test/test-tcp-unexpected-read.c \
test/test-tcp-oob.c \ test/test-tcp-oob.c \
@ -267,10 +287,15 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-tcp-writealot.c \ test/test-tcp-writealot.c \
test/test-tcp-write-fail.c \ test/test-tcp-write-fail.c \
test/test-tcp-try-write.c \ test/test-tcp-try-write.c \
test/test-tcp-write-in-a-row.c \
test/test-tcp-try-write-error.c \ test/test-tcp-try-write-error.c \
test/test-tcp-write-queue-order.c \ test/test-tcp-write-queue-order.c \
test/test-test-macros.c \
test/test-thread-equal.c \ test/test-thread-equal.c \
test/test-thread.c \ test/test-thread.c \
test/test-thread-affinity.c \
test/test-thread-name.c \
test/test-thread-priority.c \
test/test-threadpool-cancel.c \ test/test-threadpool-cancel.c \
test/test-threadpool.c \ test/test-threadpool.c \
test/test-timer-again.c \ test/test-timer-again.c \
@ -283,9 +308,11 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-udp-alloc-cb-fail.c \ test/test-udp-alloc-cb-fail.c \
test/test-udp-bind.c \ test/test-udp-bind.c \
test/test-udp-connect.c \ test/test-udp-connect.c \
test/test-udp-connect6.c \
test/test-udp-create-socket-early.c \ test/test-udp-create-socket-early.c \
test/test-udp-dgram-too-big.c \ test/test-udp-dgram-too-big.c \
test/test-udp-ipv6.c \ test/test-udp-ipv6.c \
test/test-udp-mmsg.c \
test/test-udp-multicast-interface.c \ test/test-udp-multicast-interface.c \
test/test-udp-multicast-interface6.c \ test/test-udp-multicast-interface6.c \
test/test-udp-multicast-join.c \ test/test-udp-multicast-join.c \
@ -296,8 +323,11 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-udp-send-and-recv.c \ test/test-udp-send-and-recv.c \
test/test-udp-send-hang-loop.c \ test/test-udp-send-hang-loop.c \
test/test-udp-send-immediate.c \ test/test-udp-send-immediate.c \
test/test-udp-sendmmsg-error.c \
test/test-udp-send-unreachable.c \ test/test-udp-send-unreachable.c \
test/test-udp-try-send.c \ test/test-udp-try-send.c \
test/test-udp-recv-in-a-row.c \
test/test-udp-reuseport.c \
test/test-uname.c \ test/test-uname.c \
test/test-walk-handles.c \ test/test-walk-handles.c \
test/test-watcher-cross-stop.c test/test-watcher-cross-stop.c
@ -373,21 +403,11 @@ uvinclude_HEADERS += include/uv/posix.h
libuv_la_SOURCES += src/unix/aix-common.c \ libuv_la_SOURCES += src/unix/aix-common.c \
src/unix/ibmi.c \ src/unix/ibmi.c \
src/unix/posix-poll.c \ src/unix/posix-poll.c \
src/unix/no-fsevents.c \ src/unix/no-fsevents.c
src/unix/no-proctitle.c
endif endif
if ANDROID if ANDROID
uvinclude_HEADERS += include/uv/android-ifaddrs.h libuv_la_CFLAGS += -D_GNU_SOURCE
libuv_la_SOURCES += src/unix/android-ifaddrs.c \
src/unix/linux-core.c \
src/unix/linux-inotify.c \
src/unix/linux-syscalls.c \
src/unix/procfs-exepath.c \
src/unix/pthread-fixes.c \
src/unix/random-getrandom.c \
src/unix/random-sysctl-linux.c \
src/unix/sysinfo-loadavg.c
endif endif
if CYGWIN if CYGWIN
@ -409,8 +429,10 @@ uvinclude_HEADERS += include/uv/darwin.h
libuv_la_CFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 libuv_la_CFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
libuv_la_CFLAGS += -D_DARWIN_UNLIMITED_SELECT=1 libuv_la_CFLAGS += -D_DARWIN_UNLIMITED_SELECT=1
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \ libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
src/unix/darwin.c \
src/unix/darwin-proctitle.c \ src/unix/darwin-proctitle.c \
src/unix/darwin-stub.h \
src/unix/darwin-syscalls.h \
src/unix/darwin.c \
src/unix/fsevents.c \ src/unix/fsevents.c \
src/unix/kqueue.c \ src/unix/kqueue.c \
src/unix/proctitle.c \ src/unix/proctitle.c \
@ -452,23 +474,22 @@ endif
if HURD if HURD
uvinclude_HEADERS += include/uv/posix.h uvinclude_HEADERS += include/uv/posix.h
libuv_la_SOURCES += src/unix/no-fsevents.c \ libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
src/unix/no-fsevents.c \
src/unix/no-proctitle.c \
src/unix/posix-hrtime.c \ src/unix/posix-hrtime.c \
src/unix/posix-poll.c src/unix/posix-poll.c \
src/unix/hurd.c
endif endif
if LINUX if LINUX
uvinclude_HEADERS += include/uv/linux.h uvinclude_HEADERS += include/uv/linux.h
libuv_la_CFLAGS += -D_GNU_SOURCE libuv_la_CFLAGS += -D_GNU_SOURCE
libuv_la_SOURCES += src/unix/linux-core.c \ libuv_la_SOURCES += src/unix/linux.c \
src/unix/linux-inotify.c \
src/unix/linux-syscalls.c \
src/unix/linux-syscalls.h \
src/unix/procfs-exepath.c \ src/unix/procfs-exepath.c \
src/unix/proctitle.c \ src/unix/proctitle.c \
src/unix/random-getrandom.c \ src/unix/random-getrandom.c \
src/unix/random-sysctl-linux.c \ src/unix/random-sysctl-linux.c
src/unix/sysinfo-loadavg.c
test_run_tests_LDFLAGS += -lutil test_run_tests_LDFLAGS += -lutil
endif endif
@ -532,8 +553,7 @@ libuv_la_CFLAGS += -D_UNIX03_THREADS \
-qXPLINK \ -qXPLINK \
-qFLOAT=IEEE -qFLOAT=IEEE
libuv_la_LDFLAGS += -qXPLINK libuv_la_LDFLAGS += -qXPLINK
libuv_la_SOURCES += src/unix/pthread-fixes.c \ libuv_la_SOURCES += src/unix/os390.c \
src/unix/os390.c \
src/unix/os390-syscalls.c \ src/unix/os390-syscalls.c \
src/unix/proctitle.c src/unix/proctitle.c
endif endif

View File

@ -5,7 +5,7 @@
libuv is a multi-platform support library with a focus on asynchronous I/O. It libuv is a multi-platform support library with a focus on asynchronous I/O. It
was primarily developed for use by [Node.js][], but it's also was primarily developed for use by [Node.js][], but it's also
used by [Luvit](http://luvit.io/), [Julia](http://julialang.org/), used by [Luvit](http://luvit.io/), [Julia](http://julialang.org/),
[pyuv](https://github.com/saghul/pyuv), and [others](https://github.com/libuv/libuv/wiki/Projects-that-use-libuv). [uvloop](https://github.com/MagicStack/uvloop), and [others](https://github.com/libuv/libuv/blob/v1.x/LINKS.md).
## Feature highlights ## Feature highlights
@ -43,14 +43,16 @@ The ABI/API changes can be tracked [here](http://abi-laboratory.pro/tracker/time
## Licensing ## Licensing
libuv is licensed under the MIT license. Check the [LICENSE file](LICENSE). libuv is licensed under the MIT license. Check the [LICENSE](LICENSE) and
The documentation is licensed under the CC BY 4.0 license. Check the [LICENSE-docs file](LICENSE-docs). [LICENSE-extra](LICENSE-extra) files.
The documentation is licensed under the CC BY 4.0 license. Check the
[LICENSE-docs file](LICENSE-docs).
## Community ## Community
* [Support](https://github.com/libuv/help) * [Support](https://github.com/libuv/libuv/discussions)
* [Mailing list](http://groups.google.com/group/libuv) * [Mailing list](http://groups.google.com/group/libuv)
* [IRC chatroom (#libuv@irc.freenode.org)](http://webchat.freenode.net?channels=libuv&uio=d4)
## Documentation ## Documentation
@ -221,6 +223,27 @@ Make sure that you specify the architecture you wish to build for in the
"ARCHS" flag. You can specify more than one by delimiting with a space "ARCHS" flag. You can specify more than one by delimiting with a space
(e.g. "x86_64 i386"). (e.g. "x86_64 i386").
### Install with vcpkg
```bash
$ git clone https://github.com/microsoft/vcpkg.git
$ ./bootstrap-vcpkg.bat # for powershell
$ ./bootstrap-vcpkg.sh # for bash
$ ./vcpkg install libuv
```
### Install with Conan
You can install pre-built binaries for libuv or build it from source using [Conan](https://conan.io/). Use the following command:
```bash
conan install --requires="libuv/[*]" --build=missing
```
The libuv Conan recipe is kept up to date by Conan maintainers and community contributors.
If the version is out of date, please [create an issue or pull request](https://github.com/conan-io/conan-center-index) on the ConanCenterIndex repository.
### Running tests ### Running tests
Some tests are timing sensitive. Relaxing test timeouts may be necessary Some tests are timing sensitive. Relaxing test timeouts may be necessary
@ -286,6 +309,16 @@ listed in `test/benchmark-list.h`.
Check the [SUPPORTED_PLATFORMS file](SUPPORTED_PLATFORMS.md). Check the [SUPPORTED_PLATFORMS file](SUPPORTED_PLATFORMS.md).
### `-fno-strict-aliasing`
It is recommended to turn on the `-fno-strict-aliasing` compiler flag in
projects that use libuv. The use of ad hoc "inheritance" in the libuv API
may not be safe in the presence of compiler optimizations that depend on
strict aliasing.
MSVC does not have an equivalent flag but it also does not appear to need it
at the time of writing (December 2019.)
### AIX Notes ### AIX Notes
AIX compilation using IBM XL C/C++ requires version 12.1 or greater. AIX compilation using IBM XL C/C++ requires version 12.1 or greater.
@ -298,6 +331,13 @@ describes the package in more detail.
### z/OS Notes ### z/OS Notes
z/OS compilation requires [ZOSLIB](https://github.com/ibmruntimes/zoslib) to be installed. When building with [CMake][], use the flag `-DZOSLIB_DIR` to specify the path to [ZOSLIB](https://github.com/ibmruntimes/zoslib):
```bash
$ (cd build && cmake .. -DBUILD_TESTING=ON -DZOSLIB_DIR=/path/to/zoslib)
$ cmake --build build
```
z/OS creates System V semaphores and message queues. These persist on the system z/OS creates System V semaphores and message queues. These persist on the system
after the process terminates unless the event loop is closed. after the process terminates unless the event loop is closed.

27
SECURITY.md Normal file
View File

@ -0,0 +1,27 @@
# Security Policy
## Supported Versions
Currently, we are providing security updates for the latest release in the v1.x series:
| Version | Supported |
| ------- | ------------------ |
| Latest v1.x | :white_check_mark: |
## Reporting a Vulnerability
If you believe you have found a security vulnerability in `libuv`, please use the [GitHub's private vulnerability reporting feature](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) in the [libuv repository](https://github.com/libuv/libuv) to report it to us.
This will allow us to assess the risk, and make a fix available before we add a bug report to the GitHub repository.
Please do:
* Provide as much information as you can about the vulnerability.
* Provide details about your configuration and environment, if applicable.
Please do not:
* Post any information about the vulnerability in public places.
* Attempt to exploit the vulnerability yourself.
We take all security bugs seriously. Thank you for improving the security of `libuv`. We appreciate your efforts and responsible disclosure and will make every effort to acknowledge your contributions.

View File

@ -2,17 +2,16 @@
| System | Support type | Supported versions | Notes | | System | Support type | Supported versions | Notes |
|---|---|---|---| |---|---|---|---|
| GNU/Linux | Tier 1 | Linux >= 2.6.32 with glibc >= 2.12 | | | GNU/Linux | Tier 1 | Linux >= 3.10 with glibc >= 2.17 | |
| macOS | Tier 1 | macOS >= 10.7 | | | macOS | Tier 1 | macOS >= 11 | Currently supported macOS releases |
| Windows | Tier 1 | >= Windows 7 | MSVC 2008 and later are supported | | Windows | Tier 1 | >= Windows 10 | VS 2015 and later are supported |
| FreeBSD | Tier 1 | >= 10 | | | FreeBSD | Tier 2 | >= 12 | |
| AIX | Tier 2 | >= 6 | Maintainers: @libuv/aix | | AIX | Tier 2 | >= 6 | Maintainers: @libuv/aix |
| IBM i | Tier 2 | >= IBM i 7.2 | Maintainers: @libuv/ibmi |
| z/OS | Tier 2 | >= V2R2 | Maintainers: @libuv/zos | | z/OS | Tier 2 | >= V2R2 | Maintainers: @libuv/zos |
| Linux with musl | Tier 2 | musl >= 1.0 | | | Linux with musl | Tier 2 | musl >= 1.0 | |
| SmartOS | Tier 2 | >= 14.4 | Maintainers: @libuv/smartos | | Android | Tier 3 | NDK >= r15b | Android 7.0, `-DANDROID_PLATFORM=android-24` |
| Android | Tier 3 | NDK >= r15b | | | MinGW | Tier 3 | MinGW-w64 | |
| IBM i | Tier 3 | >= IBM i 7.2 | Maintainers: @libuv/ibmi |
| MinGW | Tier 3 | MinGW32 and MinGW-w64 | |
| SunOS | Tier 3 | Solaris 121 and later | | | SunOS | Tier 3 | Solaris 121 and later | |
| Other | Tier 3 | N/A | | | Other | Tier 3 | N/A | |

View File

@ -14,9 +14,16 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
set -eu
cd `dirname "$0"` cd `dirname "$0"`
if [ "$LIBTOOLIZE" = "" ] && [ "`uname`" = "Darwin" ]; then if [ "${1:-dev}" = "release" ]; then
export LIBUV_RELEASE=true
else
export LIBUV_RELEASE=false
fi
if [ "${LIBTOOLIZE:-}" = "" ] && [ "`uname`" = "Darwin" ]; then
LIBTOOLIZE=glibtoolize LIBTOOLIZE=glibtoolize
fi fi
@ -25,9 +32,17 @@ AUTOCONF=${AUTOCONF:-autoconf}
AUTOMAKE=${AUTOMAKE:-automake} AUTOMAKE=${AUTOMAKE:-automake}
LIBTOOLIZE=${LIBTOOLIZE:-libtoolize} LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}
aclocal_version=`"$ACLOCAL" --version | head -n 1 | sed 's/[^.0-9]//g'`
autoconf_version=`"$AUTOCONF" --version | head -n 1 | sed 's/[^.0-9]//g'`
automake_version=`"$AUTOMAKE" --version | head -n 1 | sed 's/[^.0-9]//g'` automake_version=`"$AUTOMAKE" --version | head -n 1 | sed 's/[^.0-9]//g'`
automake_version_major=`echo "$automake_version" | cut -d. -f1` automake_version_major=`echo "$automake_version" | cut -d. -f1`
automake_version_minor=`echo "$automake_version" | cut -d. -f2` automake_version_minor=`echo "$automake_version" | cut -d. -f2`
libtoolize_version=`"$LIBTOOLIZE" --version | head -n 1 | sed 's/[^.0-9]//g'`
if [ $aclocal_version != $automake_version ]; then
echo "FATAL: aclocal version appears not to be from the same as automake"
exit 1
fi
UV_EXTRA_AUTOMAKE_FLAGS= UV_EXTRA_AUTOMAKE_FLAGS=
if test "$automake_version_major" -gt 1 || \ if test "$automake_version_major" -gt 1 || \
@ -39,8 +54,22 @@ fi
echo "m4_define([UV_EXTRA_AUTOMAKE_FLAGS], [$UV_EXTRA_AUTOMAKE_FLAGS])" \ echo "m4_define([UV_EXTRA_AUTOMAKE_FLAGS], [$UV_EXTRA_AUTOMAKE_FLAGS])" \
> m4/libuv-extra-automake-flags.m4 > m4/libuv-extra-automake-flags.m4
set -ex (set -x
"$LIBTOOLIZE" --copy "$LIBTOOLIZE" --copy --force
"$ACLOCAL" -I m4 "$ACLOCAL" -I m4
)
if $LIBUV_RELEASE; then
"$AUTOCONF" -o /dev/null m4/libuv-check-versions.m4
echo "
AC_PREREQ($autoconf_version)
AC_INIT([libuv-release-check], [0.0])
AM_INIT_AUTOMAKE([$automake_version])
LT_PREREQ($libtoolize_version)
AC_OUTPUT
" > m4/libuv-check-versions.m4
fi
(
set -x
"$AUTOCONF" "$AUTOCONF"
"$AUTOMAKE" --add-missing --copy "$AUTOMAKE" --add-missing --copy
)

View File

@ -0,0 +1,17 @@
if(NOT HOST_ARCH)
message(SEND_ERROR "-DHOST_ARCH required to be specified")
endif()
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
HOST_ARCH
)
SET(CMAKE_SYSTEM_NAME Windows)
set(COMPILER_PREFIX "${HOST_ARCH}-w64-mingw32")
find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres)
find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc)
find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@ -13,18 +13,25 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT([libuv], [1.36.0], [https://github.com/libuv/libuv/issues]) AC_INIT([libuv], [1.50.1-dev], [https://github.com/libuv/libuv/issues])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/libuv-extra-automake-flags.m4])
m4_include([m4/as_case.m4]) m4_include([m4/as_case.m4])
m4_include([m4/libuv-check-flags.m4]) m4_include([m4/libuv-check-flags.m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects] UV_EXTRA_AUTOMAKE_FLAGS) AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects] UV_EXTRA_AUTOMAKE_FLAGS)
AM_MAINTAINER_MODE([enable]) # pass --disable-maintainer-mode if autotools may be unavailable
AC_CANONICAL_HOST AC_CANONICAL_HOST
AC_ENABLE_SHARED AC_ENABLE_SHARED
AC_ENABLE_STATIC AC_ENABLE_STATIC
AC_PROG_CC AC_PROG_CC
AM_PROG_CC_C_O AM_PROG_CC_C_O
CC_FLAG_VISIBILITY #[-fvisibility=hidden]
CC_ATTRIBUTE_VISIBILITY([default], [
CC_FLAG_VISIBILITY([CFLAGS="${CFLAGS} -fvisibility=hidden"])
])
# Xlc has a flag "-f<filename>". Need to use CC_CHECK_FLAG_SUPPORTED_APPEND so
# we exclude -fno-strict-aliasing for xlc
CC_CHECK_FLAG_SUPPORTED_APPEND([-fno-strict-aliasing])
CC_CHECK_CFLAGS_APPEND([-g]) CC_CHECK_CFLAGS_APPEND([-g])
CC_CHECK_CFLAGS_APPEND([-std=gnu89]) CC_CHECK_CFLAGS_APPEND([-std=gnu89])
CC_CHECK_CFLAGS_APPEND([-Wall]) CC_CHECK_CFLAGS_APPEND([-Wall])
@ -38,22 +45,24 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
LT_INIT LT_INIT
# TODO(bnoordhuis) Check for -pthread vs. -pthreads AX_PTHREAD([
AC_CHECK_LIB([dl], [dlopen]) LIBS="$LIBS $PTHREAD_LIBS"
AC_CHECK_LIB([kstat], [kstat_lookup]) CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
AC_CHECK_LIB([nsl], [gethostbyname]) ])
AC_CHECK_LIB([perfstat], [perfstat_cpu]) AC_SEARCH_LIBS([dlopen], [dl])
AC_CHECK_LIB([pthread], [pthread_mutex_init]) AC_SEARCH_LIBS([kstat_lookup], [kstat])
AC_CHECK_LIB([rt], [clock_gettime]) AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_CHECK_LIB([sendfile], [sendfile]) AC_SEARCH_LIBS([perfstat_cpu], [perfstat])
AC_CHECK_LIB([socket], [socket]) AC_SEARCH_LIBS([clock_gettime], [rt])
AC_SEARCH_LIBS([sendfile], [sendfile])
AC_SEARCH_LIBS([socket], [socket])
AC_SYS_LARGEFILE AC_SYS_LARGEFILE
AM_CONDITIONAL([AIX], [AS_CASE([$host_os],[aix*], [true], [false])]) AM_CONDITIONAL([AIX], [AS_CASE([$host_os],[aix*], [true], [false])])
AM_CONDITIONAL([ANDROID], [AS_CASE([$host_os],[linux-android*],[true], [false])]) AM_CONDITIONAL([ANDROID], [AS_CASE([$host_os],[linux-android*],[true], [false])])
AM_CONDITIONAL([CYGWIN], [AS_CASE([$host_os],[cygwin*], [true], [false])]) AM_CONDITIONAL([CYGWIN], [AS_CASE([$host_os],[cygwin*], [true], [false])])
AM_CONDITIONAL([DARWIN], [AS_CASE([$host_os],[darwin*], [true], [false])]) AM_CONDITIONAL([DARWIN], [AS_CASE([$host_os],[darwin*], [true], [false])])
AM_CONDITIONAL([DRAGONFLY],[AS_CASE([$host_os],[dragonfly*], [true], [false])]) AM_CONDITIONAL([DRAGONFLY],[AS_CASE([$host_os],[dragonfly*], [true], [false])])
AM_CONDITIONAL([FREEBSD], [AS_CASE([$host_os],[*freebsd*], [true], [false])]) AM_CONDITIONAL([FREEBSD], [AS_CASE([$host_os],[freebsd*], [true], [false])])
AM_CONDITIONAL([HAIKU], [AS_CASE([$host_os],[haiku], [true], [false])]) AM_CONDITIONAL([HAIKU], [AS_CASE([$host_os],[haiku], [true], [false])])
AM_CONDITIONAL([HURD], [AS_CASE([$host_os],[gnu*], [true], [false])]) AM_CONDITIONAL([HURD], [AS_CASE([$host_os],[gnu*], [true], [false])])
AM_CONDITIONAL([LINUX], [AS_CASE([$host_os],[linux*], [true], [false])]) AM_CONDITIONAL([LINUX], [AS_CASE([$host_os],[linux*], [true], [false])])
@ -65,12 +74,12 @@ AM_CONDITIONAL([OS400], [AS_CASE([$host_os],[os400], [true], [false])
AM_CONDITIONAL([SUNOS], [AS_CASE([$host_os],[solaris*], [true], [false])]) AM_CONDITIONAL([SUNOS], [AS_CASE([$host_os],[solaris*], [true], [false])])
AM_CONDITIONAL([WINNT], [AS_CASE([$host_os],[mingw*], [true], [false])]) AM_CONDITIONAL([WINNT], [AS_CASE([$host_os],[mingw*], [true], [false])])
AS_CASE([$host_os],[mingw*], [ AS_CASE([$host_os],[mingw*], [
LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32" LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -luserenv -luser32 -ldbghelp -lole32 -lshell32"
])
AS_CASE([$host_os], [solaris2.10], [
CFLAGS="$CFLAGS -DSUNOS_NO_IFADDRS"
]) ])
AS_CASE([$host_os], [netbsd*], [AC_CHECK_LIB([kvm], [kvm_open])]) AS_CASE([$host_os], [netbsd*], [AC_CHECK_LIB([kvm], [kvm_open])])
AS_CASE([$host_os], [kfreebsd*], [
LIBS="$LIBS -lfreebsd-glue"
])
AS_CASE([$host_os], [haiku], [ AS_CASE([$host_os], [haiku], [
LIBS="$LIBS -lnetwork" LIBS="$LIBS -lnetwork"
]) ])
@ -79,4 +88,5 @@ AC_CONFIG_FILES([Makefile libuv.pc])
AC_CONFIG_LINKS([test/fixtures/empty_file:test/fixtures/empty_file]) AC_CONFIG_LINKS([test/fixtures/empty_file:test/fixtures/empty_file])
AC_CONFIG_LINKS([test/fixtures/load_error.node:test/fixtures/load_error.node]) AC_CONFIG_LINKS([test/fixtures/load_error.node:test/fixtures/load_error.node])
AC_CONFIG_LINKS([test/fixtures/lorem_ipsum.txt:test/fixtures/lorem_ipsum.txt]) AC_CONFIG_LINKS([test/fixtures/lorem_ipsum.txt:test/fixtures/lorem_ipsum.txt])
AC_CONFIG_LINKS([test/fixtures/one_file/one_file:test/fixtures/one_file/one_file])
AC_OUTPUT AC_OUTPUT

3
docs/code/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*/*
!*.c
!*.h

51
docs/code/CMakeLists.txt Normal file
View File

@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 3.5)
project(libuv_sample)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory("../../" build)
set(SIMPLE_SAMPLES
cgi
helloworld
dns
detach
default-loop
idle-basic
idle-compute
interfaces
locks
onchange
pipe-echo-server
ref-timer
spawn
tcp-echo-server
thread-create
udp-dhcp
uvcat
uvstop
uvtee
)
IF (NOT WIN32)
list(APPEND SIMPLE_SAMPLES
signal
progress
queue-cancel
queue-work
tty
tty-gravity
)
ENDIF()
foreach (X IN LISTS SIMPLE_SAMPLES)
add_executable(${X} ${X}/main.c)
target_link_libraries(${X} uv_a)
endforeach ()
FIND_PACKAGE(CURL)
IF(CURL_FOUND)
add_executable(uvwget uvwget/main.c)
target_link_libraries(uvwget uv_a ${CURL_LIBRARIES})
ENDIF(CURL_FOUND)

View File

@ -15,8 +15,8 @@ void cleanup_handles(uv_process_t *req, int64_t exit_status, int term_signal) {
} }
void invoke_cgi_script(uv_tcp_t *client) { void invoke_cgi_script(uv_tcp_t *client) {
size_t size = 500; char path[500];
char path[size]; size_t size = sizeof(path);
uv_exepath(path, &size); uv_exepath(path, &size);
strcpy(path + (strlen(path) - strlen("cgi")), "tick"); strcpy(path + (strlen(path) - strlen("cgi")), "tick");

View File

@ -0,0 +1,12 @@
#include <stdio.h>
#include <uv.h>
int main() {
uv_loop_t *loop = uv_default_loop();
printf("Default loop.\n");
uv_run(loop, UV_RUN_DEFAULT);
uv_loop_close(loop);
return 0;
}

View File

@ -69,8 +69,8 @@ int main() {
hints.ai_flags = 0; hints.ai_flags = 0;
uv_getaddrinfo_t resolver; uv_getaddrinfo_t resolver;
fprintf(stderr, "irc.freenode.net is... "); fprintf(stderr, "irc.libera.chat is... ");
int r = uv_getaddrinfo(loop, &resolver, on_resolved, "irc.freenode.net", "6667", &hints); int r = uv_getaddrinfo(loop, &resolver, on_resolved, "irc.libera.chat", "6667", &hints);
if (r) { if (r) {
fprintf(stderr, "getaddrinfo call error %s\n", uv_err_name(r)); fprintf(stderr, "getaddrinfo call error %s\n", uv_err_name(r));

View File

@ -11,17 +11,17 @@ int main() {
printf("Number of interfaces: %d\n", count); printf("Number of interfaces: %d\n", count);
while (i--) { while (i--) {
uv_interface_address_t interface = info[i]; uv_interface_address_t interface_a = info[i];
printf("Name: %s\n", interface.name); printf("Name: %s\n", interface_a.name);
printf("Internal? %s\n", interface.is_internal ? "Yes" : "No"); printf("Internal? %s\n", interface_a.is_internal ? "Yes" : "No");
if (interface.address.address4.sin_family == AF_INET) { if (interface_a.address.address4.sin_family == AF_INET) {
uv_ip4_name(&interface.address.address4, buf, sizeof(buf)); uv_ip4_name(&interface_a.address.address4, buf, sizeof(buf));
printf("IPv4 address: %s\n", buf); printf("IPv4 address: %s\n", buf);
} }
else if (interface.address.address4.sin_family == AF_INET6) { else if (interface_a.address.address4.sin_family == AF_INET6) {
uv_ip6_name(&interface.address.address6, buf, sizeof(buf)); uv_ip6_name(&interface_a.address.address6, buf, sizeof(buf));
printf("IPv6 address: %s\n", buf); printf("IPv6 address: %s\n", buf);
} }

View File

@ -70,7 +70,7 @@ void setup_workers() {
child_worker_count = cpu_count; child_worker_count = cpu_count;
workers = calloc(sizeof(struct child_worker), cpu_count); workers = calloc(cpu_count, sizeof(struct child_worker));
while (cpu_count--) { while (cpu_count--) {
struct child_worker *worker = &workers[cpu_count]; struct child_worker *worker = &workers[cpu_count];
uv_pipe_init(loop, &worker->pipe, 1); uv_pipe_init(loop, &worker->pipe, 1);

View File

@ -1,5 +1,4 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include <uv.h> #include <uv.h>
@ -7,7 +6,7 @@ void hare(void *arg) {
int tracklen = *((int *) arg); int tracklen = *((int *) arg);
while (tracklen) { while (tracklen) {
tracklen--; tracklen--;
sleep(1); uv_sleep(1000);
fprintf(stderr, "Hare ran another step\n"); fprintf(stderr, "Hare ran another step\n");
} }
fprintf(stderr, "Hare done running!\n"); fprintf(stderr, "Hare done running!\n");
@ -18,7 +17,7 @@ void tortoise(void *arg) {
while (tracklen) { while (tracklen) {
tracklen--; tracklen--;
fprintf(stderr, "Tortoise ran another step\n"); fprintf(stderr, "Tortoise ran another step\n");
sleep(3); uv_sleep(3000);
} }
fprintf(stderr, "Tortoise done running!\n"); fprintf(stderr, "Tortoise done running!\n");
} }

View File

@ -5,25 +5,27 @@
uv_loop_t *loop; uv_loop_t *loop;
uv_tty_t tty; uv_tty_t tty;
int main() {
loop = uv_default_loop();
int main() {
uv_write_t req;
uv_buf_t buf;
uv_write_t req1;
uv_buf_t buf1;
loop = uv_default_loop();
uv_tty_init(loop, &tty, STDOUT_FILENO, 0); uv_tty_init(loop, &tty, STDOUT_FILENO, 0);
uv_tty_set_mode(&tty, UV_TTY_MODE_NORMAL); uv_tty_set_mode(&tty, UV_TTY_MODE_NORMAL);
if (uv_guess_handle(1) == UV_TTY) { if (uv_guess_handle(1) == UV_TTY) {
uv_write_t req; buf1.base = "\033[41;37m";
uv_buf_t buf; buf1.len = strlen(buf1.base);
buf.base = "\033[41;37m"; uv_write(&req1, (uv_stream_t*) &tty, &buf1, 1, NULL);
buf.len = strlen(buf.base);
uv_write(&req, (uv_stream_t*) &tty, &buf, 1, NULL);
} }
uv_write_t req;
uv_buf_t buf;
buf.base = "Hello TTY\n"; buf.base = "Hello TTY\n";
buf.len = strlen(buf.base); buf.len = strlen(buf.base);
uv_write(&req, (uv_stream_t*) &tty, &buf, 1, NULL); uv_write(&req, (uv_stream_t*) &tty, &buf, 1, NULL);
uv_tty_reset_mode(); uv_tty_reset_mode();
return uv_run(loop, UV_RUN_DEFAULT); return uv_run(loop, UV_RUN_DEFAULT);
} }

View File

@ -53,7 +53,8 @@ uv_buf_t make_discover_msg() {
// HOPS // HOPS
buffer.base[3] = 0x0; buffer.base[3] = 0x0;
// XID 4 bytes // XID 4 bytes
buffer.base[4] = (unsigned int) random(); if (uv_random(NULL, NULL, &buffer.base[4], 4, 0, NULL))
abort();
// SECS // SECS
buffer.base[8] = 0x0; buffer.base[8] = 0x0;
// FLAGS // FLAGS

View File

@ -1,7 +1,6 @@
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h>
#include <uv.h> #include <uv.h>
void on_read(uv_fs_t *req); void on_read(uv_fs_t *req);

View File

@ -1,6 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>

36
docs/requirements.txt Normal file
View File

@ -0,0 +1,36 @@
# primary
furo==2023.5.20
Sphinx==6.1.3
# dependencies
alabaster==0.7.13
Babel==2.11.0
beautifulsoup4==4.12.2
certifi==2022.12.7
charset-normalizer==3.0.1
colorama==0.4.6
docutils==0.19
idna==3.4
imagesize==1.4.1
importlib-metadata==6.0.0
Jinja2==3.1.2
livereload==2.6.3
MarkupSafe==2.1.2
packaging==23.0
Pygments==2.14.0
pytz==2022.7.1
requests==2.28.2
six==1.16.0
snowballstemmer==2.2.0
soupsieve==2.4.1
sphinx-autobuild==2021.3.14
sphinx-basic-ng==1.0.0b2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
sphinxcontrib.applehelp==1.0.3
tornado==6.3.2
urllib3==1.26.14
zipp==3.11.0

View File

@ -32,4 +32,5 @@ API documentation
dll dll
threading threading
misc misc
metrics

View File

@ -51,7 +51,7 @@ API
loop thread. loop thread.
.. note:: .. note::
:c:func:`uv_async_send` is `async-signal-safe <http://man7.org/linux/man-pages/man7/signal-safety.7.html>`_. :c:func:`uv_async_send` is `async-signal-safe <https://man7.org/linux/man-pages/man7/signal-safety.7.html>`_.
It's safe to call this function from a signal handler. It's safe to call this function from a signal handler.
.. warning:: .. warning::

View File

@ -33,14 +33,22 @@ API
.. c:function:: int uv_check_init(uv_loop_t* loop, uv_check_t* check) .. c:function:: int uv_check_init(uv_loop_t* loop, uv_check_t* check)
Initialize the handle. Initialize the handle. This function always succeeds.
:returns: 0
.. c:function:: int uv_check_start(uv_check_t* check, uv_check_cb cb) .. c:function:: int uv_check_start(uv_check_t* check, uv_check_cb cb)
Start the handle with the given callback. Start the handle with the given callback. This function always succeeds,
except when `cb` is `NULL`.
:returns: 0 on success, or `UV_EINVAL` when `cb == NULL`.
.. c:function:: int uv_check_stop(uv_check_t* check) .. c:function:: int uv_check_stop(uv_check_t* check)
Stop the handle, the callback will no longer be called. Stop the handle, the callback will no longer be called.
This function always succeeds.
:returns: 0
.. seealso:: The :c:type:`uv_handle_t` API functions also apply. .. seealso:: The :c:type:`uv_handle_t` API functions also apply.

View File

@ -118,7 +118,7 @@ pygments_style = 'sphinx'
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
html_theme = 'nature' html_theme = 'furo'
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the

View File

@ -60,16 +60,15 @@ stages of a loop iteration:
:align: center :align: center
#. The loop concept of 'now' is updated. The event loop caches the current time at the start of #. The loop concept of 'now' is initially set.
the event loop tick in order to reduce the number of time-related system calls.
#. Due timers are run if the loop was run with ``UV_RUN_DEFAULT``. All active timers scheduled
for a time before the loop's concept of *now* get their callbacks called.
#. If the loop is *alive* an iteration is started, otherwise the loop will exit immediately. So, #. If the loop is *alive* an iteration is started, otherwise the loop will exit immediately. So,
when is a loop considered to be *alive*? If a loop has active and ref'd handles, active when is a loop considered to be *alive*? If a loop has active and ref'd handles, active
requests or closing handles it's considered to be *alive*. requests or closing handles it's considered to be *alive*.
#. Due timers are run. All active timers scheduled for a time before the loop's concept of *now*
get their callbacks called.
#. Pending callbacks are called. All I/O callbacks are called right after polling for I/O, for the #. Pending callbacks are called. All I/O callbacks are called right after polling for I/O, for the
most part. There are cases, however, in which calling such a callback is deferred for the next most part. There are cases, however, in which calling such a callback is deferred for the next
loop iteration. If the previous iteration deferred any I/O callback it will be run at this point. loop iteration. If the previous iteration deferred any I/O callback it will be run at this point.
@ -101,9 +100,11 @@ stages of a loop iteration:
#. Close callbacks are called. If a handle was closed by calling :c:func:`uv_close` it will #. Close callbacks are called. If a handle was closed by calling :c:func:`uv_close` it will
get the close callback called. get the close callback called.
#. Special case in case the loop was run with ``UV_RUN_ONCE``, as it implies forward progress. #. The loop concept of 'now' is updated.
It's possible that no I/O callbacks were fired after blocking for I/O, but some time has passed
so there might be timers which are due, those timers get their callbacks called. #. Due timers are run. Note that 'now' is not updated again until the next loop iteration.
So if a timer became due while other timers were being processed, it won't be run until
the following event loop iteration.
#. Iteration ends. If the loop was run with ``UV_RUN_NOWAIT`` or ``UV_RUN_ONCE`` modes the #. Iteration ends. If the loop was run with ``UV_RUN_NOWAIT`` or ``UV_RUN_ONCE`` modes the
iteration ends and :c:func:`uv_run` will return. If the loop was run with ``UV_RUN_DEFAULT`` iteration ends and :c:func:`uv_run` will return. If the loop was run with ``UV_RUN_DEFAULT``

View File

@ -251,6 +251,10 @@ Error constants
operation not supported on socket operation not supported on socket
.. c:macro:: UV_EOVERFLOW
value too large for defined data type
.. c:macro:: UV_EPERM .. c:macro:: UV_EPERM
operation not permitted operation not permitted
@ -319,11 +323,30 @@ Error constants
too many links too many links
.. c:macro:: UV_ENOTTY
inappropriate ioctl for device
.. c:macro:: UV_EFTYPE
inappropriate file type or format
.. c:macro:: UV_EILSEQ
illegal byte sequence
.. c:macro:: UV_ESOCKTNOSUPPORT
socket type not supported
.. c:macro:: UV_EUNATCH
protocol driver not attached
API API
--- ---
.. c:function:: UV_ERRNO_MAP(iter_macro) .. c:macro:: UV_ERRNO_MAP(iter_macro)
Macro that expands to a series of invocations of `iter_macro` for Macro that expands to a series of invocations of `iter_macro` for
each of the error constants above. `iter_macro` is invoked with two each of the error constants above. `iter_macro` is invoked with two

View File

@ -12,6 +12,15 @@ otherwise it will be performed asynchronously.
All file operations are run on the threadpool. See :ref:`threadpool` for information All file operations are run on the threadpool. See :ref:`threadpool` for information
on the threadpool size. on the threadpool size.
Starting with libuv v1.45.0, some file operations on Linux are handed off to
`io_uring <https://en.wikipedia.org/wiki/Io_uring>` when possible. Apart from
a (sometimes significant) increase in throughput there should be no change in
observable behavior. Libuv reverts to using its threadpool when the necessary
kernel features are unavailable or unsuitable. Starting with libuv v1.49.0 this
behavior was reverted and Libuv on Linux by default will be using the threadpool
again. In order to enable io_uring the :c:type:`uv_loop_t` instance must be
configured with the :c:type:`UV_LOOP_ENABLE_IO_URING_SQPOLL` option.
.. note:: .. note::
On Windows `uv_fs_*` functions use utf-8 encoding. On Windows `uv_fs_*` functions use utf-8 encoding.
@ -24,7 +33,8 @@ Data types
.. c:type:: uv_timespec_t .. c:type:: uv_timespec_t
Portable equivalent of ``struct timespec``. Y2K38-unsafe data type for storing times with nanosecond resolution.
Will be replaced with :c:type:`uv_timespec64_t` in libuv v2.0.
:: ::
@ -58,7 +68,7 @@ Data types
uv_timespec_t st_birthtim; uv_timespec_t st_birthtim;
} uv_stat_t; } uv_stat_t;
.. c:type:: uv_fs_type .. c:enum:: uv_fs_type
File system request type. File system request type.
@ -122,10 +132,9 @@ Data types
uint64_t f_spare[4]; uint64_t f_spare[4];
} uv_statfs_t; } uv_statfs_t;
.. c:type:: uv_dirent_t .. c:enum:: uv_dirent_type_t
Cross platform (reduced) equivalent of ``struct dirent``. Type of dirent.
Used in :c:func:`uv_fs_scandir_next`.
:: ::
@ -140,6 +149,14 @@ Data types
UV_DIRENT_BLOCK UV_DIRENT_BLOCK
} uv_dirent_type_t; } uv_dirent_type_t;
.. c:type:: uv_dirent_t
Cross platform (reduced) equivalent of ``struct dirent``.
Used in :c:func:`uv_fs_scandir_next`.
::
typedef struct uv_dirent_s { typedef struct uv_dirent_s {
const char* name; const char* name;
uv_dirent_type_t type; uv_dirent_type_t type;
@ -160,6 +177,10 @@ Data types
size_t nentries; size_t nentries;
} uv_dir_t; } uv_dir_t;
.. c:type:: void (*uv_fs_cb)(uv_fs_t* req)
Callback called when a request is completed asynchronously.
Public members Public members
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
@ -218,7 +239,8 @@ API
.. c:function:: int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb) .. c:function:: int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb)
Equivalent to :man:`preadv(2)`. Equivalent to :man:`preadv(2)`. If the `offset` argument is `-1`, then
the current file offset is used and updated.
.. warning:: .. warning::
On Windows, under non-MSVC environments (e.g. when GCC or Clang is used On Windows, under non-MSVC environments (e.g. when GCC or Clang is used
@ -231,7 +253,8 @@ API
.. c:function:: int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb) .. c:function:: int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb)
Equivalent to :man:`pwritev(2)`. Equivalent to :man:`pwritev(2)`. If the `offset` argument is `-1`, then
the current file offset is used and updated.
.. warning:: .. warning::
On Windows, under non-MSVC environments (e.g. when GCC or Clang is used On Windows, under non-MSVC environments (e.g. when GCC or Clang is used
@ -407,6 +430,12 @@ API
Equivalent to :man:`utime(2)`, :man:`futimes(3)` and :man:`lutimes(3)` respectively. Equivalent to :man:`utime(2)`, :man:`futimes(3)` and :man:`lutimes(3)` respectively.
Passing `UV_FS_UTIME_NOW` as the atime or mtime sets the timestamp to the
current time.
Passing `UV_FS_UTIME_OMIT` as the atime or mtime leaves the timestamp
untouched.
.. note:: .. note::
z/OS: `uv_fs_lutime()` is not implemented for z/OS. It can still be called but will return z/OS: `uv_fs_lutime()` is not implemented for z/OS. It can still be called but will return
``UV_ENOSYS``. ``UV_ENOSYS``.
@ -441,7 +470,7 @@ API
.. c:function:: int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) .. c:function:: int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
Equivalent to :man:`realpath(3)` on Unix. Windows uses `GetFinalPathNameByHandle <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlea>`_. Equivalent to :man:`realpath(3)` on Unix. Windows uses `GetFinalPathNameByHandleW <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew>`_.
The resulting string is stored in `req->ptr`. The resulting string is stored in `req->ptr`.
.. warning:: .. warning::
@ -463,10 +492,6 @@ API
The background story and some more details on these issues can be checked The background story and some more details on these issues can be checked
`here <https://github.com/nodejs/node/issues/7726>`_. `here <https://github.com/nodejs/node/issues/7726>`_.
.. note::
This function is not implemented on Windows XP and Windows Server 2003.
On these systems, UV_ENOSYS is returned.
.. versionadded:: 1.8.0 .. versionadded:: 1.8.0
.. c:function:: int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb) .. c:function:: int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb)
@ -492,6 +517,13 @@ API
.. versionadded:: 1.19.0 .. versionadded:: 1.19.0
.. c:function:: int uv_fs_get_system_error(const uv_fs_t* req)
Returns the platform specific error code - `GetLastError()` value on Windows
and `-(req->result)` on other platforms.
.. versionadded:: 1.38.0
.. c:function:: void* uv_fs_get_ptr(const uv_fs_t* req) .. c:function:: void* uv_fs_get_ptr(const uv_fs_t* req)
Returns `req->ptr`. Returns `req->ptr`.
@ -528,8 +560,8 @@ Helper functions
For a OS-dependent handle, get the file descriptor in the C runtime. For a OS-dependent handle, get the file descriptor in the C runtime.
On UNIX, returns the ``os_fd`` intact. On Windows, this calls `_open_osfhandle <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-osfhandle?view=vs-2019>`_. On UNIX, returns the ``os_fd`` intact. On Windows, this calls `_open_osfhandle <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-osfhandle?view=vs-2019>`_.
Note that the return value is still owned by the CRT, Note that this consumes the argument, any attempts to close it or to use it
any attempts to close it or to use it after closing the handle may lead to malfunction. after closing the return value may lead to malfunction.
.. versionadded:: 1.23.0 .. versionadded:: 1.23.0
@ -637,7 +669,7 @@ File open constants
.. note:: .. note::
`UV_FS_O_RANDOM` is only supported on Windows via `UV_FS_O_RANDOM` is only supported on Windows via
`FILE_FLAG_RANDOM_ACCESS <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_. `FILE_FLAG_RANDOM_ACCESS <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew>`_.
.. c:macro:: UV_FS_O_RDONLY .. c:macro:: UV_FS_O_RDONLY
@ -654,7 +686,7 @@ File open constants
.. note:: .. note::
`UV_FS_O_SEQUENTIAL` is only supported on Windows via `UV_FS_O_SEQUENTIAL` is only supported on Windows via
`FILE_FLAG_SEQUENTIAL_SCAN <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_. `FILE_FLAG_SEQUENTIAL_SCAN <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew>`_.
.. c:macro:: UV_FS_O_SHORT_LIVED .. c:macro:: UV_FS_O_SHORT_LIVED
@ -662,7 +694,7 @@ File open constants
.. note:: .. note::
`UV_FS_O_SHORT_LIVED` is only supported on Windows via `UV_FS_O_SHORT_LIVED` is only supported on Windows via
`FILE_ATTRIBUTE_TEMPORARY <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_. `FILE_ATTRIBUTE_TEMPORARY <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew>`_.
.. c:macro:: UV_FS_O_SYMLINK .. c:macro:: UV_FS_O_SYMLINK
@ -683,7 +715,7 @@ File open constants
.. note:: .. note::
`UV_FS_O_TEMPORARY` is only supported on Windows via `UV_FS_O_TEMPORARY` is only supported on Windows via
`FILE_ATTRIBUTE_TEMPORARY <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_. `FILE_ATTRIBUTE_TEMPORARY <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew>`_.
.. c:macro:: UV_FS_O_TRUNC .. c:macro:: UV_FS_O_TRUNC

View File

@ -39,11 +39,20 @@ Data types
.. c:type:: void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename, int events, int status) .. c:type:: void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename, int events, int status)
Callback passed to :c:func:`uv_fs_event_start` which will be called repeatedly Callback passed to :c:func:`uv_fs_event_start` which will be called repeatedly
after the handle is started. If the handle was started with a directory the after the handle is started.
`filename` parameter will be a relative path to a file contained in the directory.
The `events` parameter is an ORed mask of :c:type:`uv_fs_event` elements.
.. c:type:: uv_fs_event If the handle was started with a directory the `filename` parameter will
be a relative path to a file contained in the directory, or `NULL` if the
file name cannot be determined.
The `events` parameter is an ORed mask of :c:enum:`uv_fs_event` elements.
.. note::
For FreeBSD path could sometimes be `NULL` due to a kernel bug.
.. _Reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197695
.. c:enum:: uv_fs_event
Event types that :c:type:`uv_fs_event_t` handles monitor. Event types that :c:type:`uv_fs_event_t` handles monitor.
@ -54,7 +63,7 @@ Data types
UV_CHANGE = 2 UV_CHANGE = 2
}; };
.. c:type:: uv_fs_event_flags .. c:enum:: uv_fs_event_flags
Flags that can be passed to :c:func:`uv_fs_event_start` to control its Flags that can be passed to :c:func:`uv_fs_event_start` to control its
behavior. behavior.
@ -105,10 +114,13 @@ API
.. c:function:: int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, const char* path, unsigned int flags) .. c:function:: int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, const char* path, unsigned int flags)
Start the handle with the given callback, which will watch the specified Start the handle with the given callback, which will watch the specified
`path` for changes. `flags` can be an ORed mask of :c:type:`uv_fs_event_flags`. `path` for changes. `flags` can be an ORed mask of :c:enum:`uv_fs_event_flags`.
.. note:: Currently the only supported flag is ``UV_FS_EVENT_RECURSIVE`` and .. note:: Currently the only supported flag is ``UV_FS_EVENT_RECURSIVE`` and
only on OSX and Windows. only on OSX and Windows.
.. note:: On macOS, events collected by the OS immediately before calling
``uv_fs_event_start`` might be reported to the `uv_fs_event_cb`
callback.
.. c:function:: int uv_fs_event_stop(uv_fs_event_t* handle) .. c:function:: int uv_fs_event_stop(uv_fs_event_t* handle)

View File

@ -42,7 +42,7 @@ as other activities and other I/O operations are kept waiting.
One of the standard solutions is to use threads. Each blocking I/O operation is One of the standard solutions is to use threads. Each blocking I/O operation is
started in a separate thread (or in a thread pool). When the blocking function started in a separate thread (or in a thread pool). When the blocking function
gets invoked in the thread, the processor can schedule another thread to run, gets invoked in the thread, the operating system can schedule another thread to run,
which actually needs the CPU. which actually needs the CPU.
The approach followed by libuv uses another style, which is the **asynchronous, The approach followed by libuv uses another style, which is the **asynchronous,
@ -71,7 +71,7 @@ architecture of libuv and its background. If you have no prior experience with
either libuv or libev, it is a quick, useful watch. either libuv or libev, it is a quick, useful watch.
libuv's event loop is explained in more detail in the `documentation libuv's event loop is explained in more detail in the `documentation
<http://docs.libuv.org/en/v1.x/design.html#the-i-o-loop>`_. <https://docs.libuv.org/en/v1.x/design.html#the-i-o-loop>`_.
.. raw:: html .. raw:: html
@ -87,6 +87,7 @@ nothing, except start a loop which will exit immediately.
.. rubric:: helloworld/main.c .. rubric:: helloworld/main.c
.. literalinclude:: ../../code/helloworld/main.c .. literalinclude:: ../../code/helloworld/main.c
:language: c
:linenos: :linenos:
This program quits immediately because it has no events to process. A libuv This program quits immediately because it has no events to process. A libuv
@ -108,6 +109,11 @@ A default loop is provided by libuv and can be accessed using
``uv_default_loop()``. You should use this loop if you only want a single ``uv_default_loop()``. You should use this loop if you only want a single
loop. loop.
.. rubric:: default-loop/main.c
.. literalinclude:: ../../code/default-loop/main.c
:language: c
:linenos:
.. note:: .. note::
node.js uses the default loop as its main loop. If you are writing bindings node.js uses the default loop as its main loop. If you are writing bindings
@ -120,7 +126,7 @@ Error handling
Initialization functions or synchronous functions which may fail return a negative number on error. Async functions that may fail will pass a status parameter to their callbacks. The error messages are defined as ``UV_E*`` `constants`_. Initialization functions or synchronous functions which may fail return a negative number on error. Async functions that may fail will pass a status parameter to their callbacks. The error messages are defined as ``UV_E*`` `constants`_.
.. _constants: http://docs.libuv.org/en/v1.x/errors.html#error-constants .. _constants: https://docs.libuv.org/en/v1.x/errors.html#error-constants
You can use the ``uv_strerror(int)`` and ``uv_err_name(int)`` functions You can use the ``uv_strerror(int)`` and ``uv_err_name(int)`` functions
to get a ``const char *`` describing the error or the error name respectively. to get a ``const char *`` describing the error or the error name respectively.
@ -168,6 +174,16 @@ handle is used for.
typedef struct uv_udp_send_s uv_udp_send_t; typedef struct uv_udp_send_s uv_udp_send_t;
typedef struct uv_fs_s uv_fs_t; typedef struct uv_fs_s uv_fs_t;
typedef struct uv_work_s uv_work_t; typedef struct uv_work_s uv_work_t;
typedef struct uv_random_s uv_random_t;
/* None of the above. */
typedef struct uv_env_item_s uv_env_item_t;
typedef struct uv_cpu_info_s uv_cpu_info_t;
typedef struct uv_interface_address_s uv_interface_address_t;
typedef struct uv_dirent_s uv_dirent_t;
typedef struct uv_passwd_s uv_passwd_t;
typedef struct uv_utsname_s uv_utsname_t;
typedef struct uv_statfs_s uv_statfs_t;
Handles represent long-lived objects. Async operations on such handles are Handles represent long-lived objects. Async operations on such handles are
@ -202,6 +218,7 @@ event watchers are active.
.. rubric:: idle-basic/main.c .. rubric:: idle-basic/main.c
.. literalinclude:: ../../code/idle-basic/main.c .. literalinclude:: ../../code/idle-basic/main.c
:language: c
:emphasize-lines: 6,10,14-17 :emphasize-lines: 6,10,14-17
Storing context Storing context

View File

@ -20,6 +20,7 @@ these things can be a bit difficult to understand, so let's look at
.. rubric:: src/unix/core.c - uv_run .. rubric:: src/unix/core.c - uv_run
.. literalinclude:: ../../../src/unix/core.c .. literalinclude:: ../../../src/unix/core.c
:language: c
:linenos: :linenos:
:lines: 304-324 :lines: 304-324
:emphasize-lines: 10,19,21 :emphasize-lines: 10,19,21
@ -43,6 +44,7 @@ iteration of the loop still takes places.
.. rubric:: uvstop/main.c .. rubric:: uvstop/main.c
.. literalinclude:: ../../code/uvstop/main.c .. literalinclude:: ../../code/uvstop/main.c
:language: c
:linenos: :linenos:
:emphasize-lines: 11 :emphasize-lines: 11

View File

@ -13,7 +13,7 @@ Simple filesystem read/write is achieved using the ``uv_fs_*`` functions and the
watchers registered with the event loop when application interaction is watchers registered with the event loop when application interaction is
required. required.
.. _thread pool: http://docs.libuv.org/en/v1.x/threadpool.html#thread-pool-work-scheduling .. _thread pool: https://docs.libuv.org/en/v1.x/threadpool.html#thread-pool-work-scheduling
All filesystem functions have two forms - *synchronous* and *asynchronous*. All filesystem functions have two forms - *synchronous* and *asynchronous*.
@ -33,7 +33,7 @@ A file descriptor is obtained using
int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, int mode, uv_fs_cb cb) int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, int mode, uv_fs_cb cb)
``flags`` and ``mode`` are standard ``flags`` and ``mode`` are standard
`Unix flags <http://man7.org/linux/man-pages/man2/open.2.html>`_. `Unix flags <https://man7.org/linux/man-pages/man2/open.2.html>`_.
libuv takes care of converting to the appropriate Windows flags. libuv takes care of converting to the appropriate Windows flags.
File descriptors are closed using File descriptors are closed using
@ -54,6 +54,7 @@ a callback for when the file is opened:
.. rubric:: uvcat/main.c - opening a file .. rubric:: uvcat/main.c - opening a file
.. literalinclude:: ../../code/uvcat/main.c .. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos: :linenos:
:lines: 41-53 :lines: 41-53
:emphasize-lines: 4, 6-7 :emphasize-lines: 4, 6-7
@ -63,8 +64,9 @@ The ``result`` field of a ``uv_fs_t`` is the file descriptor in case of the
.. rubric:: uvcat/main.c - read callback .. rubric:: uvcat/main.c - read callback
.. literalinclude:: ../../code/uvcat/main.c .. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos: :linenos:
:lines: 26-40 :lines: 26-39
:emphasize-lines: 2,8,12 :emphasize-lines: 2,8,12
In the case of a read call, you should pass an *initialized* buffer which will In the case of a read call, you should pass an *initialized* buffer which will
@ -87,8 +89,9 @@ callbacks.
.. rubric:: uvcat/main.c - write callback .. rubric:: uvcat/main.c - write callback
.. literalinclude:: ../../code/uvcat/main.c .. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos: :linenos:
:lines: 16-24 :lines: 17-24
:emphasize-lines: 6 :emphasize-lines: 6
.. warning:: .. warning::
@ -100,6 +103,7 @@ We set the dominos rolling in ``main()``:
.. rubric:: uvcat/main.c .. rubric:: uvcat/main.c
.. literalinclude:: ../../code/uvcat/main.c .. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos: :linenos:
:lines: 55- :lines: 55-
:emphasize-lines: 2 :emphasize-lines: 2
@ -128,6 +132,7 @@ same patterns as the read/write/open calls, returning the result in the
int uv_fs_copyfile(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, int flags, uv_fs_cb cb); int uv_fs_copyfile(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, int flags, uv_fs_cb cb);
int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb); int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb);
int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb); int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb);
int uv_fs_mkstemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb);
int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb); int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_cb cb); int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_cb cb);
int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent); int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent);
@ -145,6 +150,7 @@ same patterns as the read/write/open calls, returning the result in the
int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb); int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb);
int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb); int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb);
int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb); int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb);
int uv_fs_lutime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb);
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb); int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb); int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb);
int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, int flags, uv_fs_cb cb); int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, int flags, uv_fs_cb cb);
@ -154,6 +160,7 @@ same patterns as the read/write/open calls, returning the result in the
int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb); int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb);
int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb); int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb);
int uv_fs_lchown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb); int uv_fs_lchown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb);
int uv_fs_statfs(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
.. _buffers-and-streams: .. _buffers-and-streams:
@ -186,7 +193,7 @@ and freed by the application.
.. ERROR:: .. ERROR::
THIS PROGRAM DOES NOT ALWAYS WORK, NEED SOMETHING BETTER** **THIS PROGRAM DOES NOT ALWAYS WORK, NEED SOMETHING BETTER**
To demonstrate streams we will need to use ``uv_pipe_t``. This allows streaming To demonstrate streams we will need to use ``uv_pipe_t``. This allows streaming
local files [#]_. Here is a simple tee utility using libuv. Doing all operations local files [#]_. Here is a simple tee utility using libuv. Doing all operations
@ -203,8 +210,9 @@ opened as bidirectional by default.
.. rubric:: uvtee/main.c - read on pipes .. rubric:: uvtee/main.c - read on pipes
.. literalinclude:: ../../code/uvtee/main.c .. literalinclude:: ../../code/uvtee/main.c
:language: c
:linenos: :linenos:
:lines: 61-80 :lines: 62-80
:emphasize-lines: 4,5,15 :emphasize-lines: 4,5,15
The third argument of ``uv_pipe_init()`` should be set to 1 for IPC using named The third argument of ``uv_pipe_init()`` should be set to 1 for IPC using named
@ -218,6 +226,7 @@ these buffers.
.. rubric:: uvtee/main.c - reading buffers .. rubric:: uvtee/main.c - reading buffers
.. literalinclude:: ../../code/uvtee/main.c .. literalinclude:: ../../code/uvtee/main.c
:language: c
:linenos: :linenos:
:lines: 19-22,44-60 :lines: 19-22,44-60
@ -242,6 +251,7 @@ point there is nothing to be read. Most applications will just ignore this.
.. rubric:: uvtee/main.c - Write to pipe .. rubric:: uvtee/main.c - Write to pipe
.. literalinclude:: ../../code/uvtee/main.c .. literalinclude:: ../../code/uvtee/main.c
:language: c
:linenos: :linenos:
:lines: 9-13,23-42 :lines: 9-13,23-42
@ -278,10 +288,18 @@ a command whenever any of the watched files change::
./onchange <command> <file1> [file2] ... ./onchange <command> <file1> [file2] ...
.. note::
Currently this example only works on OSX and Windows.
Refer to the `notes of uv_fs_event_start`_ function.
.. _notes of uv_fs_event_start: https://docs.libuv.org/en/v1.x/fs_event.html#c.uv_fs_event_start
The file change notification is started using ``uv_fs_event_init()``: The file change notification is started using ``uv_fs_event_init()``:
.. rubric:: onchange/main.c - The setup .. rubric:: onchange/main.c - The setup
.. literalinclude:: ../../code/onchange/main.c .. literalinclude:: ../../code/onchange/main.c
:language: c
:linenos: :linenos:
:lines: 26- :lines: 26-
:emphasize-lines: 15 :emphasize-lines: 15
@ -311,15 +329,16 @@ The callback will receive the following arguments:
#. ``const char *filename`` - If a directory is being monitored, this is the #. ``const char *filename`` - If a directory is being monitored, this is the
file which was changed. Only non-``null`` on Linux and Windows. May be ``null`` file which was changed. Only non-``null`` on Linux and Windows. May be ``null``
even on those platforms. even on those platforms.
#. ``int flags`` - one of ``UV_RENAME`` or ``UV_CHANGE``, or a bitwise OR of #. ``int events`` - one of ``UV_RENAME`` or ``UV_CHANGE``, or a bitwise OR of
both. both.
#. ``int status`` - Currently 0. #. ``int status`` - If ``status < 0``, there is an :ref:`libuv error<libuv-error-handling>`.
In our example we simply print the arguments and run the command using In our example we simply print the arguments and run the command using
``system()``. ``system()``.
.. rubric:: onchange/main.c - file change notification callback .. rubric:: onchange/main.c - file change notification callback
.. literalinclude:: ../../code/onchange/main.c .. literalinclude:: ../../code/onchange/main.c
:language: c
:linenos: :linenos:
:lines: 9-24 :lines: 9-24

View File

@ -8,7 +8,7 @@ It is meant to cover the main areas of libuv, but is not a comprehensive
reference discussing every function and data structure. The `official libuv reference discussing every function and data structure. The `official libuv
documentation`_ may be consulted for full details. documentation`_ may be consulted for full details.
.. _official libuv documentation: http://docs.libuv.org/en/v1.x/ .. _official libuv documentation: https://docs.libuv.org/en/v1.x/
This book is still a work in progress, so sections may be incomplete, but This book is still a work in progress, so sections may be incomplete, but
I hope you will enjoy it as it grows. I hope you will enjoy it as it grows.
@ -47,29 +47,27 @@ Since then libuv has continued to mature and become a high quality standalone
library for system programming. Users outside of node.js include Mozilla's library for system programming. Users outside of node.js include Mozilla's
Rust_ programming language, and a variety_ of language bindings. Rust_ programming language, and a variety_ of language bindings.
This book and the code is based on libuv version `v1.3.0`_. This book and the code is based on libuv version `v1.42.0`_.
Code Code
---- ----
All the code from this book is included as part of the source of the book on All the example code and the source of the book is included as part of
Github. `Clone`_/`Download`_ the book, then build libuv:: the libuv_ project on GitHub.
Clone or Download libuv_, then build it::
cd libuv sh autogen.sh
./autogen.sh
./configure ./configure
make make
There is no need to ``make install``. To build the examples run ``make`` in the There is no need to ``make install``. To build the examples run ``make`` in the
``code/`` directory. ``docs/code/`` directory.
.. _Clone: https://github.com/nikhilm/uvbook .. _v1.42.0: https://github.com/libuv/libuv/releases/tag/v1.42.0
.. _Download: https://github.com/nikhilm/uvbook/downloads
.. _v1.3.0: https://github.com/libuv/libuv/tags
.. _V8: https://v8.dev .. _V8: https://v8.dev
.. _libev: http://software.schmorp.de/pkg/libev.html .. _libev: http://software.schmorp.de/pkg/libev.html
.. _libuv: https://github.com/libuv/libuv .. _libuv: https://github.com/libuv/libuv
.. _node.js: https://www.nodejs.org .. _node.js: https://www.nodejs.org
.. _libev was removed: https://github.com/joyent/libuv/issues/485 .. _libev was removed: https://github.com/joyent/libuv/issues/485
.. _Rust: https://www.rust-lang.org .. _Rust: https://www.rust-lang.org
.. _variety: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv .. _variety: https://github.com/libuv/libuv/blob/v1.x/LINKS.md

View File

@ -38,6 +38,7 @@ Here is a simple echo server
.. rubric:: tcp-echo-server/main.c - The listen socket .. rubric:: tcp-echo-server/main.c - The listen socket
.. literalinclude:: ../../code/tcp-echo-server/main.c .. literalinclude:: ../../code/tcp-echo-server/main.c
:language: c
:linenos: :linenos:
:lines: 68- :lines: 68-
:emphasize-lines: 4-5,7-10 :emphasize-lines: 4-5,7-10
@ -60,6 +61,7 @@ In this case we also establish interest in reading from this stream.
.. rubric:: tcp-echo-server/main.c - Accepting the client .. rubric:: tcp-echo-server/main.c - Accepting the client
.. literalinclude:: ../../code/tcp-echo-server/main.c .. literalinclude:: ../../code/tcp-echo-server/main.c
:language: c
:linenos: :linenos:
:lines: 51-66 :lines: 51-66
:emphasize-lines: 9-10 :emphasize-lines: 9-10
@ -108,6 +110,7 @@ address from a `DHCP`_ server -- DHCP Discover.
.. rubric:: udp-dhcp/main.c - Setup and send UDP packets .. rubric:: udp-dhcp/main.c - Setup and send UDP packets
.. literalinclude:: ../../code/udp-dhcp/main.c .. literalinclude:: ../../code/udp-dhcp/main.c
:language: c
:linenos: :linenos:
:lines: 7-11,104- :lines: 7-11,104-
:emphasize-lines: 8,10-11,17-18,21 :emphasize-lines: 8,10-11,17-18,21
@ -143,6 +146,7 @@ the OS will discard the data that could not fit* (That's UDP for you!).
.. rubric:: udp-dhcp/main.c - Reading packets .. rubric:: udp-dhcp/main.c - Reading packets
.. literalinclude:: ../../code/udp-dhcp/main.c .. literalinclude:: ../../code/udp-dhcp/main.c
:language: c
:linenos: :linenos:
:lines: 17-40 :lines: 17-40
:emphasize-lines: 1,23 :emphasize-lines: 1,23
@ -160,7 +164,7 @@ IPv6 stack only
IPv6 sockets can be used for both IPv4 and IPv6 communication. If you want to IPv6 sockets can be used for both IPv4 and IPv6 communication. If you want to
restrict the socket to IPv6 only, pass the ``UV_UDP_IPV6ONLY`` flag to restrict the socket to IPv6 only, pass the ``UV_UDP_IPV6ONLY`` flag to
``uv_udp_bind`` [#]_. ``uv_udp_bind``.
Multicast Multicast
~~~~~~~~~ ~~~~~~~~~
@ -189,10 +193,11 @@ Querying DNS
libuv provides asynchronous DNS resolution. For this it provides its own libuv provides asynchronous DNS resolution. For this it provides its own
``getaddrinfo`` replacement [#]_. In the callback you can ``getaddrinfo`` replacement [#]_. In the callback you can
perform normal socket operations on the retrieved addresses. Let's connect to perform normal socket operations on the retrieved addresses. Let's connect to
Freenode to see an example of DNS resolution. Libera.chat to see an example of DNS resolution.
.. rubric:: dns/main.c .. rubric:: dns/main.c
.. literalinclude:: ../../code/dns/main.c .. literalinclude:: ../../code/dns/main.c
:language: c
:linenos: :linenos:
:lines: 61- :lines: 61-
:emphasize-lines: 12 :emphasize-lines: 12
@ -200,7 +205,7 @@ Freenode to see an example of DNS resolution.
If ``uv_getaddrinfo`` returns non-zero, something went wrong in the setup and If ``uv_getaddrinfo`` returns non-zero, something went wrong in the setup and
your callback won't be invoked at all. All arguments can be freed immediately your callback won't be invoked at all. All arguments can be freed immediately
after ``uv_getaddrinfo`` returns. The `hostname`, `servname` and `hints` after ``uv_getaddrinfo`` returns. The `hostname`, `servname` and `hints`
structures are documented in `the getaddrinfo man page <getaddrinfo>`_. The structures are documented in `the getaddrinfo man page <getaddrinfo_>`_. The
callback can be ``NULL`` in which case the function will run synchronously. callback can be ``NULL`` in which case the function will run synchronously.
In the resolver callback, you can pick any IP from the linked list of ``struct In the resolver callback, you can pick any IP from the linked list of ``struct
@ -209,6 +214,7 @@ call ``uv_freeaddrinfo`` in the callback.
.. rubric:: dns/main.c .. rubric:: dns/main.c
.. literalinclude:: ../../code/dns/main.c .. literalinclude:: ../../code/dns/main.c
:language: c
:linenos: :linenos:
:lines: 42-60 :lines: 42-60
:emphasize-lines: 8,16 :emphasize-lines: 8,16
@ -227,6 +233,7 @@ useful to allow your service to bind to IP addresses when it starts.
.. rubric:: interfaces/main.c .. rubric:: interfaces/main.c
.. literalinclude:: ../../code/interfaces/main.c .. literalinclude:: ../../code/interfaces/main.c
:language: c
:linenos: :linenos:
:emphasize-lines: 9,17 :emphasize-lines: 9,17
@ -235,7 +242,7 @@ interface has multiple IPv4/IPv6 addresses, the name will be reported multiple
times, with each address being reported once. times, with each address being reported once.
.. _c-ares: https://c-ares.haxx.se .. _c-ares: https://c-ares.haxx.se
.. _getaddrinfo: https://www.kernel.org/doc/man-pages/online/pages/man3/getaddrinfo.3.html .. _getaddrinfo: https://man7.org/linux/man-pages/man3/getaddrinfo.3.html
.. _User Datagram Protocol: https://en.wikipedia.org/wiki/User_Datagram_Protocol .. _User Datagram Protocol: https://en.wikipedia.org/wiki/User_Datagram_Protocol
.. _DHCP: https://tools.ietf.org/html/rfc2131 .. _DHCP: https://tools.ietf.org/html/rfc2131
@ -243,7 +250,6 @@ times, with each address being reported once.
---- ----
.. [#] https://beej.us/guide/bgnet/html/#broadcast-packetshello-world .. [#] https://beej.us/guide/bgnet/html/#broadcast-packetshello-world
.. [#] on Windows only supported on Windows Vista and later.
.. [#] https://www.tldp.org/HOWTO/Multicast-HOWTO-6.html#ss6.1 .. [#] https://www.tldp.org/HOWTO/Multicast-HOWTO-6.html#ss6.1
.. [#] libuv use the system ``getaddrinfo`` in the libuv threadpool. libuv .. [#] libuv use the system ``getaddrinfo`` in the libuv threadpool. libuv
v0.8.0 and earlier also included c-ares_ as an alternative, but this has been v0.8.0 and earlier also included c-ares_ as an alternative, but this has been

View File

@ -27,6 +27,7 @@ exits. This is achieved using ``uv_spawn``.
.. rubric:: spawn/main.c .. rubric:: spawn/main.c
.. literalinclude:: ../../code/spawn/main.c .. literalinclude:: ../../code/spawn/main.c
:language: c
:linenos: :linenos:
:lines: 6-8,15- :lines: 6-8,15-
:emphasize-lines: 11,13-17 :emphasize-lines: 11,13-17
@ -52,8 +53,11 @@ ID of the child process.
The exit callback will be invoked with the *exit status* and the type of *signal* The exit callback will be invoked with the *exit status* and the type of *signal*
which caused the exit. which caused the exit.
Note that it is important **not** to call ``uv_close`` before the exit callback.
.. rubric:: spawn/main.c .. rubric:: spawn/main.c
.. literalinclude:: ../../code/spawn/main.c .. literalinclude:: ../../code/spawn/main.c
:language: c
:linenos: :linenos:
:lines: 9-12 :lines: 9-12
:emphasize-lines: 3 :emphasize-lines: 3
@ -104,6 +108,7 @@ does not affect it.
.. rubric:: detach/main.c .. rubric:: detach/main.c
.. literalinclude:: ../../code/detach/main.c .. literalinclude:: ../../code/detach/main.c
:language: c
:linenos: :linenos:
:lines: 9-30 :lines: 9-30
:emphasize-lines: 12,19 :emphasize-lines: 12,19
@ -123,7 +128,8 @@ of ``uv_kill`` is::
For processes started using libuv, you may use ``uv_process_kill`` instead, For processes started using libuv, you may use ``uv_process_kill`` instead,
which accepts the ``uv_process_t`` watcher as the first argument, rather than which accepts the ``uv_process_t`` watcher as the first argument, rather than
the pid. In this case, **remember to call** ``uv_close`` on the watcher. the pid. In this case, **remember to call** ``uv_close`` on the watcher _after_
the exit callback has been called.
Signals Signals
------- -------
@ -140,6 +146,7 @@ stop watching. Here is a small example demonstrating the various possibilities:
.. rubric:: signal/main.c .. rubric:: signal/main.c
.. literalinclude:: ../../code/signal/main.c .. literalinclude:: ../../code/signal/main.c
:language: c
:linenos: :linenos:
:emphasize-lines: 17-18,27-28 :emphasize-lines: 17-18,27-28
@ -172,6 +179,7 @@ which is:
.. rubric:: proc-streams/test.c .. rubric:: proc-streams/test.c
.. literalinclude:: ../../code/proc-streams/test.c .. literalinclude:: ../../code/proc-streams/test.c
:language: c
The actual program ``proc-streams`` runs this while sharing only ``stderr``. The actual program ``proc-streams`` runs this while sharing only ``stderr``.
The file descriptors of the child process are set using the ``stdio`` field in The file descriptors of the child process are set using the ``stdio`` field in
@ -199,6 +207,7 @@ Then we set the ``fd`` to ``stderr``.
.. rubric:: proc-streams/main.c .. rubric:: proc-streams/main.c
.. literalinclude:: ../../code/proc-streams/main.c .. literalinclude:: ../../code/proc-streams/main.c
:language: c
:linenos: :linenos:
:lines: 15-17,27- :lines: 15-17,27-
:emphasize-lines: 6,10,11,12 :emphasize-lines: 6,10,11,12
@ -217,12 +226,14 @@ A sample CGI script/executable is:
.. rubric:: cgi/tick.c .. rubric:: cgi/tick.c
.. literalinclude:: ../../code/cgi/tick.c .. literalinclude:: ../../code/cgi/tick.c
:language: c
The CGI server combines the concepts from this chapter and :doc:`networking` so The CGI server combines the concepts from this chapter and :doc:`networking` so
that every client is sent ten ticks after which that connection is closed. that every client is sent ten ticks after which that connection is closed.
.. rubric:: cgi/main.c .. rubric:: cgi/main.c
.. literalinclude:: ../../code/cgi/main.c .. literalinclude:: ../../code/cgi/main.c
:language: c
:linenos: :linenos:
:lines: 49-63 :lines: 49-63
:emphasize-lines: 10 :emphasize-lines: 10
@ -232,6 +243,7 @@ Here we simply accept the TCP connection and pass on the socket (*stream*) to
.. rubric:: cgi/main.c .. rubric:: cgi/main.c
.. literalinclude:: ../../code/cgi/main.c .. literalinclude:: ../../code/cgi/main.c
:language: c
:linenos: :linenos:
:lines: 16, 25-45 :lines: 16, 25-45
:emphasize-lines: 8-9,18,20 :emphasize-lines: 8-9,18,20
@ -266,10 +278,10 @@ Domain Socket`_, or derived from `mkfifo(1)`_, or it could actually be a
This is intended for the purpose of allowing multiple libuv processes to This is intended for the purpose of allowing multiple libuv processes to
communicate with IPC. This is discussed below. communicate with IPC. This is discussed below.
.. _pipe(7): http://man7.org/linux/man-pages/man7/pipe.7.html .. _pipe(7): https://man7.org/linux/man-pages/man7/pipe.7.html
.. _mkfifo(1): http://man7.org/linux/man-pages/man1/mkfifo.1.html .. _mkfifo(1): https://man7.org/linux/man-pages/man1/mkfifo.1.html
.. _socketpair(2): http://man7.org/linux/man-pages/man2/socketpair.2.html .. _socketpair(2): https://man7.org/linux/man-pages/man2/socketpair.2.html
.. _Unix Domain Socket: http://man7.org/linux/man-pages/man7/unix.7.html .. _Unix Domain Socket: https://man7.org/linux/man-pages/man7/unix.7.html
.. _Named Pipe: https://docs.microsoft.com/en-us/windows/win32/ipc/named-pipes .. _Named Pipe: https://docs.microsoft.com/en-us/windows/win32/ipc/named-pipes
@ -291,6 +303,7 @@ messaging is no different from TCP, so we'll re-use the echo server example.
.. rubric:: pipe-echo-server/main.c .. rubric:: pipe-echo-server/main.c
.. literalinclude:: ../../code/pipe-echo-server/main.c .. literalinclude:: ../../code/pipe-echo-server/main.c
:language: c
:linenos: :linenos:
:lines: 70- :lines: 70-
:emphasize-lines: 5,10,14 :emphasize-lines: 5,10,14
@ -320,7 +333,7 @@ to hand off their I/O to other processes. Applications include load-balancing
servers, worker processes and other ways to make optimum use of CPU. libuv only servers, worker processes and other ways to make optimum use of CPU. libuv only
supports sending **TCP sockets or other pipes** over pipes for now. supports sending **TCP sockets or other pipes** over pipes for now.
To demonstrate, we will look at a echo server implementation that hands of To demonstrate, we will look at an echo server implementation that hands off
clients to worker processes in a round-robin fashion. This program is a bit clients to worker processes in a round-robin fashion. This program is a bit
involved, and while only snippets are included in the book, it is recommended involved, and while only snippets are included in the book, it is recommended
to read the full code to really understand it. to read the full code to really understand it.
@ -330,6 +343,7 @@ it by the master.
.. rubric:: multi-echo-server/worker.c .. rubric:: multi-echo-server/worker.c
.. literalinclude:: ../../code/multi-echo-server/worker.c .. literalinclude:: ../../code/multi-echo-server/worker.c
:language: c
:linenos: :linenos:
:lines: 7-9,81- :lines: 7-9,81-
:emphasize-lines: 6-8 :emphasize-lines: 6-8
@ -343,6 +357,7 @@ standard input of the worker, we connect the pipe to ``stdin`` using
.. rubric:: multi-echo-server/worker.c .. rubric:: multi-echo-server/worker.c
.. literalinclude:: ../../code/multi-echo-server/worker.c .. literalinclude:: ../../code/multi-echo-server/worker.c
:language: c
:linenos: :linenos:
:lines: 51-79 :lines: 51-79
:emphasize-lines: 10,15,20 :emphasize-lines: 10,15,20
@ -361,6 +376,7 @@ allow load balancing.
.. rubric:: multi-echo-server/main.c .. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c .. literalinclude:: ../../code/multi-echo-server/main.c
:language: c
:linenos: :linenos:
:lines: 9-13 :lines: 9-13
@ -369,6 +385,7 @@ master and the individual process.
.. rubric:: multi-echo-server/main.c .. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c .. literalinclude:: ../../code/multi-echo-server/main.c
:language: c
:linenos: :linenos:
:lines: 51,61-95 :lines: 51,61-95
:emphasize-lines: 17,20-21 :emphasize-lines: 17,20-21
@ -387,6 +404,7 @@ worker in the round-robin.
.. rubric:: multi-echo-server/main.c .. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c .. literalinclude:: ../../code/multi-echo-server/main.c
:language: c
:linenos: :linenos:
:lines: 31-49 :lines: 31-49
:emphasize-lines: 9,12-13 :emphasize-lines: 9,12-13

View File

@ -39,6 +39,7 @@ wait for it to close using ``uv_thread_join()``.
.. rubric:: thread-create/main.c .. rubric:: thread-create/main.c
.. literalinclude:: ../../code/thread-create/main.c .. literalinclude:: ../../code/thread-create/main.c
:language: c
:linenos: :linenos:
:lines: 26-36 :lines: 26-36
:emphasize-lines: 3-7 :emphasize-lines: 3-7
@ -55,6 +56,7 @@ thread, scheduled pre-emptively by the operating system:
.. rubric:: thread-create/main.c .. rubric:: thread-create/main.c
.. literalinclude:: ../../code/thread-create/main.c .. literalinclude:: ../../code/thread-create/main.c
:language: c
:linenos: :linenos:
:lines: 6-14 :lines: 6-14
:emphasize-lines: 2 :emphasize-lines: 2
@ -124,6 +126,7 @@ example.
.. rubric:: locks/main.c - simple rwlocks .. rubric:: locks/main.c - simple rwlocks
.. literalinclude:: ../../code/locks/main.c .. literalinclude:: ../../code/locks/main.c
:language: c
:linenos: :linenos:
:emphasize-lines: 13,16,27,31,42,55 :emphasize-lines: 13,16,27,31,42,55
@ -208,6 +211,7 @@ event loop from performing other activities.
.. rubric:: queue-work/main.c - lazy fibonacci .. rubric:: queue-work/main.c - lazy fibonacci
.. literalinclude:: ../../code/queue-work/main.c .. literalinclude:: ../../code/queue-work/main.c
:language: c
:linenos: :linenos:
:lines: 17-29 :lines: 17-29
@ -221,6 +225,7 @@ The trigger is ``uv_queue_work``:
.. rubric:: queue-work/main.c .. rubric:: queue-work/main.c
.. literalinclude:: ../../code/queue-work/main.c .. literalinclude:: ../../code/queue-work/main.c
:language: c
:linenos: :linenos:
:lines: 31-44 :lines: 31-44
:emphasize-lines: 10 :emphasize-lines: 10
@ -248,6 +253,7 @@ up a signal handler for termination.
.. rubric:: queue-cancel/main.c .. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c .. literalinclude:: ../../code/queue-cancel/main.c
:language: c
:linenos: :linenos:
:lines: 43- :lines: 43-
@ -256,6 +262,7 @@ When the user triggers the signal by pressing ``Ctrl+C`` we send
.. rubric:: queue-cancel/main.c .. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c .. literalinclude:: ../../code/queue-cancel/main.c
:language: c
:linenos: :linenos:
:lines: 33-41 :lines: 33-41
:emphasize-lines: 6 :emphasize-lines: 6
@ -265,6 +272,7 @@ with ``status`` set to ``UV_ECANCELED``.
.. rubric:: queue-cancel/main.c .. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c .. literalinclude:: ../../code/queue-cancel/main.c
:language: c
:linenos: :linenos:
:lines: 28-31 :lines: 28-31
:emphasize-lines: 2 :emphasize-lines: 2
@ -292,8 +300,9 @@ informing the user of the status of running downloads.
.. rubric:: progress/main.c .. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c .. literalinclude:: ../../code/progress/main.c
:language: c
:linenos: :linenos:
:lines: 7-8,34- :lines: 7-8,35-
:emphasize-lines: 2,11 :emphasize-lines: 2,11
The async thread communication works *on loops* so although any thread can be The async thread communication works *on loops* so although any thread can be
@ -317,8 +326,9 @@ with the async watcher whenever it receives a message.
.. rubric:: progress/main.c .. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c .. literalinclude:: ../../code/progress/main.c
:language: c
:linenos: :linenos:
:lines: 10-23 :lines: 10-24
:emphasize-lines: 7-8 :emphasize-lines: 7-8
In the download function, we modify the progress indicator and queue the message In the download function, we modify the progress indicator and queue the message
@ -327,8 +337,9 @@ non-blocking and will return immediately.
.. rubric:: progress/main.c .. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c .. literalinclude:: ../../code/progress/main.c
:language: c
:linenos: :linenos:
:lines: 30-33 :lines: 31-34
The callback is a standard libuv pattern, extracting the data from the watcher. The callback is a standard libuv pattern, extracting the data from the watcher.
@ -336,8 +347,9 @@ Finally it is important to remember to clean up the watcher.
.. rubric:: progress/main.c .. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c .. literalinclude:: ../../code/progress/main.c
:language: c
:linenos: :linenos:
:lines: 25-28 :lines: 26-29
:emphasize-lines: 3 :emphasize-lines: 3
After this example, which showed the abuse of the ``data`` field, bnoordhuis_ After this example, which showed the abuse of the ``data`` field, bnoordhuis_

View File

@ -87,6 +87,7 @@ JS object and can be ref/unrefed.
.. rubric:: ref-timer/main.c .. rubric:: ref-timer/main.c
.. literalinclude:: ../../code/ref-timer/main.c .. literalinclude:: ../../code/ref-timer/main.c
:language: c
:linenos: :linenos:
:lines: 5-8, 17- :lines: 5-8, 17-
:emphasize-lines: 9 :emphasize-lines: 9
@ -111,6 +112,7 @@ idle watcher to keep the UI operational.
.. rubric:: idle-compute/main.c .. rubric:: idle-compute/main.c
.. literalinclude:: ../../code/idle-compute/main.c .. literalinclude:: ../../code/idle-compute/main.c
:language: c
:linenos: :linenos:
:lines: 5-9, 34- :lines: 5-9, 34-
:emphasize-lines: 13 :emphasize-lines: 13
@ -123,6 +125,7 @@ keep calling the idle callback again.
.. rubric:: idle-compute/main.c .. rubric:: idle-compute/main.c
.. literalinclude:: ../../code/idle-compute/main.c .. literalinclude:: ../../code/idle-compute/main.c
:language: c
:linenos: :linenos:
:lines: 10-19 :lines: 10-19
@ -215,8 +218,9 @@ progress with the download whenever libuv notifies of I/O readiness.
.. rubric:: uvwget/main.c - The setup .. rubric:: uvwget/main.c - The setup
.. literalinclude:: ../../code/uvwget/main.c .. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos: :linenos:
:lines: 1-9,140- :lines: 1-9,142-
:emphasize-lines: 7,21,24-25 :emphasize-lines: 7,21,24-25
The way each library is integrated with libuv will vary. In the case of The way each library is integrated with libuv will vary. In the case of
@ -231,10 +235,11 @@ Our downloader is to be invoked as::
$ ./uvwget [url1] [url2] ... $ ./uvwget [url1] [url2] ...
So we add each argument as an URL So we add each argument as a URL
.. rubric:: uvwget/main.c - Adding urls .. rubric:: uvwget/main.c - Adding urls
.. literalinclude:: ../../code/uvwget/main.c .. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos: :linenos:
:lines: 39-56 :lines: 39-56
:emphasize-lines: 13-14 :emphasize-lines: 13-14
@ -243,7 +248,7 @@ We let libcurl directly write the data to a file, but much more is possible if
you so desire. you so desire.
``start_timeout`` will be called immediately the first time by libcurl, so ``start_timeout`` will be called immediately the first time by libcurl, so
things are set in motion. This simply starts a libuv `timer <Timers>`_ which things are set in motion. This simply starts a libuv `timer <#timers>`_ which
drives ``curl_multi_socket_action`` with ``CURL_SOCKET_TIMEOUT`` whenever it drives ``curl_multi_socket_action`` with ``CURL_SOCKET_TIMEOUT`` whenever it
times out. ``curl_multi_socket_action`` is what drives libcurl, and what we times out. ``curl_multi_socket_action`` is what drives libcurl, and what we
call whenever sockets change state. But before we go into that, we need to poll call whenever sockets change state. But before we go into that, we need to poll
@ -251,6 +256,7 @@ on sockets whenever ``handle_socket`` is called.
.. rubric:: uvwget/main.c - Setting up polling .. rubric:: uvwget/main.c - Setting up polling
.. literalinclude:: ../../code/uvwget/main.c .. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos: :linenos:
:lines: 102-140 :lines: 102-140
:emphasize-lines: 9,11,15,21,24 :emphasize-lines: 9,11,15,21,24
@ -271,6 +277,7 @@ mask with the new value. ``curl_perform`` is the crux of this program.
.. rubric:: uvwget/main.c - Driving libcurl. .. rubric:: uvwget/main.c - Driving libcurl.
.. literalinclude:: ../../code/uvwget/main.c .. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos: :linenos:
:lines: 81-95 :lines: 81-95
:emphasize-lines: 2,6-7,12 :emphasize-lines: 2,6-7,12
@ -288,6 +295,7 @@ transfers are done.
.. rubric:: uvwget/main.c - Reading transfer status. .. rubric:: uvwget/main.c - Reading transfer status.
.. literalinclude:: ../../code/uvwget/main.c .. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos: :linenos:
:lines: 58-79 :lines: 58-79
:emphasize-lines: 6,9-10,13-14 :emphasize-lines: 6,9-10,13-14
@ -312,6 +320,7 @@ Let us first look at the interface provided to plugin authors.
.. rubric:: plugin/plugin.h .. rubric:: plugin/plugin.h
.. literalinclude:: ../../code/plugin/plugin.h .. literalinclude:: ../../code/plugin/plugin.h
:language: c
:linenos: :linenos:
You can similarly add more functions that plugin authors can use to do useful You can similarly add more functions that plugin authors can use to do useful
@ -319,6 +328,7 @@ things in your application [#]_. A sample plugin using this API is:
.. rubric:: plugin/hello.c .. rubric:: plugin/hello.c
.. literalinclude:: ../../code/plugin/hello.c .. literalinclude:: ../../code/plugin/hello.c
:language: c
:linenos: :linenos:
Our interface defines that all plugins should have an ``initialize`` function Our interface defines that all plugins should have an ``initialize`` function
@ -340,6 +350,7 @@ This is done by using ``uv_dlopen`` to first load the shared library
.. rubric:: plugin/main.c .. rubric:: plugin/main.c
.. literalinclude:: ../../code/plugin/main.c .. literalinclude:: ../../code/plugin/main.c
:language: c
:linenos: :linenos:
:lines: 7- :lines: 7-
:emphasize-lines: 15, 18, 24 :emphasize-lines: 15, 18, 24
@ -352,7 +363,7 @@ to get the error message.
argument. ``init_plugin_function`` is a function pointer to the sort of argument. ``init_plugin_function`` is a function pointer to the sort of
function we are looking for in the application's plugins. function we are looking for in the application's plugins.
.. _shared libraries: https://en.wikipedia.org/wiki/Shared_library#Shared_libraries .. _shared libraries: https://en.wikipedia.org/wiki/Shared_library
TTY TTY
--- ---
@ -393,6 +404,7 @@ Here is a simple example which prints white text on a red background:
.. rubric:: tty/main.c .. rubric:: tty/main.c
.. literalinclude:: ../../code/tty/main.c .. literalinclude:: ../../code/tty/main.c
:language: c
:linenos: :linenos:
:emphasize-lines: 11-12,14,17,27 :emphasize-lines: 11-12,14,17,27
@ -403,6 +415,7 @@ escape codes.
.. rubric:: tty-gravity/main.c .. rubric:: tty-gravity/main.c
.. literalinclude:: ../../code/tty-gravity/main.c .. literalinclude:: ../../code/tty-gravity/main.c
:language: c
:linenos: :linenos:
:emphasize-lines: 19,25,38 :emphasize-lines: 19,25,38

View File

@ -20,7 +20,7 @@ Data types
The base libuv handle type. The base libuv handle type.
.. c:type:: uv_handle_type .. c:enum:: uv_handle_type
The kind of the libuv handle. The kind of the libuv handle.
@ -94,7 +94,7 @@ Public members
.. c:member:: uv_handle_type uv_handle_t.type .. c:member:: uv_handle_type uv_handle_t.type
The :c:type:`uv_handle_type`, indicating the type of the underlying handle. Readonly. The :c:enum:`uv_handle_type`, indicating the type of the underlying handle. Readonly.
.. c:member:: void* uv_handle_t.data .. c:member:: void* uv_handle_t.data
@ -104,7 +104,7 @@ Public members
API API
--- ---
.. c:function:: UV_HANDLE_TYPE_MAP(iter_macro) .. c:macro:: UV_HANDLE_TYPE_MAP(iter_macro)
Macro that expands to a series of invocations of `iter_macro` for Macro that expands to a series of invocations of `iter_macro` for
each of the handle types. `iter_macro` is invoked with two each of the handle types. `iter_macro` is invoked with two
@ -153,6 +153,9 @@ API
In-progress requests, like uv_connect_t or uv_write_t, are cancelled and In-progress requests, like uv_connect_t or uv_write_t, are cancelled and
have their callbacks called asynchronously with status=UV_ECANCELED. have their callbacks called asynchronously with status=UV_ECANCELED.
`close_cb` can be `NULL` in cases where no cleanup or deallocation is
necessary.
.. c:function:: void uv_ref(uv_handle_t* handle) .. c:function:: void uv_ref(uv_handle_t* handle)
Reference the given handle. References are idempotent, that is, if a handle Reference the given handle. References are idempotent, that is, if a handle
@ -245,7 +248,7 @@ just for some handle types.
.. versionadded:: 1.19.0 .. versionadded:: 1.19.0
.. c:function:: void* uv_handle_set_data(uv_handle_t* handle, void* data) .. c:function:: void uv_handle_set_data(uv_handle_t* handle, void* data)
Sets `handle->data` to `data`. Sets `handle->data` to `data`.

View File

@ -41,14 +41,22 @@ API
.. c:function:: int uv_idle_init(uv_loop_t* loop, uv_idle_t* idle) .. c:function:: int uv_idle_init(uv_loop_t* loop, uv_idle_t* idle)
Initialize the handle. Initialize the handle. This function always succeeds.
:returns: 0
.. c:function:: int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb) .. c:function:: int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb)
Start the handle with the given callback. Start the handle with the given callback. This function always succeeds,
except when `cb` is `NULL`.
:returns: 0 on success, or `UV_EINVAL` when `cb == NULL`.
.. c:function:: int uv_idle_stop(uv_idle_t* idle) .. c:function:: int uv_idle_stop(uv_idle_t* idle)
Stop the handle, the callback will no longer be called. Stop the handle, the callback will no longer be called.
This function always succeeds.
:returns: 0
.. seealso:: The :c:type:`uv_handle_t` API functions also apply. .. seealso:: The :c:type:`uv_handle_t` API functions also apply.

View File

@ -7,7 +7,7 @@ Overview
libuv is a multi-platform support library with a focus on asynchronous I/O. It libuv is a multi-platform support library with a focus on asynchronous I/O. It
was primarily developed for use by `Node.js`_, but it's also used by `Luvit`_, was primarily developed for use by `Node.js`_, but it's also used by `Luvit`_,
`Julia`_, `pyuv`_, and `others`_. `Julia`_, `uvloop`_, and `others`_.
.. note:: .. note::
In case you find errors in this documentation you can help by sending In case you find errors in this documentation you can help by sending
@ -16,8 +16,8 @@ was primarily developed for use by `Node.js`_, but it's also used by `Luvit`_,
.. _Node.js: https://nodejs.org .. _Node.js: https://nodejs.org
.. _Luvit: https://luvit.io .. _Luvit: https://luvit.io
.. _Julia: https://julialang.org .. _Julia: https://julialang.org
.. _pyuv: https://github.com/saghul/pyuv .. _uvloop: https://github.com/MagicStack/uvloop
.. _others: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv .. _others: https://github.com/libuv/libuv/blob/v1.x/LINKS.md
Features Features
@ -58,5 +58,5 @@ libuv can be downloaded from `here <https://dist.libuv.org/dist/>`_.
Installation Installation
------------ ------------
Installation instructions can be found in `the README <https://github.com/libuv/libuv/blob/master/README.md>`_. Installation instructions can be found in the `README <https://github.com/libuv/libuv/blob/master/README.md>`_.

View File

@ -16,7 +16,20 @@ Data types
Loop data type. Loop data type.
.. c:type:: uv_run_mode .. c:enum:: uv_loop_option
Additional loop options.
See :c:func:`uv_loop_configure`.
::
typedef enum {
UV_LOOP_BLOCK_SIGNAL = 0,
UV_METRICS_IDLE_TIME,
UV_LOOP_USE_IO_URING_SQPOLL
} uv_loop_option;
.. c:enum:: uv_run_mode
Mode used to run the loop with :c:func:`uv_run`. Mode used to run the loop with :c:func:`uv_run`.
@ -68,6 +81,18 @@ API
to suppress unnecessary wakeups when using a sampling profiler. to suppress unnecessary wakeups when using a sampling profiler.
Requesting other signals will fail with UV_EINVAL. Requesting other signals will fail with UV_EINVAL.
- UV_METRICS_IDLE_TIME: Accumulate the amount of idle time the event loop
spends in the event provider.
This option is necessary to use :c:func:`uv_metrics_idle_time`.
- UV_LOOP_ENABLE_IO_URING_SQPOLL: Enable SQPOLL io_uring instance to handle
asynchronous file system operations.
.. versionchanged:: 1.39.0 added the UV_METRICS_IDLE_TIME option.
.. versionchanged:: 1.49.0 added the UV_LOOP_ENABLE_IO_URING_SQPOLL option.
.. c:function:: int uv_loop_close(uv_loop_t* loop) .. c:function:: int uv_loop_close(uv_loop_t* loop)
Releases all internal loop resources. Call this function only when the loop Releases all internal loop resources. Call this function only when the loop
@ -231,7 +256,7 @@ API
.. versionadded:: 1.19.0 .. versionadded:: 1.19.0
.. c:function:: void* uv_loop_set_data(uv_loop_t* loop, void* data) .. c:function:: void uv_loop_set_data(uv_loop_t* loop, void* data)
Sets `loop->data` to `data`. Sets `loop->data` to `data`.

71
docs/src/metrics.rst Normal file
View File

@ -0,0 +1,71 @@
.. _metrics:
Metrics operations
======================
libuv provides a metrics API to track various internal operations of the event
loop.
Data types
----------
.. c:type:: uv_metrics_t
The struct that contains event loop metrics. It is recommended to retrieve
these metrics in a :c:type:`uv_prepare_cb` in order to make sure there are
no inconsistencies with the metrics counters.
::
typedef struct {
uint64_t loop_count;
uint64_t events;
uint64_t events_waiting;
/* private */
uint64_t* reserved[13];
} uv_metrics_t;
Public members
^^^^^^^^^^^^^^
.. c:member:: uint64_t uv_metrics_t.loop_count
Number of event loop iterations.
.. c:member:: uint64_t uv_metrics_t.events
Number of events that have been processed by the event handler.
.. c:member:: uint64_t uv_metrics_t.events_waiting
Number of events that were waiting to be processed when the event provider
was called.
API
---
.. c:function:: uint64_t uv_metrics_idle_time(uv_loop_t* loop)
Retrieve the amount of time the event loop has been idle in the kernel's
event provider (e.g. ``epoll_wait``). The call is thread safe.
The return value is the accumulated time spent idle in the kernel's event
provider starting from when the :c:type:`uv_loop_t` was configured to
collect the idle time.
.. note::
The event loop will not begin accumulating the event provider's idle
time until calling :c:type:`uv_loop_configure` with
:c:type:`UV_METRICS_IDLE_TIME`.
.. versionadded:: 1.39.0
.. c:function:: int uv_metrics_info(uv_loop_t* loop, uv_metrics_t* metrics)
Copy the current set of event loop metrics to the ``metrics`` pointer.
.. versionadded:: 1.45.0

View File

@ -73,7 +73,8 @@ Data types
.. c:type:: uv_timeval_t .. c:type:: uv_timeval_t
Data type for storing times. Y2K38-unsafe data type for storing times with microsecond resolution.
Will be replaced with :c:type:`uv_timeval64_t` in libuv v2.0.
:: ::
@ -84,7 +85,7 @@ Data types
.. c:type:: uv_timeval64_t .. c:type:: uv_timeval64_t
Alternative data type for storing times. Y2K38-safe data type for storing times with microsecond resolution.
:: ::
@ -93,6 +94,28 @@ Data types
int32_t tv_usec; int32_t tv_usec;
} uv_timeval64_t; } uv_timeval64_t;
.. c:type:: uv_timespec64_t
Y2K38-safe data type for storing times with nanosecond resolution.
::
typedef struct {
int64_t tv_sec;
int32_t tv_nsec;
} uv_timespec64_t;
.. c:enum:: uv_clock_id
Clock source for :c:func:`uv_clock_gettime`.
::
typedef enum {
UV_CLOCK_MONOTONIC,
UV_CLOCK_REALTIME
} uv_clock_id;
.. c:type:: uv_rusage_t .. c:type:: uv_rusage_t
Data type for resource usage results. Data type for resource usage results.
@ -119,7 +142,10 @@ Data types
} uv_rusage_t; } uv_rusage_t;
Members marked with `(X)` are unsupported on Windows. Members marked with `(X)` are unsupported on Windows.
See :man:`getrusage(2)` for supported fields on Unix See :man:`getrusage(2)` for supported fields on UNIX-like platforms.
The maximum resident set size is reported in kilobytes, the unit most
platforms use natively.
.. c:type:: uv_cpu_info_t .. c:type:: uv_cpu_info_t
@ -131,11 +157,11 @@ Data types
char* model; char* model;
int speed; int speed;
struct uv_cpu_times_s { struct uv_cpu_times_s {
uint64_t user; uint64_t user; /* milliseconds */
uint64_t nice; uint64_t nice; /* milliseconds */
uint64_t sys; uint64_t sys; /* milliseconds */
uint64_t idle; uint64_t idle; /* milliseconds */
uint64_t irq; uint64_t irq; /* milliseconds */
} cpu_times; } cpu_times;
} uv_cpu_info_t; } uv_cpu_info_t;
@ -173,6 +199,18 @@ Data types
char* homedir; char* homedir;
} uv_passwd_t; } uv_passwd_t;
.. c:type:: uv_group_t
Data type for group file information.
::
typedef struct uv_group_s {
char* groupname;
unsigned long gid;
char** members;
} uv_group_t;
.. c:type:: uv_utsname_t .. c:type:: uv_utsname_t
Data type for operating system name and version information. Data type for operating system name and version information.
@ -211,7 +249,7 @@ API
type of the stdio streams. type of the stdio streams.
For :man:`isatty(3)` equivalent functionality use this function and test For :man:`isatty(3)` equivalent functionality use this function and test
for ``UV_TTY``. for `UV_TTY`.
.. c:function:: int uv_replace_allocator(uv_malloc_func malloc_func, uv_realloc_func realloc_func, uv_calloc_func calloc_func, uv_free_func free_func) .. c:function:: int uv_replace_allocator(uv_malloc_func malloc_func, uv_realloc_func realloc_func, uv_calloc_func calloc_func, uv_free_func free_func)
@ -225,14 +263,32 @@ API
after all resources have been freed and thus libuv doesn't reference after all resources have been freed and thus libuv doesn't reference
any allocated memory chunk. any allocated memory chunk.
On success, it returns 0, if any of the function pointers is NULL it On success, it returns 0, if any of the function pointers is `NULL` it
returns UV_EINVAL. returns `UV_EINVAL`.
.. warning:: There is no protection against changing the allocator multiple .. warning:: There is no protection against changing the allocator multiple
times. If the user changes it they are responsible for making times. If the user changes it they are responsible for making
sure the allocator is changed while no memory was allocated with sure the allocator is changed while no memory was allocated with
the previous allocator, or that they are compatible. the previous allocator, or that they are compatible.
.. warning:: Allocator must be thread-safe.
.. c:function:: void uv_library_shutdown(void);
.. versionadded:: 1.38.0
Release any global state that libuv is holding onto. Libuv will normally
do so automatically when it is unloaded but it can be instructed to perform
cleanup manually.
.. warning:: Only call :c:func:`uv_library_shutdown()` once.
.. warning:: Don't call :c:func:`uv_library_shutdown()` when there are
still event loops or I/O requests active.
.. warning:: Don't call libuv functions after calling
:c:func:`uv_library_shutdown()`.
.. c:function:: uv_buf_t uv_buf_init(char* base, unsigned int len) .. c:function:: uv_buf_t uv_buf_init(char* base, unsigned int len)
Constructor for :c:type:`uv_buf_t`. Constructor for :c:type:`uv_buf_t`.
@ -243,9 +299,9 @@ API
.. c:function:: char** uv_setup_args(int argc, char** argv) .. c:function:: char** uv_setup_args(int argc, char** argv)
Store the program arguments. Required for getting / setting the process title. Store the program arguments. Required for getting / setting the process title
Libuv may take ownership of the memory that `argv` points to. This function or the executable path. Libuv may take ownership of the memory that `argv`
should be called exactly once, at program start-up. points to. This function should be called exactly once, at program start-up.
Example: Example:
@ -257,29 +313,44 @@ API
.. c:function:: int uv_get_process_title(char* buffer, size_t size) .. c:function:: int uv_get_process_title(char* buffer, size_t size)
Gets the title of the current process. You *must* call `uv_setup_args` Gets the title of the current process. You *must* call `uv_setup_args`
before calling this function. If `buffer` is `NULL` or `size` is zero, before calling this function on Unix and AIX systems. If `uv_setup_args`
`UV_EINVAL` is returned. If `size` cannot accommodate the process title and has not been called on systems that require it, then `UV_ENOBUFS` is
terminating `NULL` character, the function returns `UV_ENOBUFS`. returned. If `buffer` is `NULL` or `size` is zero, `UV_EINVAL` is returned.
If `size` cannot accommodate the process title and terminating `nul`
character, the function returns `UV_ENOBUFS`.
.. note::
On BSD systems, `uv_setup_args` is needed for getting the initial process
title. The process title returned will be an empty string until either
`uv_setup_args` or `uv_set_process_title` is called.
.. versionchanged:: 1.18.1 now thread-safe on all supported platforms. .. versionchanged:: 1.18.1 now thread-safe on all supported platforms.
.. versionchanged:: 1.39.0 now returns an error if `uv_setup_args` is needed
but hasn't been called.
.. c:function:: int uv_set_process_title(const char* title) .. c:function:: int uv_set_process_title(const char* title)
Sets the current process title. You *must* call `uv_setup_args` before Sets the current process title. You *must* call `uv_setup_args` before
calling this function. On platforms with a fixed size buffer for the process calling this function on Unix and AIX systems. If `uv_setup_args` has not
title the contents of `title` will be copied to the buffer and truncated if been called on systems that require it, then `UV_ENOBUFS` is returned. On
larger than the available space. Other platforms will return `UV_ENOMEM` if platforms with a fixed size buffer for the process title the contents of
they cannot allocate enough space to duplicate the contents of `title`. `title` will be copied to the buffer and truncated if larger than the
available space. Other platforms will return `UV_ENOMEM` if they cannot
allocate enough space to duplicate the contents of `title`.
.. versionchanged:: 1.18.1 now thread-safe on all supported platforms. .. versionchanged:: 1.18.1 now thread-safe on all supported platforms.
.. versionchanged:: 1.39.0 now returns an error if `uv_setup_args` is needed
but hasn't been called.
.. c:function:: int uv_resident_set_memory(size_t* rss) .. c:function:: int uv_resident_set_memory(size_t* rss)
Gets the resident set size (RSS) for the current process. Gets the resident set size (RSS) for the current process.
.. c:function:: int uv_uptime(double* uptime) .. c:function:: int uv_uptime(double* uptime)
Gets the current system uptime. Gets the current system uptime. Depending on the system full or fractional seconds are returned.
.. c:function:: int uv_getrusage(uv_rusage_t* rusage) .. c:function:: int uv_getrusage(uv_rusage_t* rusage)
@ -289,6 +360,17 @@ API
On Windows not all fields are set, the unsupported fields are filled with zeroes. On Windows not all fields are set, the unsupported fields are filled with zeroes.
See :c:type:`uv_rusage_t` for more details. See :c:type:`uv_rusage_t` for more details.
.. c:function:: int uv_getrusage_thread(uv_rusage_t* rusage)
Gets the resource usage measures for the calling thread.
.. versionadded:: 1.50.0
.. note::
Not supported on all platforms. May return `UV_ENOTSUP`.
On macOS and Windows not all fields are set, the unsupported fields are filled with zeroes.
See :c:type:`uv_rusage_t` for more details.
.. c:function:: uv_pid_t uv_os_getpid(void) .. c:function:: uv_pid_t uv_os_getpid(void)
Returns the current process ID. Returns the current process ID.
@ -301,15 +383,41 @@ API
.. versionadded:: 1.16.0 .. versionadded:: 1.16.0
.. c:function:: unsigned int uv_available_parallelism(void)
Returns an estimate of the default amount of parallelism a program should
use. Always returns a non-zero value.
On Linux, inspects the calling thread's CPU affinity mask to determine if
it has been pinned to specific CPUs.
On Windows, the available parallelism may be underreported on systems with
more than 64 logical CPUs.
On other platforms, reports the number of CPUs that the operating system
considers to be online.
.. versionadded:: 1.44.0
.. c:function:: int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) .. c:function:: int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count)
Gets information about the CPUs on the system. The `cpu_infos` array will Gets information about the CPUs on the system. The `cpu_infos` array will
have `count` elements and needs to be freed with :c:func:`uv_free_cpu_info`. have `count` elements and needs to be freed with :c:func:`uv_free_cpu_info`.
Use :c:func:`uv_available_parallelism` if you need to know how many CPUs
are available for threads or child processes.
.. c:function:: void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) .. c:function:: void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count)
Frees the `cpu_infos` array previously allocated with :c:func:`uv_cpu_info`. Frees the `cpu_infos` array previously allocated with :c:func:`uv_cpu_info`.
.. c:function:: int uv_cpumask_size(void)
Returns the maximum size of the mask used for process/thread affinities,
or `UV_ENOTSUP` if affinities are not supported on the current platform.
.. versionadded:: 1.45.0
.. c:function:: int uv_interface_addresses(uv_interface_address_t** addresses, int* count) .. c:function:: int uv_interface_addresses(uv_interface_address_t** addresses, int* count)
Gets address information about the network interfaces on the system. An Gets address information about the network interfaces on the system. An
@ -344,6 +452,10 @@ API
Convert a binary structure containing an IPv6 address to a string. Convert a binary structure containing an IPv6 address to a string.
.. c:function:: int uv_ip_name(const struct sockaddr *src, char *dst, size_t size)
Convert a binary structure containing an IPv4 address or an IPv6 address to a string.
.. c:function:: int uv_inet_ntop(int af, const void* src, char* dst, size_t size) .. c:function:: int uv_inet_ntop(int af, const void* src, char* dst, size_t size)
.. c:function:: int uv_inet_pton(int af, const char* src, void* dst) .. c:function:: int uv_inet_pton(int af, const char* src, void* dst)
@ -407,7 +519,8 @@ API
.. c:function:: int uv_exepath(char* buffer, size_t* size) .. c:function:: int uv_exepath(char* buffer, size_t* size)
Gets the executable path. Gets the executable path. You *must* call `uv_setup_args` before calling
this function.
.. c:function:: int uv_cwd(char* buffer, size_t* size) .. c:function:: int uv_cwd(char* buffer, size_t* size)
@ -476,6 +589,35 @@ API
.. versionadded:: 1.9.0 .. versionadded:: 1.9.0
.. c:function:: int uv_os_get_passwd2(uv_passwd_t* pwd, uv_uid_t uid)
Gets a subset of the password file entry for the provided uid.
The populated data includes the username, euid, gid, shell,
and home directory. On non-Windows systems, all data comes from
:man:`getpwuid_r(3)`. On Windows, uid and gid are set to -1 and have no
meaning, and shell is `NULL`. After successfully calling this function, the
memory allocated to `pwd` needs to be freed with
:c:func:`uv_os_free_passwd`.
.. versionadded:: 1.45.0
.. c:function:: int uv_os_get_group(uv_group_t* group, uv_uid_t gid)
Gets a subset of the group file entry for the provided uid.
The populated data includes the group name, gid, and members. On non-Windows
systems, all data comes from :man:`getgrgid_r(3)`. On Windows, uid and gid
are set to -1 and have no meaning. After successfully calling this function,
the memory allocated to `group` needs to be freed with
:c:func:`uv_os_free_group`.
.. versionadded:: 1.45.0
.. c:function:: void uv_os_free_group(uv_passwd_t* pwd)
Frees the memory previously allocated with :c:func:`uv_os_get_group`.
.. versionadded:: 1.45.0
.. c:function:: void uv_os_free_passwd(uv_passwd_t* pwd) .. c:function:: void uv_os_free_passwd(uv_passwd_t* pwd)
Frees the `pwd` memory previously allocated with :c:func:`uv_os_get_passwd`. Frees the `pwd` memory previously allocated with :c:func:`uv_os_get_passwd`.
@ -484,28 +626,45 @@ API
.. c:function:: uint64_t uv_get_free_memory(void) .. c:function:: uint64_t uv_get_free_memory(void)
Gets memory information (in bytes). Gets the amount of free memory available in the system, as reported by
the kernel (in bytes). Returns 0 when unknown.
.. c:function:: uint64_t uv_get_total_memory(void) .. c:function:: uint64_t uv_get_total_memory(void)
Gets memory information (in bytes). Gets the total amount of physical memory in the system (in bytes).
Returns 0 when unknown.
.. c:function:: uint64_t uv_get_constrained_memory(void) .. c:function:: uint64_t uv_get_constrained_memory(void)
Gets the amount of memory available to the process (in bytes) based on Gets the total amount of memory available to the process (in bytes) based on
limits imposed by the OS. If there is no such constraint, or the constraint limits imposed by the OS. If there is no such constraint, or the constraint
is unknown, `0` is returned. Note that it is not unusual for this value to is unknown, `0` is returned. If there is a constraining mechanism, but there
be less than or greater than :c:func:`uv_get_total_memory`. is no constraint set, `UINT64_MAX` is returned. Note that it is not unusual
for this value to be less than or greater than :c:func:`uv_get_total_memory`.
.. note:: .. note::
This function currently only returns a non-zero value on Linux, based This function currently only returns a non-zero value on Linux, based
on cgroups if it is present. on cgroups if it is present, and on z/OS based on RLIMIT_MEMLIMIT.
.. versionadded:: 1.29.0 .. versionadded:: 1.29.0
.. c:function:: uint64_t uv_get_available_memory(void)
Gets the amount of free memory that is still available to the process (in bytes).
This differs from :c:func:`uv_get_free_memory` in that it takes into account any
limits imposed by the OS. If there is no such constraint, or the constraint
is unknown, the amount returned will be identical to :c:func:`uv_get_free_memory`.
.. note::
This function currently only returns a value that is different from
what :c:func:`uv_get_free_memory` reports on Linux, based
on cgroups if it is present.
.. versionadded:: 1.45.0
.. c:function:: uint64_t uv_hrtime(void) .. c:function:: uint64_t uv_hrtime(void)
Returns the current high-resolution real time. This is expressed in Returns the current high-resolution timestamp. This is expressed in
nanoseconds. It is relative to an arbitrary time in the past. It is not nanoseconds. It is relative to an arbitrary time in the past. It is not
related to the time of day and therefore not subject to clock drift. The related to the time of day and therefore not subject to clock drift. The
primary use is for measuring performance between intervals. primary use is for measuring performance between intervals.
@ -514,6 +673,19 @@ API
Not every platform can support nanosecond resolution; however, this value will always Not every platform can support nanosecond resolution; however, this value will always
be in nanoseconds. be in nanoseconds.
.. c:function:: int uv_clock_gettime(uv_clock_id clock_id, uv_timespec64_t* ts)
Obtain the current system time from a high-resolution real-time or monotonic
clock source.
The real-time clock counts from the UNIX epoch (1970-01-01) and is subject
to time adjustments; it can jump back in time.
The monotonic clock counts from an arbitrary point in the past and never
jumps back in time.
.. versionadded:: 1.45.0
.. c:function:: void uv_print_all_handles(uv_loop_t* loop, FILE* stream) .. c:function:: void uv_print_all_handles(uv_loop_t* loop, FILE* stream)
Prints all handles associated with the given `loop` to the given `stream`. Prints all handles associated with the given `loop` to the given `stream`.
@ -657,7 +829,7 @@ API
.. note:: .. note::
On IBM i PASE, you are not allowed to change your priority unless you On IBM i PASE, you are not allowed to change your priority unless you
have the *JOBCTL special authority (even to lower it). have the \*JOBCTL special authority (even to lower it).
.. versionadded:: 1.23.0 .. versionadded:: 1.23.0
@ -698,7 +870,7 @@ API
:man:`sysctl(2)`. :man:`sysctl(2)`.
- FreeBSD: `getrandom(2) <https://www.freebsd.org/cgi/man.cgi?query=getrandom&sektion=2>_`, - FreeBSD: `getrandom(2) <https://www.freebsd.org/cgi/man.cgi?query=getrandom&sektion=2>_`,
or `/dev/urandom` after reading from `/dev/random` once. or `/dev/urandom` after reading from `/dev/random` once.
- NetBSD: `KERN_ARND` `sysctl(3) <https://netbsd.gw.com/cgi-bin/man-cgi?sysctl+3+NetBSD-current>_` - NetBSD: `KERN_ARND` `sysctl(7) <https://man.netbsd.org/sysctl.7>_`
- macOS, OpenBSD: `getentropy(2) <https://man.openbsd.org/getentropy.2>_` - macOS, OpenBSD: `getentropy(2) <https://man.openbsd.org/getentropy.2>_`
if available, or `/dev/urandom` after reading from `/dev/random` once. if available, or `/dev/urandom` after reading from `/dev/random` once.
- AIX: `/dev/random`. - AIX: `/dev/random`.
@ -719,3 +891,50 @@ API
Causes the calling thread to sleep for `msec` milliseconds. Causes the calling thread to sleep for `msec` milliseconds.
.. versionadded:: 1.34.0 .. versionadded:: 1.34.0
String manipulation functions
-----------------------------
These string utilities are needed internally for dealing with Windows, and are
exported to allow clients to work uniformly with this data when the libuv API
is not complete.
.. c:function:: size_t uv_utf16_length_as_wtf8(const uint16_t* utf16, ssize_t utf16_len)
Get the length of a UTF-16 (or UCS-2) `utf16` value after converting it to
WTF-8. If `utf16` is NUL terminated, `utf16_len` can be set to -1,
otherwise it must be specified.
.. versionadded:: 1.47.0
.. c:function:: int uv_utf16_to_wtf8(const uint16_t* utf16, ssize_t utf16_len, char** wtf8_ptr, size_t* wtf8_len_ptr)
Convert UTF-16 (or UCS-2) data in `utf16` to WTF-8 data in `*wtf8_ptr`. The
`utf16_len` count (in characters) gives the length of `utf16`. If `utf16`
is NUL terminated, `utf16_len` can be set to -1, otherwise it must be
specified. If `wtf8_ptr` is `NULL`, no result will be computed, but the
length (equal to `uv_utf16_length_as_wtf8`) will be stored in `wtf8_ptr`.
If `*wtf8_ptr` is `NULL`, space for the conversion will be allocated and
returned in `wtf8_ptr` and the length will be returned in `wtf8_len_ptr`.
Otherwise, the length of `*wtf8_ptr` must be passed in `wtf8_len_ptr`. The
`wtf8_ptr` must contain an extra space for an extra NUL after the result.
If the result is truncated, `UV_ENOBUFS` will be returned and
`wtf8_len_ptr` will be the length of the required `wtf8_ptr` to contain the
whole result.
.. versionadded:: 1.47.0
.. c:function:: ssize_t uv_wtf8_length_as_utf16(const char* wtf8)
Get the length in characters of a NUL-terminated WTF-8 `wtf8` value
after converting it to UTF-16 (or UCS-2), including NUL terminator.
.. versionadded:: 1.47.0
.. c:function:: void uv_wtf8_to_utf16(const char* utf8, uint16_t* utf16, size_t utf16_len)
Convert NUL-terminated WTF-8 data in `wtf8` to UTF-16 (or UCS-2) data
in `utf16`. The `utf16_len` count (in characters) must include space
for the NUL terminator.
.. versionadded:: 1.47.0

View File

@ -55,17 +55,61 @@ API
Bind the pipe to a file path (Unix) or a name (Windows). Bind the pipe to a file path (Unix) or a name (Windows).
Does not support Linux abstract namespace sockets,
unlike :c:func:`uv_pipe_bind2`.
Alias for ``uv_pipe_bind2(handle, name, strlen(name), 0)``.
.. note:: .. note::
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes,
92 and 108 bytes. typically between 92 and 108 bytes.
.. c:function:: int uv_pipe_bind2(uv_pipe_t* handle, const char* name, size_t namelen, unsigned int flags)
Bind the pipe to a file path (Unix) or a name (Windows).
``flags`` must be zero or ``UV_PIPE_NO_TRUNCATE``. Returns ``UV_EINVAL``
for unsupported flags without performing the bind operation.
Supports Linux abstract namespace sockets. ``namelen`` must include
the leading nul byte but not the trailing nul byte.
.. versionadded:: 1.46.0
.. note::
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes,
typically between 92 and 108 bytes, unless the ``UV_PIPE_NO_TRUNCATE``
flag is specified, in which case an ``UV_EINVAL`` error is returned.
.. c:function:: void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, const char* name, uv_connect_cb cb) .. c:function:: void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, const char* name, uv_connect_cb cb)
Connect to the Unix domain socket or the named pipe. Connect to the Unix domain socket or the Windows named pipe.
Does not support Linux abstract namespace sockets,
unlike :c:func:`uv_pipe_connect2`.
Alias for ``uv_pipe_connect2(req, handle, name, strlen(name), 0, cb)``.
.. note:: .. note::
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes,
92 and 108 bytes. typically between 92 and 108 bytes.
.. c:function:: void uv_pipe_connect2(uv_connect_t* req, uv_pipe_t* handle, const char* name, size_t namelen, unsigned int flags, uv_connect_cb cb)
Connect to the Unix domain socket or the Windows named pipe.
``flags`` must be zero or ``UV_PIPE_NO_TRUNCATE``. Returns ``UV_EINVAL``
for unsupported flags without performing the connect operation.
Supports Linux abstract namespace sockets. ``namelen`` must include
the leading nul byte but not the trailing nul byte.
.. versionadded:: 1.46.0
.. note::
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes,
typically between 92 and 108 bytes, unless the ``UV_PIPE_NO_TRUNCATE``
flag is specified, in which case an ``UV_EINVAL`` error is returned.
.. c:function:: int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) .. c:function:: int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size)
@ -118,3 +162,21 @@ API
function is blocking. function is blocking.
.. versionadded:: 1.16.0 .. versionadded:: 1.16.0
.. c:function:: int uv_pipe(uv_file fds[2], int read_flags, int write_flags)
Create a pair of connected pipe handles.
Data may be written to `fds[1]` and read from `fds[0]`.
The resulting handles can be passed to `uv_pipe_open`, used with `uv_spawn`,
or for any other purpose.
Valid values for `flags` are:
- UV_NONBLOCK_PIPE: Opens the specified socket handle for `OVERLAPPED`
or `FIONBIO`/`O_NONBLOCK` I/O usage.
This is recommended for handles that will be used by libuv,
and not usually recommended otherwise.
Equivalent to :man:`pipe(2)` with the `O_CLOEXEC` flag set.
.. versionadded:: 1.41.0

View File

@ -45,7 +45,7 @@ Data types
Type definition for callback passed to :c:func:`uv_poll_start`. Type definition for callback passed to :c:func:`uv_poll_start`.
.. c:type:: uv_poll_event .. c:enum:: uv_poll_event
Poll event types Poll event types
@ -86,36 +86,65 @@ API
.. c:function:: int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb) .. c:function:: int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb)
Starts polling the file descriptor. `events` is a bitmask made up of Starts polling the file descriptor. `events` is a bitmask made up of
UV_READABLE, UV_WRITABLE, UV_PRIORITIZED and UV_DISCONNECT. As soon as an `UV_READABLE`, `UV_WRITABLE`, `UV_PRIORITIZED` and `UV_DISCONNECT`. As soon
event is detected the callback will be called with `status` set to 0, and the as an event is detected the callback will be called with `status` set to 0,
detected events set on the `events` field. and the detected events set on the `events` field.
The UV_PRIORITIZED event is used to watch for sysfs interrupts or TCP out-of-band The `UV_PRIORITIZED` event is used to watch for sysfs interrupts or TCP
messages. out-of-band messages.
The UV_DISCONNECT event is optional in the sense that it may not be The `UV_DISCONNECT` event is optional in the sense that it may not be
reported and the user is free to ignore it, but it can help optimize the shutdown reported and the user is free to ignore it, but it can help optimize the
path because an extra read or write call might be avoided. shutdown path because an extra read or write call might be avoided.
If an error happens while polling, `status` will be < 0 and corresponds If an error happens while polling, `status` will be < 0 and corresponds
with one of the UV_E* error codes (see :ref:`errors`). The user should with one of the `UV_E*` error codes (see :ref:`errors`). The user should
not close the socket while the handle is active. If the user does that not close the socket while the handle is active. If the user does that
anyway, the callback *may* be called reporting an error status, but this anyway, the callback *may* be called reporting an error status, but this is
is **not** guaranteed. **not** guaranteed. If `status == UV_EBADF` polling is discontinued for the
file handle and no further events will be reported. The user should
then call :c:func:`uv_close` on the handle.
.. note:: .. note::
Calling :c:func:`uv_poll_start` on a handle that is already active is fine. Doing so Calling :c:func:`uv_poll_start` on a handle that is already active is
will update the events mask that is being watched for. fine. Doing so will update the events mask that is being watched for.
.. note:: .. note::
Though UV_DISCONNECT can be set, it is unsupported on AIX and as such will not be set Though `UV_DISCONNECT` can be set, it is unsupported on AIX and as such
on the `events` field in the callback. will not be set on the `events` field in the callback.
.. versionchanged:: 1.9.0 Added the UV_DISCONNECT event. .. note::
.. versionchanged:: 1.14.0 Added the UV_PRIORITIZED event. If one of the events `UV_READABLE` or `UV_WRITABLE` are set, the
callback will be called again, as long as the given fd/socket remains
readable or writable accordingly. Particularly in each of the following
scenarios:
* The callback has been called because the socket became
readable/writable and the callback did not conduct a read/write on
this socket at all.
* The callback committed a read on the socket, and has not read all the
available data (when `UV_READABLE` is set).
* The callback committed a write on the socket, but it remained
writable afterwards (when `UV_WRITABLE` is set).
* The socket has already became readable/writable before calling
:c:func:`uv_poll_start` on a poll handle associated with this socket,
and since then the state of the socket did not changed.
In all of the above listed scenarios, the socket remains readable or
writable and hence the callback will be called again (depending on the
events set in the bitmask). This behaviour is known as level
triggering.
.. versionchanged:: 1.9.0 Added the `UV_DISCONNECT` event.
.. versionchanged:: 1.14.0 Added the `UV_PRIORITIZED` event.
.. c:function:: int uv_poll_stop(uv_poll_t* poll) .. c:function:: int uv_poll_stop(uv_poll_t* poll)
Stop polling the file descriptor, the callback will no longer be called. Stop polling the file descriptor, the callback will no longer be called.
.. note::
Calling :c:func:`uv_poll_stop` is effective immediately: any pending
callback is also canceled, even if the socket state change notification
was already pending.
.. seealso:: The :c:type:`uv_handle_t` API functions also apply. .. seealso:: The :c:type:`uv_handle_t` API functions also apply.

View File

@ -33,14 +33,22 @@ API
.. c:function:: int uv_prepare_init(uv_loop_t* loop, uv_prepare_t* prepare) .. c:function:: int uv_prepare_init(uv_loop_t* loop, uv_prepare_t* prepare)
Initialize the handle. Initialize the handle. This function always succeeds.
:returns: 0
.. c:function:: int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb) .. c:function:: int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb)
Start the handle with the given callback. Start the handle with the given callback. This function always succeeds,
except when `cb` is `NULL`.
:returns: 0 on success, or `UV_EINVAL` when `cb == NULL`.
.. c:function:: int uv_prepare_stop(uv_prepare_t* prepare) .. c:function:: int uv_prepare_stop(uv_prepare_t* prepare)
Stop the handle, the callback will no longer be called. Stop the handle, the callback will no longer be called.
This function always succeeds.
:returns: 0
.. seealso:: The :c:type:`uv_handle_t` API functions also apply. .. seealso:: The :c:type:`uv_handle_t` API functions also apply.

View File

@ -40,7 +40,7 @@ Data types
will indicate the exit status and the signal that caused the process to will indicate the exit status and the signal that caused the process to
terminate, if any. terminate, if any.
.. c:type:: uv_process_flags .. c:enum:: uv_process_flags
Flags to be set on the flags field of :c:type:`uv_process_options_t`. Flags to be set on the flags field of :c:type:`uv_process_options_t`.
@ -85,7 +85,14 @@ Data types
* option is only meaningful on Windows systems. On Unix it is silently * option is only meaningful on Windows systems. On Unix it is silently
* ignored. * ignored.
*/ */
UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6) UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6),
/*
* On Windows, if the path to the program to execute, specified in
* uv_process_options_t's file field, has a directory component,
* search for the exact file name before trying variants with
* extensions like '.exe' or '.cmd'.
*/
UV_PROCESS_WINDOWS_FILE_PATH_EXACT_NAME = (1 << 7)
}; };
.. c:type:: uv_stdio_container_t .. c:type:: uv_stdio_container_t
@ -102,72 +109,104 @@ Data types
} data; } data;
} uv_stdio_container_t; } uv_stdio_container_t;
.. c:type:: uv_stdio_flags .. c:enum:: uv_stdio_flags
Flags specifying how a stdio should be transmitted to the child process. Flags specifying how a stdio should be transmitted to the child process.
:: ::
typedef enum { typedef enum {
/*
* The following four options are mutually-exclusive, and define
* the operation to perform for the corresponding file descriptor
* in the child process:
*/
/*
* No file descriptor will be provided (or redirected to
* `/dev/null` if it is fd 0, 1 or 2).
*/
UV_IGNORE = 0x00, UV_IGNORE = 0x00,
/*
* Open a new pipe into `data.stream`, per the flags below. The
* `data.stream` field must point to a uv_pipe_t object that has
* been initialized with `uv_pipe_init(loop, data.stream, ipc);`,
* but not yet opened or connected.
/*
UV_CREATE_PIPE = 0x01, UV_CREATE_PIPE = 0x01,
/*
* The child process will be given a duplicate of the parent's
* file descriptor given by `data.fd`.
*/
UV_INHERIT_FD = 0x02, UV_INHERIT_FD = 0x02,
/*
* The child process will be given a duplicate of the parent's
* file descriptor being used by the stream handle given by
* `data.stream`.
*/
UV_INHERIT_STREAM = 0x04, UV_INHERIT_STREAM = 0x04,
/* /*
* When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE
* determine the direction of flow, from the child process' perspective. Both * determine the direction of flow, from the child process' perspective. Both
* flags may be specified to create a duplex data stream. * flags may be specified to create a duplex data stream.
*/ */
UV_READABLE_PIPE = 0x10, UV_READABLE_PIPE = 0x10,
UV_WRITABLE_PIPE = 0x20 UV_WRITABLE_PIPE = 0x20,
/* /*
* Open the child pipe handle in overlapped mode on Windows. * When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the
* On Unix it is silently ignored. * handle in non-blocking mode in the child. This may cause loss of data,
* if the child is not designed to handle to encounter this mode,
* but can also be significantly more efficient.
*/ */
UV_OVERLAPPED_PIPE = 0x40 UV_NONBLOCK_PIPE = 0x40
} uv_stdio_flags; } uv_stdio_flags;
Public members Public members
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
.. c:member:: uv_process_t.pid .. c:member:: int uv_process_t.pid
The PID of the spawned process. It's set after calling :c:func:`uv_spawn`. The PID of the spawned process. It's set after calling :c:func:`uv_spawn`.
.. note:: .. note::
The :c:type:`uv_handle_t` members also apply. The :c:type:`uv_handle_t` members also apply.
.. c:member:: uv_process_options_t.exit_cb .. c:member:: uv_exit_cb uv_process_options_t.exit_cb
Callback called after the process exits. Callback called after the process exits.
.. c:member:: uv_process_options_t.file .. c:member:: const char* uv_process_options_t.file
Path pointing to the program to be executed. Path pointing to the program to be executed.
.. c:member:: uv_process_options_t.args .. c:member:: char** uv_process_options_t.args
Command line arguments. args[0] should be the path to the program. On Command line arguments. args[0] should be the path to the program. On
Windows this uses `CreateProcess` which concatenates the arguments into a Windows this uses `CreateProcess` which concatenates the arguments into a
string this can cause some strange errors. See the string this can cause some strange errors. See the
``UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS`` flag on :c:type:`uv_process_flags`. ``UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS`` flag on :c:enum:`uv_process_flags`.
.. c:member:: uv_process_options_t.env .. c:member:: char** uv_process_options_t.env
Environment for the new process. If NULL the parents environment is used. Environment for the new process. If NULL the parents environment is used.
.. c:member:: uv_process_options_t.cwd .. c:member:: const char* uv_process_options_t.cwd
Current working directory for the subprocess. Current working directory for the subprocess.
.. c:member:: uv_process_options_t.flags .. c:member:: unsigned int uv_process_options_t.flags
Various flags that control how :c:func:`uv_spawn` behaves. See Various flags that control how :c:func:`uv_spawn` behaves. See
:c:type:`uv_process_flags`. :c:enum:`uv_process_flags`.
.. c:member:: uv_process_options_t.stdio_count .. c:member:: int uv_process_options_t.stdio_count
.. c:member:: uv_process_options_t.stdio .. c:member:: uv_stdio_container_t* uv_process_options_t.stdio
The `stdio` field points to an array of :c:type:`uv_stdio_container_t` The `stdio` field points to an array of :c:type:`uv_stdio_container_t`
structs that describe the file descriptors that will be made available to structs that describe the file descriptors that will be made available to
@ -178,8 +217,8 @@ Public members
On Windows file descriptors greater than 2 are available to the child process only if On Windows file descriptors greater than 2 are available to the child process only if
the child processes uses the MSVCRT runtime. the child processes uses the MSVCRT runtime.
.. c:member:: uv_process_options_t.uid .. c:member:: uv_uid_t uv_process_options_t.uid
.. c:member:: uv_process_options_t.gid .. c:member:: uv_gid_t uv_process_options_t.gid
Libuv can change the child process' user/group id. This happens only when Libuv can change the child process' user/group id. This happens only when
the appropriate bits are set in the flags fields. the appropriate bits are set in the flags fields.
@ -188,14 +227,13 @@ Public members
This is not supported on Windows, :c:func:`uv_spawn` will fail and set the error This is not supported on Windows, :c:func:`uv_spawn` will fail and set the error
to ``UV_ENOTSUP``. to ``UV_ENOTSUP``.
.. c:member:: uv_stdio_container_t.flags .. c:member:: uv_stdio_flags uv_stdio_container_t.flags
Flags specifying how the stdio container should be passed to the child. See Flags specifying how the stdio container should be passed to the child.
:c:type:`uv_stdio_flags`.
.. c:member:: uv_stdio_container_t.data .. c:member:: union @0 uv_stdio_container_t.data
Union containing either the stream or fd to be passed on to the child Union containing either the `stream` or `fd` to be passed on to the child
process. process.
@ -231,6 +269,9 @@ API
.. versionchanged:: 1.24.0 Added `UV_PROCESS_WINDOWS_HIDE_CONSOLE` and .. versionchanged:: 1.24.0 Added `UV_PROCESS_WINDOWS_HIDE_CONSOLE` and
`UV_PROCESS_WINDOWS_HIDE_GUI` flags. `UV_PROCESS_WINDOWS_HIDE_GUI` flags.
.. versionchanged:: 1.48.0 Added the
`UV_PROCESS_WINDOWS_FILE_PATH_EXACT_NAME` flag.
.. c:function:: int uv_process_kill(uv_process_t* handle, int signum) .. c:function:: int uv_process_kill(uv_process_t* handle, int signum)
Sends the specified signal to the given process handle. Check the documentation Sends the specified signal to the given process handle. Check the documentation

View File

@ -21,17 +21,9 @@ Data types
Union of all request types. Union of all request types.
.. c:enum:: uv_req_type
Public members The kind of the libuv request.
^^^^^^^^^^^^^^
.. c:member:: void* uv_req_t.data
Space for user-defined arbitrary data. libuv does not use this field.
.. c:member:: uv_req_type uv_req_t.type
Indicated the type of request. Readonly.
:: ::
@ -50,10 +42,22 @@ Public members
} uv_req_type; } uv_req_type;
Public members
^^^^^^^^^^^^^^
.. c:member:: void* uv_req_t.data
Space for user-defined arbitrary data. libuv does not use this field.
.. c:member:: uv_req_type uv_req_t.type
The :c:enum:`uv_req_type`, indicating the type of the request. Readonly.
API API
--- ---
.. c:function:: UV_REQ_TYPE_MAP(iter_macro) .. c:macro:: UV_REQ_TYPE_MAP(iter_macro)
Macro that expands to a series of invocations of `iter_macro` for Macro that expands to a series of invocations of `iter_macro` for
each of the request types. `iter_macro` is invoked with two each of the request types. `iter_macro` is invoked with two
@ -69,8 +73,8 @@ API
Returns 0 on success, or an error code < 0 on failure. Returns 0 on success, or an error code < 0 on failure.
Only cancellation of :c:type:`uv_fs_t`, :c:type:`uv_getaddrinfo_t`, Only cancellation of :c:type:`uv_fs_t`, :c:type:`uv_getaddrinfo_t`,
:c:type:`uv_getnameinfo_t` and :c:type:`uv_work_t` requests is :c:type:`uv_getnameinfo_t`, :c:type:`uv_random_t` and :c:type:`uv_work_t`
currently supported. requests is currently supported.
Cancelled requests have their callbacks invoked some time in the future. Cancelled requests have their callbacks invoked some time in the future.
It's **not** safe to free the memory associated with the request until the It's **not** safe to free the memory associated with the request until the
@ -80,8 +84,9 @@ API
* A :c:type:`uv_fs_t` request has its req->result field set to `UV_ECANCELED`. * A :c:type:`uv_fs_t` request has its req->result field set to `UV_ECANCELED`.
* A :c:type:`uv_work_t`, :c:type:`uv_getaddrinfo_t` or c:type:`uv_getnameinfo_t` * A :c:type:`uv_work_t`, :c:type:`uv_getaddrinfo_t`,
request has its callback invoked with status == `UV_ECANCELED`. :c:type:`uv_getnameinfo_t` or :c:type:`uv_random_t` request has its
callback invoked with status == `UV_ECANCELED`.
.. c:function:: size_t uv_req_size(uv_req_type type) .. c:function:: size_t uv_req_size(uv_req_type type)
@ -94,7 +99,7 @@ API
.. versionadded:: 1.19.0 .. versionadded:: 1.19.0
.. c:function:: void* uv_req_set_data(uv_req_t* req, void* data) .. c:function:: void uv_req_set_data(uv_req_t* req, void* data)
Sets `req->data` to `data`. Sets `req->data` to `data`.

View File

@ -18,7 +18,7 @@ from string import Template
def make_link_node(rawtext, app, name, manpage_num, options): def make_link_node(rawtext, app, name, manpage_num, options):
ref = app.config.man_url_regex ref = app.config.man_url_regex
if not ref: if not ref:
ref = "http://man7.org/linux/man-pages/man%s/%s.%s.html" %(manpage_num, name, manpage_num) ref = "https://man7.org/linux/man-pages/man%s/%s.%s.html" %(manpage_num, name, manpage_num)
else: else:
s = Template(ref) s = Template(ref)
ref = s.substitute(num=manpage_num, topic=name) ref = s.substitute(num=manpage_num, topic=name)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -139,6 +139,11 @@ API
be made several times until there is no more data to read or be made several times until there is no more data to read or
:c:func:`uv_read_stop` is called. :c:func:`uv_read_stop` is called.
.. versionchanged:: 1.38.0 :c:func:`uv_read_start()` now consistently
returns `UV_EALREADY` when called twice, and `UV_EINVAL` when the
stream is closing. With older libuv versions, it returns `UV_EALREADY`
on Windows but not UNIX, and `UV_EINVAL` on UNIX but not Windows.
.. c:function:: int uv_read_stop(uv_stream_t*) .. c:function:: int uv_read_stop(uv_stream_t*)
Stop reading data from the stream. The :c:type:`uv_read_cb` callback will Stop reading data from the stream. The :c:type:`uv_read_cb` callback will
@ -146,6 +151,11 @@ API
This function is idempotent and may be safely called on a stopped stream. This function is idempotent and may be safely called on a stopped stream.
This function will always succeed; hence, checking its return value is
unnecessary. A non-zero return indicates that finishing releasing resources
may be pending on the next input event on that TTY on Windows, and does not
indicate failure.
.. c:function:: int uv_write(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb) .. c:function:: int uv_write(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb)
Write data to stream. Buffers are written in order. Example: Write data to stream. Buffers are written in order. Example:
@ -183,8 +193,9 @@ API
initialized with `ipc` == 1. initialized with `ipc` == 1.
.. note:: .. note::
`send_handle` must be a TCP socket or pipe, which is a server or a connection (listening `send_handle` must be a TCP, pipe and UDP handle on Unix, or a TCP
or connected state). Bound sockets or pipes will be assumed to be servers. handle on Windows, which is a server or a connection (listening or
connected state). Bound sockets or pipes will be assumed to be servers.
.. c:function:: int uv_try_write(uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs) .. c:function:: int uv_try_write(uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs)
@ -197,6 +208,16 @@ API
* < 0: negative error code (``UV_EAGAIN`` is returned if no data can be sent * < 0: negative error code (``UV_EAGAIN`` is returned if no data can be sent
immediately). immediately).
.. c:function:: int uv_try_write2(uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t* send_handle)
Same as :c:func:`uv_try_write` and extended write function for sending
handles over a pipe like c:func:`uv_write2`.
Try to send a handle is not supported on Windows,
where it returns ``UV_EAGAIN``.
.. versionadded:: 1.42.0
.. c:function:: int uv_is_readable(const uv_stream_t* handle) .. c:function:: int uv_is_readable(const uv_stream_t* handle)
Returns 1 if the stream is readable, 0 otherwise. Returns 1 if the stream is readable, 0 otherwise.

View File

@ -16,6 +16,28 @@ Data types
TCP handle type. TCP handle type.
.. c:enum:: uv_tcp_flags
Flags used in :c:func:`uv_tcp_bind`.
::
enum uv_tcp_flags {
/* Used with uv_tcp_bind, when an IPv6 address is used. */
UV_TCP_IPV6ONLY = 1,
/* Enable SO_REUSEPORT socket option when binding the handle.
* This allows completely duplicate bindings by multiple processes
* or threads if they all set SO_REUSEPORT before binding the port.
* Incoming connections are distributed across the participating
* listener sockets.
*
* This flag is available only on Linux 3.9+, DragonFlyBSD 3.6+,
* FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ for now.
*/
UV_TCP_REUSEPORT = 2,
};
Public members Public members
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
@ -65,6 +87,10 @@ API
at the end of this procedure, then the handle is destroyed with a at the end of this procedure, then the handle is destroyed with a
``UV_ETIMEDOUT`` error passed to the corresponding callback. ``UV_ETIMEDOUT`` error passed to the corresponding callback.
If `delay` is less than 1 then ``UV_EINVAL`` is returned.
.. versionchanged:: 1.49.0 If `delay` is less than 1 then ``UV_EINVAL``` is returned.
.. c:function:: int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) .. c:function:: int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable)
Enable / disable simultaneous asynchronous accept requests that are Enable / disable simultaneous asynchronous accept requests that are
@ -77,17 +103,34 @@ API
.. c:function:: int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr* addr, unsigned int flags) .. c:function:: int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr* addr, unsigned int flags)
Bind the handle to an address and port. `addr` should point to an Bind the handle to an address and port.
initialized ``struct sockaddr_in`` or ``struct sockaddr_in6``.
When the port is already taken, you can expect to see an ``UV_EADDRINUSE`` When the port is already taken, you can expect to see an ``UV_EADDRINUSE``
error from either :c:func:`uv_tcp_bind`, :c:func:`uv_listen` or error from :c:func:`uv_listen` or :c:func:`uv_tcp_connect` unless you specify
:c:func:`uv_tcp_connect`. That is, a successful call to this function does ``UV_TCP_REUSEPORT`` in `flags` for all the binding sockets. That is, a successful
not guarantee that the call to :c:func:`uv_listen` or :c:func:`uv_tcp_connect` call to this function does not guarantee that the call to :c:func:`uv_listen` or
will succeed as well. :c:func:`uv_tcp_connect` will succeed as well.
`flags` can contain ``UV_TCP_IPV6ONLY``, in which case dual-stack support :param handle: TCP handle. It should have been initialized with :c:func:`uv_tcp_init`.
is disabled and only IPv6 is used.
:param addr: Address to bind to. It should point to an initialized ``struct sockaddr_in``
or ``struct sockaddr_in6``.
:param flags: Flags that control the behavior of binding the socket.
``UV_TCP_IPV6ONLY`` can be contained in `flags` to disable dual-stack
support and only use IPv6.
``UV_TCP_REUSEPORT`` can be contained in `flags` to enable the socket option
`SO_REUSEPORT` with the capability of load balancing that distribute incoming
connections across all listening sockets in multiple processes or threads.
:returns: 0 on success, or an error code < 0 on failure.
.. versionchanged:: 1.49.0 added the ``UV_TCP_REUSEPORT`` flag.
.. note::
``UV_TCP_REUSEPORT`` flag is available only on Linux 3.9+, DragonFlyBSD 3.6+,
FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ at the moment. On other platforms
this function will return an UV_ENOTSUP error.
.. c:function:: int uv_tcp_getsockname(const uv_tcp_t* handle, struct sockaddr* name, int* namelen) .. c:function:: int uv_tcp_getsockname(const uv_tcp_t* handle, struct sockaddr* name, int* namelen)
@ -128,3 +171,20 @@ API
:c:func:`uv_tcp_close_reset` calls is not allowed. :c:func:`uv_tcp_close_reset` calls is not allowed.
.. versionadded:: 1.32.0 .. versionadded:: 1.32.0
.. c:function:: int uv_socketpair(int type, int protocol, uv_os_sock_t socket_vector[2], int flags0, int flags1)
Create a pair of connected sockets with the specified properties.
The resulting handles can be passed to `uv_tcp_open`, used with `uv_spawn`,
or for any other purpose.
Valid values for `flags0` and `flags1` are:
- UV_NONBLOCK_PIPE: Opens the specified socket handle for `OVERLAPPED`
or `FIONBIO`/`O_NONBLOCK` I/O usage.
This is recommended for handles that will be used by libuv,
and not usually recommended otherwise.
Equivalent to :man:`socketpair(2)` with a domain of AF_UNIX.
.. versionadded:: 1.41.0

View File

@ -78,6 +78,14 @@ Threads
.. versionchanged:: 1.4.1 returns a UV_E* error code on failure .. versionchanged:: 1.4.1 returns a UV_E* error code on failure
.. c:function:: int uv_thread_detach(uv_thread_t* tid)
Detaches a thread. Detached threads automatically release their
resources upon termination, eliminating the need for the application to
call `uv_thread_join`.
.. versionadded:: 1.50.0
.. c:function:: int uv_thread_create_ex(uv_thread_t* tid, const uv_thread_options_t* params, uv_thread_cb entry, void* arg) .. c:function:: int uv_thread_create_ex(uv_thread_t* tid, const uv_thread_options_t* params, uv_thread_cb entry, void* arg)
Like :c:func:`uv_thread_create`, but additionally specifies options for creating a new thread. Like :c:func:`uv_thread_create`, but additionally specifies options for creating a new thread.
@ -88,10 +96,89 @@ Threads
.. versionadded:: 1.26.0 .. versionadded:: 1.26.0
.. c:function:: int uv_thread_setaffinity(uv_thread_t* tid, char* cpumask, char* oldmask, size_t mask_size)
Sets the specified thread's affinity to cpumask, which is specified in
bytes. Optionally returning the previous affinity setting in oldmask.
On Unix, uses :man:`pthread_getaffinity_np(3)` to get the affinity setting
and maps the cpu_set_t to bytes in oldmask. Then maps the bytes in cpumask
to a cpu_set_t and uses :man:`pthread_setaffinity_np(3)`. On Windows, maps
the bytes in cpumask to a bitmask and uses SetThreadAffinityMask() which
returns the previous affinity setting.
The mask_size specifies the number of entries (bytes) in cpumask / oldmask,
and must be greater-than-or-equal-to :c:func:`uv_cpumask_size`.
.. note::
Thread affinity setting is not atomic on Windows. Unsupported on macOS.
.. versionadded:: 1.45.0
.. c:function:: int uv_thread_getaffinity(uv_thread_t* tid, char* cpumask, size_t mask_size)
Gets the specified thread's affinity setting. On Unix, this maps the
cpu_set_t returned by :man:`pthread_getaffinity_np(3)` to bytes in cpumask.
The mask_size specifies the number of entries (bytes) in cpumask,
and must be greater-than-or-equal-to :c:func:`uv_cpumask_size`.
.. note::
Thread affinity getting is not atomic on Windows. Unsupported on macOS.
.. versionadded:: 1.45.0
.. c:function:: int uv_thread_getcpu(void)
Gets the CPU number on which the calling thread is running.
.. note::
Currently only implemented on Windows, Linux and FreeBSD.
.. versionadded:: 1.45.0
.. c:function:: uv_thread_t uv_thread_self(void) .. c:function:: uv_thread_t uv_thread_self(void)
.. c:function:: int uv_thread_join(uv_thread_t *tid) .. c:function:: int uv_thread_join(uv_thread_t *tid)
.. c:function:: int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) .. c:function:: int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2)
.. c:function:: int uv_thread_setname(const char* name)
Sets the name of the current thread. Different platforms define different limits on the max number of characters
a thread name can be: Linux, IBM i (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.
Not supported on Windows Server 2016, returns `UV_ENOSYS`.
.. versionadded:: 1.50.0
.. c:function:: int uv_thread_getname(uv_thread_t* tid, char* name, size_t* size)
Gets the name of the thread specified by `tid`. The thread name is copied, with the trailing NUL, 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
with the trailing NUL.
Not supported on Windows Server 2016, returns `UV_ENOSYS`.
.. versionadded:: 1.50.0
.. c:function:: int uv_thread_setpriority(uv_thread_t tid, int priority)
If the function succeeds, the return value is 0.
If the function fails, the return value is less than zero.
Sets the scheduling priority of the thread specified by tid. It requires elevated
privilege to set specific priorities on some platforms.
The priority can be set to the following constants. UV_THREAD_PRIORITY_HIGHEST,
UV_THREAD_PRIORITY_ABOVE_NORMAL, UV_THREAD_PRIORITY_NORMAL,
UV_THREAD_PRIORITY_BELOW_NORMAL, UV_THREAD_PRIORITY_LOWEST.
.. c:function:: int uv_thread_getpriority(uv_thread_t tid, int* priority)
If the function succeeds, the return value is 0.
If the function fails, the return value is less than zero.
Retrieves the scheduling priority of the thread specified by tid. The value in the
output parameter priority is platform dependent.
For Linux, when schedule policy is SCHED_OTHER (default), priority is 0.
Thread-local storage Thread-local storage
^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^

View File

@ -14,6 +14,11 @@ is 1024).
.. versionchanged:: 1.30.0 the maximum UV_THREADPOOL_SIZE allowed was increased from 128 to 1024. .. versionchanged:: 1.30.0 the maximum UV_THREADPOOL_SIZE allowed was increased from 128 to 1024.
.. versionchanged:: 1.45.0 threads now have an 8 MB stack instead of the
(sometimes too low) platform default.
.. versionchanged:: 1.50.0 threads now have a default name of libuv-worker.
The threadpool is global and shared across all event loops. When a particular The threadpool is global and shared across all event loops. When a particular
function makes use of the threadpool (i.e. when using :c:func:`uv_queue_work`) function makes use of the threadpool (i.e. when using :c:func:`uv_queue_work`)
libuv preallocates and initializes the maximum number of threads allowed by libuv preallocates and initializes the maximum number of threads allowed by

View File

@ -6,6 +6,15 @@
Timer handles are used to schedule callbacks to be called in the future. Timer handles are used to schedule callbacks to be called in the future.
Timers are either single-shot or repeating. Repeating timers do not adjust
for overhead but are rearmed relative to the event loop's idea of "now".
Libuv updates its idea of "now" right before executing timer callbacks, and
right after waking up from waiting for I/O. See also :c:func:`uv_update_time`.
Example: a repeating timer with a 50 ms interval whose callback takes 17 ms
to complete, runs again 33 ms later. If other tasks take longer than 33 ms,
the timer callback runs as soon as possible.
Data types Data types
---------- ----------
@ -64,11 +73,6 @@ API
duration, and will follow normal timer semantics in the case of a duration, and will follow normal timer semantics in the case of a
time-slice overrun. time-slice overrun.
For example, if a 50ms repeating timer first runs for 17ms, it will be
scheduled to run again 33ms later. If other tasks consume more than the
33ms following the first timer callback, then the callback will run as soon
as possible.
.. note:: .. note::
If the repeat value is set from a timer callback it does not immediately take effect. If the repeat value is set from a timer callback it does not immediately take effect.
If the timer was non-repeating before, it will have been stopped. If it was repeating, If the timer was non-repeating before, it will have been stopped. If it was repeating,
@ -78,4 +82,11 @@ API
Get the timer repeat value. Get the timer repeat value.
.. c:function:: uint64_t uv_timer_get_due_in(const uv_timer_t* handle)
Get the timer due value or 0 if it has expired. The time is relative to
:c:func:`uv_now()`.
.. versionadded:: 1.40.0
.. seealso:: The :c:type:`uv_handle_t` API functions also apply. .. seealso:: The :c:type:`uv_handle_t` API functions also apply.

View File

@ -16,7 +16,7 @@ Data types
TTY handle type. TTY handle type.
.. c:type:: uv_tty_mode_t .. c:enum:: uv_tty_mode_t
.. versionadded:: 1.2.0 .. versionadded:: 1.2.0
@ -27,13 +27,19 @@ Data types
typedef enum { typedef enum {
/* Initial/normal terminal mode */ /* Initial/normal terminal mode */
UV_TTY_MODE_NORMAL, UV_TTY_MODE_NORMAL,
/* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ /*
* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled).
* May become equivalent to UV_TTY_MODE_RAW_VT in future libuv versions.
*/
UV_TTY_MODE_RAW, UV_TTY_MODE_RAW,
/* Binary-safe I/O mode for IPC (Unix-only) */ /* Binary-safe I/O mode for IPC (Unix-only) */
UV_TTY_MODE_IO UV_TTY_MODE_IO,
/* Raw input mode. On Windows ENABLE_VIRTUAL_TERMINAL_INPUT is also set. */
UV_TTY_MODE_RAW_VT
} uv_tty_mode_t; } uv_tty_mode_t;
.. c:type:: uv_tty_vtermstate_t .. c:enum:: uv_tty_vtermstate_t
Console virtual terminal mode type: Console virtual terminal mode type:
:: ::
@ -97,7 +103,7 @@ API
.. c:function:: int uv_tty_set_mode(uv_tty_t* handle, uv_tty_mode_t mode) .. c:function:: int uv_tty_set_mode(uv_tty_t* handle, uv_tty_mode_t mode)
.. versionchanged:: 1.2.0: the mode is specified as a .. versionchanged:: 1.2.0: the mode is specified as a
:c:type:`uv_tty_mode_t` value. :c:enum:`uv_tty_mode_t` value.
Set the TTY using the specified terminal mode. Set the TTY using the specified terminal mode.

View File

@ -18,7 +18,7 @@ Data types
UDP send request type. UDP send request type.
.. c:type:: uv_udp_flags .. c:enum:: uv_udp_flags
Flags used in :c:func:`uv_udp_bind` and :c:type:`uv_udp_recv_cb`.. Flags used in :c:func:`uv_udp_bind` and :c:type:`uv_udp_recv_cb`..
@ -33,20 +33,52 @@ Data types
*/ */
UV_UDP_PARTIAL = 2, UV_UDP_PARTIAL = 2,
/* /*
* Indicates if SO_REUSEADDR will be set when binding the handle in * Indicates if SO_REUSEADDR will be set when binding the handle.
* uv_udp_bind. * This sets the SO_REUSEPORT socket flag on the BSDs (except for
* This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other * DragonFlyBSD), OS X, and other platforms where SO_REUSEPORTs don't
* Unix platforms, it sets the SO_REUSEADDR flag. What that means is that * have the capability of load balancing, as the opposite of what
* multiple threads or processes can bind to the same address without error * UV_UDP_REUSEPORT would do. On other Unix platforms, it sets the
* (provided they all set the flag) but only the last one to bind will receive * SO_REUSEADDR flag. What that means is that multiple threads or
* processes can bind to the same address without error (provided
* they all set the flag) but only the last one to bind will receive
* any traffic, in effect "stealing" the port from the previous listener. * any traffic, in effect "stealing" the port from the previous listener.
*/ */
UV_UDP_REUSEADDR = 4 UV_UDP_REUSEADDR = 4,
/* /*
* Indicates that the message was received by recvmmsg, so the buffer provided * Indicates that the message was received by recvmmsg, so the buffer provided
* must not be freed by the recv_cb callback. * must not be freed by the recv_cb callback.
*/ */
UV_UDP_MMSG_CHUNK = 8 UV_UDP_MMSG_CHUNK = 8,
/*
* Indicates that the buffer provided has been fully utilized by recvmmsg and
* that it should now be freed by the recv_cb callback. When this flag is set
* in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL.
*/
UV_UDP_MMSG_FREE = 16,
/*
* Indicates if IP_RECVERR/IPV6_RECVERR will be set when binding the handle.
* This sets IP_RECVERR for IPv4 and IPV6_RECVERR for IPv6 UDP sockets on
* Linux. This stops the Linux kernel from suppressing some ICMP error messages
* and enables full ICMP error reporting for faster failover.
* This flag is no-op on platforms other than Linux.
*/
UV_UDP_LINUX_RECVERR = 32,
/*
* Indicates if SO_REUSEPORT will be set when binding the handle.
* This sets the SO_REUSEPORT socket option on supported platforms.
* Unlike UV_UDP_REUSEADDR, this flag will make multiple threads or
* processes that are binding to the same address and port "share"
* the port, which means incoming datagrams are distributed across
* the receiving sockets among threads or processes.
*
* This flag is available only on Linux 3.9+, DragonFlyBSD 3.6+,
* FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ for now.
*/
UV_UDP_REUSEPORT = 64,
/*
* Indicates that recvmmsg should be used, if available.
*/
UV_UDP_RECVMMSG = 256
}; };
.. c:type:: void (*uv_udp_send_cb)(uv_udp_send_t* req, int status) .. c:type:: void (*uv_udp_send_cb)(uv_udp_send_t* req, int status)
@ -63,7 +95,8 @@ Data types
* `nread`: Number of bytes that have been received. * `nread`: Number of bytes that have been received.
0 if there is no more data to read. Note that 0 may also mean that an 0 if there is no more data to read. Note that 0 may also mean that an
empty datagram was received (in this case `addr` is not NULL). < 0 if empty datagram was received (in this case `addr` is not NULL). < 0 if
a transmission error was detected. a transmission error was detected; if using :man:`recvmmsg(2)` no more
chunks will be received and the buffer can be freed safely.
* `buf`: :c:type:`uv_buf_t` with the received data. * `buf`: :c:type:`uv_buf_t` with the received data.
* `addr`: ``struct sockaddr*`` containing the address of the sender. * `addr`: ``struct sockaddr*`` containing the address of the sender.
Can be NULL. Valid for the duration of the callback only. Can be NULL. Valid for the duration of the callback only.
@ -74,17 +107,20 @@ Data types
on error. on error.
When using :man:`recvmmsg(2)`, chunks will have the `UV_UDP_MMSG_CHUNK` flag set, When using :man:`recvmmsg(2)`, chunks will have the `UV_UDP_MMSG_CHUNK` flag set,
those must not be freed. There will be a final callback with `nread` set to 0, those must not be freed. If no errors occur, there will be a final callback with
`addr` set to NULL and the buffer pointing at the initially allocated data with `nread` set to 0, `addr` set to NULL and the buffer pointing at the initially
the `UV_UDP_MMSG_CHUNK` flag cleared. This is a good chance for the callee to allocated data with the `UV_UDP_MMSG_CHUNK` flag cleared and the `UV_UDP_MMSG_FREE`
free the provided buffer. flag set. If a UDP socket error occurs, `nread` will be < 0. In either scenario,
the callee can now safely free the provided buffer.
.. versionchanged:: 1.40.0 added the `UV_UDP_MMSG_FREE` flag.
.. note:: .. note::
The receive callback will be called with `nread` == 0 and `addr` == NULL when there is The receive callback will be called with `nread` == 0 and `addr` == NULL when there is
nothing to read, and with `nread` == 0 and `addr` != NULL when an empty UDP packet is nothing to read, and with `nread` == 0 and `addr` != NULL when an empty UDP packet is
received. received.
.. c:type:: uv_membership .. c:enum:: uv_membership
Membership type for a multicast address. Membership type for a multicast address.
@ -125,12 +161,17 @@ API
.. c:function:: int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) .. c:function:: int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags)
Initialize the handle with the specified flags. At the moment the lower 8 bits Initialize the handle with the specified flags. The lower 8 bits of the `flags`
of the `flags` parameter are used as the socket domain. A socket will be created parameter are used as the socket domain. A socket will be created for the given domain.
for the given domain. If the specified domain is ``AF_UNSPEC`` no socket is created, If the specified domain is ``AF_UNSPEC`` no socket is created, just like :c:func:`uv_udp_init`.
just like :c:func:`uv_udp_init`.
The remaining bits can be used to set one of these flags:
* `UV_UDP_RECVMMSG`: if set, and the platform supports it, :man:`recvmmsg(2)` will
be used.
.. versionadded:: 1.7.0 .. versionadded:: 1.7.0
.. versionchanged:: 1.37.0 added the `UV_UDP_RECVMMSG` flag.
.. c:function:: int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) .. c:function:: int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock)
@ -159,10 +200,24 @@ API
with the address and port to bind to. with the address and port to bind to.
:param flags: Indicate how the socket will be bound, :param flags: Indicate how the socket will be bound,
``UV_UDP_IPV6ONLY`` and ``UV_UDP_REUSEADDR`` are supported. ``UV_UDP_IPV6ONLY``, ``UV_UDP_REUSEADDR``, ``UV_UDP_REUSEPORT``,
and ``UV_UDP_RECVERR`` are supported.
:returns: 0 on success, or an error code < 0 on failure. :returns: 0 on success, or an error code < 0 on failure.
.. versionchanged:: 1.49.0 added the ``UV_UDP_REUSEPORT`` flag.
.. note::
``UV_UDP_REUSEPORT`` flag is available only on Linux 3.9+, DragonFlyBSD 3.6+,
FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ at the moment. On other platforms
this function will return an UV_ENOTSUP error.
For platforms where `SO_REUSEPORT`s have the capability of load balancing,
specifying both ``UV_UDP_REUSEADDR`` and ``UV_UDP_REUSEPORT`` in flags is allowed
and `SO_REUSEPORT` will always override the behavior of `SO_REUSEADDR`.
For platforms where `SO_REUSEPORT`s don't have the capability of load balancing,
specifying both ``UV_UDP_REUSEADDR`` and ``UV_UDP_REUSEPORT`` in flags will fail,
returning an UV_ENOTSUP error.
.. c:function:: int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr) .. c:function:: int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr)
Associate the UDP handle to a remote address and port, so every Associate the UDP handle to a remote address and port, so every
@ -257,7 +312,9 @@ API
local sockets. local sockets.
:param handle: UDP handle. Should have been initialized with :param handle: UDP handle. Should have been initialized with
:c:func:`uv_udp_init`. :c:func:`uv_udp_init_ex` as either ``AF_INET`` or ``AF_INET6``, or have
been bound to an address explicitly with :c:func:`uv_udp_bind`, or
implicitly with :c:func:`uv_udp_send()` or :c:func:`uv_udp_recv_start`.
:param on: 1 for on, 0 for off. :param on: 1 for on, 0 for off.
@ -268,7 +325,9 @@ API
Set the multicast ttl. Set the multicast ttl.
:param handle: UDP handle. Should have been initialized with :param handle: UDP handle. Should have been initialized with
:c:func:`uv_udp_init`. :c:func:`uv_udp_init_ex` as either ``AF_INET`` or ``AF_INET6``, or have
been bound to an address explicitly with :c:func:`uv_udp_bind`, or
implicitly with :c:func:`uv_udp_send()` or :c:func:`uv_udp_recv_start`.
:param ttl: 1 through 255. :param ttl: 1 through 255.
@ -279,7 +338,9 @@ API
Set the multicast interface to send or receive data on. Set the multicast interface to send or receive data on.
:param handle: UDP handle. Should have been initialized with :param handle: UDP handle. Should have been initialized with
:c:func:`uv_udp_init`. :c:func:`uv_udp_init_ex` as either ``AF_INET`` or ``AF_INET6``, or have
been bound to an address explicitly with :c:func:`uv_udp_bind`, or
implicitly with :c:func:`uv_udp_send()` or :c:func:`uv_udp_recv_start`.
:param interface_addr: interface address. :param interface_addr: interface address.
@ -290,7 +351,9 @@ API
Set broadcast on or off. Set broadcast on or off.
:param handle: UDP handle. Should have been initialized with :param handle: UDP handle. Should have been initialized with
:c:func:`uv_udp_init`. :c:func:`uv_udp_init_ex` as either ``AF_INET`` or ``AF_INET6``, or have
been bound to an address explicitly with :c:func:`uv_udp_bind`, or
implicitly with :c:func:`uv_udp_send()` or :c:func:`uv_udp_recv_start`.
:param on: 1 for on, 0 for off. :param on: 1 for on, 0 for off.
@ -301,7 +364,9 @@ API
Set the time to live. Set the time to live.
:param handle: UDP handle. Should have been initialized with :param handle: UDP handle. Should have been initialized with
:c:func:`uv_udp_init`. :c:func:`uv_udp_init_ex` as either ``AF_INET`` or ``AF_INET6``, or have
been bound to an address explicitly with :c:func:`uv_udp_bind`, or
implicitly with :c:func:`uv_udp_send()` or :c:func:`uv_udp_recv_start`.
:param ttl: 1 through 255. :param ttl: 1 through 255.
@ -361,6 +426,20 @@ API
.. versionchanged:: 1.27.0 added support for connected sockets .. versionchanged:: 1.27.0 added support for connected sockets
.. c:function:: int uv_udp_try_send2(uv_udp_t* handle, unsigned int count, uv_buf_t* bufs[/*count*/], unsigned int nbufs[/*count*/], struct sockaddr* addrs[/*count*/], unsigned int flags)
Like :c:func:`uv_udp_try_send`, but can send multiple datagrams.
Lightweight abstraction around :man:`sendmmsg(2)`, with a :man:`sendmsg(2)`
fallback loop for platforms that do not support the former. The handle must
be fully initialized; call c:func:`uv_udp_bind` first.
:returns: >= 0: number of datagrams sent. Zero only if `count` was zero.
< 0: negative error code. Only if sending the first datagram fails,
otherwise returns a positive send count. ``UV_EAGAIN`` when datagrams
cannot be sent right now; fall back to :c:func:`uv_udp_send`.
.. versionadded:: 1.50.0
.. c:function:: int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb) .. c:function:: int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb)
Prepare for receiving data. If the socket has not previously been bound Prepare for receiving data. If the socket has not previously been bound
@ -376,9 +455,27 @@ API
:returns: 0 on success, or an error code < 0 on failure. :returns: 0 on success, or an error code < 0 on failure.
.. note::
When using :man:`recvmmsg(2)`, the number of messages received at a time is limited
by the number of max size dgrams that will fit into the buffer allocated in `alloc_cb`, and
`suggested_size` in `alloc_cb` for udp_recv is always set to the size of 1 max size dgram.
.. versionchanged:: 1.35.0 added support for :man:`recvmmsg(2)` on supported platforms). .. versionchanged:: 1.35.0 added support for :man:`recvmmsg(2)` on supported platforms).
The use of this feature requires a buffer larger than The use of this feature requires a buffer larger than
2 * 64KB to be passed to `alloc_cb`. 2 * 64KB to be passed to `alloc_cb`.
.. versionchanged:: 1.37.0 :man:`recvmmsg(2)` support is no longer enabled implicitly,
it must be explicitly requested by passing the `UV_UDP_RECVMMSG` flag to
:c:func:`uv_udp_init_ex`.
.. versionchanged:: 1.39.0 :c:func:`uv_udp_using_recvmmsg` can be used in `alloc_cb` to
determine if a buffer sized for use with :man:`recvmmsg(2)` should be
allocated for the current handle/platform.
.. c:function:: int uv_udp_using_recvmmsg(uv_udp_t* handle)
Returns 1 if the UDP handle was created with the `UV_UDP_RECVMMSG` flag
and the platform supports :man:`recvmmsg(2)`, 0 otherwise.
.. versionadded:: 1.39.0
.. c:function:: int uv_udp_recv_stop(uv_udp_t* handle) .. c:function:: int uv_udp_recv_stop(uv_udp_t* handle)

View File

@ -31,6 +31,7 @@ extern "C" {
#error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." #error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both."
#endif #endif
#ifndef UV_EXTERN
#ifdef _WIN32 #ifdef _WIN32
/* Windows - set up dll import/export decorators. */ /* Windows - set up dll import/export decorators. */
# if defined(BUILDING_UV_SHARED) # if defined(BUILDING_UV_SHARED)
@ -45,20 +46,25 @@ extern "C" {
# endif # endif
#elif __GNUC__ >= 4 #elif __GNUC__ >= 4
# define UV_EXTERN __attribute__((visibility("default"))) # define UV_EXTERN __attribute__((visibility("default")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) /* Sun Studio >= 8 */
# define UV_EXTERN __global
#else #else
# define UV_EXTERN /* nothing */ # define UV_EXTERN /* nothing */
#endif #endif
#endif /* UV_EXTERN */
#include "uv/errno.h" #include "uv/errno.h"
#include "uv/version.h" #include "uv/version.h"
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
# include "uv/stdint-msvc2008.h"
#else
#include <stdint.h> #include <stdint.h>
#endif #include <math.h>
/* Internal type, do not use. */
struct uv__queue {
struct uv__queue* next;
struct uv__queue* prev;
};
#if defined(_WIN32) #if defined(_WIN32)
# include "uv/win.h" # include "uv/win.h"
@ -126,6 +132,7 @@ extern "C" {
XX(ENOTEMPTY, "directory not empty") \ XX(ENOTEMPTY, "directory not empty") \
XX(ENOTSOCK, "socket operation on non-socket") \ XX(ENOTSOCK, "socket operation on non-socket") \
XX(ENOTSUP, "operation not supported on socket") \ XX(ENOTSUP, "operation not supported on socket") \
XX(EOVERFLOW, "value too large for defined data type") \
XX(EPERM, "operation not permitted") \ XX(EPERM, "operation not permitted") \
XX(EPIPE, "broken pipe") \ XX(EPIPE, "broken pipe") \
XX(EPROTO, "protocol error") \ XX(EPROTO, "protocol error") \
@ -148,6 +155,10 @@ extern "C" {
XX(ENOTTY, "inappropriate ioctl for device") \ XX(ENOTTY, "inappropriate ioctl for device") \
XX(EFTYPE, "inappropriate file type or format") \ XX(EFTYPE, "inappropriate file type or format") \
XX(EILSEQ, "illegal byte sequence") \ XX(EILSEQ, "illegal byte sequence") \
XX(ESOCKTNOSUPPORT, "socket type not supported") \
XX(ENODATA, "no data available") \
XX(EUNATCH, "protocol driver not attached") \
XX(ENOEXEC, "exec format error") \
#define UV_HANDLE_TYPE_MAP(XX) \ #define UV_HANDLE_TYPE_MAP(XX) \
XX(ASYNC, async) \ XX(ASYNC, async) \
@ -243,11 +254,17 @@ typedef struct uv_cpu_info_s uv_cpu_info_t;
typedef struct uv_interface_address_s uv_interface_address_t; typedef struct uv_interface_address_s uv_interface_address_t;
typedef struct uv_dirent_s uv_dirent_t; typedef struct uv_dirent_s uv_dirent_t;
typedef struct uv_passwd_s uv_passwd_t; typedef struct uv_passwd_s uv_passwd_t;
typedef struct uv_group_s uv_group_t;
typedef struct uv_utsname_s uv_utsname_t; typedef struct uv_utsname_s uv_utsname_t;
typedef struct uv_statfs_s uv_statfs_t; typedef struct uv_statfs_s uv_statfs_t;
typedef struct uv_metrics_s uv_metrics_t;
typedef enum { typedef enum {
UV_LOOP_BLOCK_SIGNAL UV_LOOP_BLOCK_SIGNAL = 0,
UV_METRICS_IDLE_TIME,
UV_LOOP_USE_IO_URING_SQPOLL
#define UV_LOOP_USE_IO_URING_SQPOLL UV_LOOP_USE_IO_URING_SQPOLL
} uv_loop_option; } uv_loop_option;
typedef enum { typedef enum {
@ -265,6 +282,8 @@ typedef void* (*uv_realloc_func)(void* ptr, size_t size);
typedef void* (*uv_calloc_func)(size_t count, size_t size); typedef void* (*uv_calloc_func)(size_t count, size_t size);
typedef void (*uv_free_func)(void* ptr); typedef void (*uv_free_func)(void* ptr);
UV_EXTERN void uv_library_shutdown(void);
UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func,
uv_realloc_func realloc_func, uv_realloc_func realloc_func,
uv_calloc_func calloc_func, uv_calloc_func calloc_func,
@ -275,13 +294,13 @@ UV_EXTERN int uv_loop_init(uv_loop_t* loop);
UV_EXTERN int uv_loop_close(uv_loop_t* loop); UV_EXTERN int uv_loop_close(uv_loop_t* loop);
/* /*
* NOTE: * NOTE:
* This function is DEPRECATED (to be removed after 0.12), users should * This function is DEPRECATED, users should
* allocate the loop manually and use uv_loop_init instead. * allocate the loop manually and use uv_loop_init instead.
*/ */
UV_EXTERN uv_loop_t* uv_loop_new(void); UV_EXTERN uv_loop_t* uv_loop_new(void);
/* /*
* NOTE: * NOTE:
* This function is DEPRECATED (to be removed after 0.12). Users should use * This function is DEPRECATED. Users should use
* uv_loop_close and free the memory manually instead. * uv_loop_close and free the memory manually instead.
*/ */
UV_EXTERN void uv_loop_delete(uv_loop_t*); UV_EXTERN void uv_loop_delete(uv_loop_t*);
@ -337,11 +356,32 @@ typedef void (*uv_random_cb)(uv_random_t* req,
void* buf, void* buf,
size_t buflen); size_t buflen);
typedef enum {
UV_CLOCK_MONOTONIC,
UV_CLOCK_REALTIME
} uv_clock_id;
/* XXX(bnoordhuis) not 2038-proof, https://github.com/libuv/libuv/issues/3864 */
typedef struct { typedef struct {
long tv_sec; long tv_sec;
long tv_nsec; long tv_nsec;
} uv_timespec_t; } uv_timespec_t;
typedef struct {
int64_t tv_sec;
int32_t tv_nsec;
} uv_timespec64_t;
/* XXX(bnoordhuis) not 2038-proof, https://github.com/libuv/libuv/issues/3864 */
typedef struct {
long tv_sec;
long tv_usec;
} uv_timeval_t;
typedef struct {
int64_t tv_sec;
int32_t tv_usec;
} uv_timeval64_t;
typedef struct { typedef struct {
uint64_t st_dev; uint64_t st_dev;
@ -430,7 +470,7 @@ struct uv_shutdown_s {
uv_handle_type type; \ uv_handle_type type; \
/* private */ \ /* private */ \
uv_close_cb close_cb; \ uv_close_cb close_cb; \
void* handle_queue[2]; \ struct uv__queue handle_queue; \
union { \ union { \
int fd; \ int fd; \
void* reserved[4]; \ void* reserved[4]; \
@ -472,6 +512,12 @@ UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd);
UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len);
UV_EXTERN int uv_pipe(uv_file fds[2], int read_flags, int write_flags);
UV_EXTERN int uv_socketpair(int type,
int protocol,
uv_os_sock_t socket_vector[2],
int flags0,
int flags1);
#define UV_STREAM_FIELDS \ #define UV_STREAM_FIELDS \
/* number of bytes queued for writing */ \ /* number of bytes queued for writing */ \
@ -517,6 +563,10 @@ UV_EXTERN int uv_write2(uv_write_t* req,
UV_EXTERN int uv_try_write(uv_stream_t* handle, UV_EXTERN int uv_try_write(uv_stream_t* handle,
const uv_buf_t bufs[], const uv_buf_t bufs[],
unsigned int nbufs); unsigned int nbufs);
UV_EXTERN int uv_try_write2(uv_stream_t* handle,
const uv_buf_t bufs[],
unsigned int nbufs,
uv_stream_t* send_handle);
/* uv_write_t is a subclass of uv_req_t. */ /* uv_write_t is a subclass of uv_req_t. */
struct uv_write_s { struct uv_write_s {
@ -558,7 +608,18 @@ UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable);
enum uv_tcp_flags { enum uv_tcp_flags {
/* Used with uv_tcp_bind, when an IPv6 address is used. */ /* Used with uv_tcp_bind, when an IPv6 address is used. */
UV_TCP_IPV6ONLY = 1 UV_TCP_IPV6ONLY = 1,
/* Enable SO_REUSEPORT socket option when binding the handle.
* This allows completely duplicate bindings by multiple processes
* or threads if they all set SO_REUSEPORT before binding the port.
* Incoming connections are distributed across the participating
* listener sockets.
*
* This flag is available only on Linux 3.9+, DragonFlyBSD 3.6+,
* FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ for now.
*/
UV_TCP_REUSEPORT = 2,
}; };
UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle,
@ -599,10 +660,13 @@ enum uv_udp_flags {
UV_UDP_PARTIAL = 2, UV_UDP_PARTIAL = 2,
/* /*
* Indicates if SO_REUSEADDR will be set when binding the handle. * Indicates if SO_REUSEADDR will be set when binding the handle.
* This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other * This sets the SO_REUSEPORT socket flag on the BSDs (except for
* Unix platforms, it sets the SO_REUSEADDR flag. What that means is that * DragonFlyBSD), OS X, and other platforms where SO_REUSEPORTs don't
* multiple threads or processes can bind to the same address without error * have the capability of load balancing, as the opposite of what
* (provided they all set the flag) but only the last one to bind will receive * UV_UDP_REUSEPORT would do. On other Unix platforms, it sets the
* SO_REUSEADDR flag. What that means is that multiple threads or
* processes can bind to the same address without error (provided
* they all set the flag) but only the last one to bind will receive
* any traffic, in effect "stealing" the port from the previous listener. * any traffic, in effect "stealing" the port from the previous listener.
*/ */
UV_UDP_REUSEADDR = 4, UV_UDP_REUSEADDR = 4,
@ -610,7 +674,37 @@ enum uv_udp_flags {
* Indicates that the message was received by recvmmsg, so the buffer provided * Indicates that the message was received by recvmmsg, so the buffer provided
* must not be freed by the recv_cb callback. * must not be freed by the recv_cb callback.
*/ */
UV_UDP_MMSG_CHUNK = 8 UV_UDP_MMSG_CHUNK = 8,
/*
* Indicates that the buffer provided has been fully utilized by recvmmsg and
* that it should now be freed by the recv_cb callback. When this flag is set
* in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL.
*/
UV_UDP_MMSG_FREE = 16,
/*
* Indicates if IP_RECVERR/IPV6_RECVERR will be set when binding the handle.
* This sets IP_RECVERR for IPv4 and IPV6_RECVERR for IPv6 UDP sockets on
* Linux. This stops the Linux kernel from suppressing some ICMP error
* messages and enables full ICMP error reporting for faster failover.
* This flag is no-op on platforms other than Linux.
*/
UV_UDP_LINUX_RECVERR = 32,
/*
* Indicates if SO_REUSEPORT will be set when binding the handle.
* This sets the SO_REUSEPORT socket option on supported platforms.
* Unlike UV_UDP_REUSEADDR, this flag will make multiple threads or
* processes that are binding to the same address and port "share"
* the port, which means incoming datagrams are distributed across
* the receiving sockets among threads or processes.
*
* This flag is available only on Linux 3.9+, DragonFlyBSD 3.6+,
* FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ for now.
*/
UV_UDP_REUSEPORT = 64,
/*
* Indicates that recvmmsg should be used, if available.
*/
UV_UDP_RECVMMSG = 256
}; };
typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status);
@ -683,9 +777,16 @@ UV_EXTERN int uv_udp_try_send(uv_udp_t* handle,
const uv_buf_t bufs[], const uv_buf_t bufs[],
unsigned int nbufs, unsigned int nbufs,
const struct sockaddr* addr); const struct sockaddr* addr);
UV_EXTERN int uv_udp_try_send2(uv_udp_t* handle,
unsigned int count,
uv_buf_t* bufs[/*count*/],
unsigned int nbufs[/*count*/],
struct sockaddr* addrs[/*count*/],
unsigned int flags);
UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle,
uv_alloc_cb alloc_cb, uv_alloc_cb alloc_cb,
uv_udp_recv_cb recv_cb); uv_udp_recv_cb recv_cb);
UV_EXTERN int uv_udp_using_recvmmsg(const uv_udp_t* handle);
UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle);
UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle); UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle);
UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle); UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle);
@ -705,10 +806,15 @@ struct uv_tty_s {
typedef enum { typedef enum {
/* Initial/normal terminal mode */ /* Initial/normal terminal mode */
UV_TTY_MODE_NORMAL, UV_TTY_MODE_NORMAL,
/* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ /*
* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled).
* May become equivalent to UV_TTY_MODE_RAW_VT in future libuv versions.
*/
UV_TTY_MODE_RAW, UV_TTY_MODE_RAW,
/* Binary-safe I/O mode for IPC (Unix-only) */ /* Binary-safe I/O mode for IPC (Unix-only) */
UV_TTY_MODE_IO UV_TTY_MODE_IO,
/* Raw input mode. On Windows ENABLE_VIRTUAL_TERMINAL_INPUT is also set. */
UV_TTY_MODE_RAW_VT
} uv_tty_mode_t; } uv_tty_mode_t;
typedef enum { typedef enum {
@ -743,6 +849,10 @@ inline int uv_tty_set_mode(uv_tty_t* handle, int mode) {
UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); UV_EXTERN uv_handle_type uv_guess_handle(uv_file file);
enum {
UV_PIPE_NO_TRUNCATE = 1u << 0
};
/* /*
* uv_pipe_t is a subclass of uv_stream_t. * uv_pipe_t is a subclass of uv_stream_t.
* *
@ -759,10 +869,20 @@ struct uv_pipe_s {
UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file);
UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);
UV_EXTERN int uv_pipe_bind2(uv_pipe_t* handle,
const char* name,
size_t namelen,
unsigned int flags);
UV_EXTERN void uv_pipe_connect(uv_connect_t* req, UV_EXTERN void uv_pipe_connect(uv_connect_t* req,
uv_pipe_t* handle, uv_pipe_t* handle,
const char* name, const char* name,
uv_connect_cb cb); uv_connect_cb cb);
UV_EXTERN int uv_pipe_connect2(uv_connect_t* req,
uv_pipe_t* handle,
const char* name,
size_t namelen,
unsigned int flags,
uv_connect_cb cb);
UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle,
char* buffer, char* buffer,
size_t* size); size_t* size);
@ -856,6 +976,7 @@ UV_EXTERN int uv_timer_stop(uv_timer_t* handle);
UV_EXTERN int uv_timer_again(uv_timer_t* handle); UV_EXTERN int uv_timer_again(uv_timer_t* handle);
UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat);
UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle);
UV_EXTERN uint64_t uv_timer_get_due_in(const uv_timer_t* handle);
/* /*
@ -917,10 +1038,13 @@ typedef enum {
UV_WRITABLE_PIPE = 0x20, UV_WRITABLE_PIPE = 0x20,
/* /*
* Open the child pipe handle in overlapped mode on Windows. * When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the
* On Unix it is silently ignored. * handle in non-blocking mode in the child. This may cause loss of data,
* if the child is not designed to handle to encounter this mode,
* but can also be significantly more efficient.
*/ */
UV_OVERLAPPED_PIPE = 0x40 UV_NONBLOCK_PIPE = 0x40,
UV_OVERLAPPED_PIPE = 0x40 /* old name, for compatibility */
} uv_stdio_flags; } uv_stdio_flags;
typedef struct uv_stdio_container_s { typedef struct uv_stdio_container_s {
@ -1023,7 +1147,14 @@ enum uv_process_flags {
* option is only meaningful on Windows systems. On Unix it is silently * option is only meaningful on Windows systems. On Unix it is silently
* ignored. * ignored.
*/ */
UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6) UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6),
/*
* On Windows, if the path to the program to execute, specified in
* uv_process_options_t's file field, has a directory component,
* search for the exact file name before trying variants with
* extensions like '.exe' or '.cmd'.
*/
UV_PROCESS_WINDOWS_FILE_PATH_EXACT_NAME = (1 << 7)
}; };
/* /*
@ -1064,11 +1195,11 @@ UV_EXTERN int uv_cancel(uv_req_t* req);
struct uv_cpu_times_s { struct uv_cpu_times_s {
uint64_t user; uint64_t user; /* milliseconds */
uint64_t nice; uint64_t nice; /* milliseconds */
uint64_t sys; uint64_t sys; /* milliseconds */
uint64_t idle; uint64_t idle; /* milliseconds */
uint64_t irq; uint64_t irq; /* milliseconds */
}; };
struct uv_cpu_info_s { struct uv_cpu_info_s {
@ -1093,12 +1224,18 @@ struct uv_interface_address_s {
struct uv_passwd_s { struct uv_passwd_s {
char* username; char* username;
long uid; unsigned long uid;
long gid; unsigned long gid;
char* shell; char* shell;
char* homedir; char* homedir;
}; };
struct uv_group_s {
char* groupname;
unsigned long gid;
char** members;
};
struct uv_utsname_s { struct uv_utsname_s {
char sysname[256]; char sysname[256];
char release[256]; char release[256];
@ -1144,16 +1281,6 @@ UV_EXTERN int uv_uptime(double* uptime);
UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd);
UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd); UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd);
typedef struct {
long tv_sec;
long tv_usec;
} uv_timeval_t;
typedef struct {
int64_t tv_sec;
int32_t tv_usec;
} uv_timeval64_t;
typedef struct { typedef struct {
uv_timeval_t ru_utime; /* user CPU time used */ uv_timeval_t ru_utime; /* user CPU time used */
uv_timeval_t ru_stime; /* system CPU time used */ uv_timeval_t ru_stime; /* system CPU time used */
@ -1174,22 +1301,26 @@ typedef struct {
} uv_rusage_t; } uv_rusage_t;
UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); UV_EXTERN int uv_getrusage(uv_rusage_t* rusage);
UV_EXTERN int uv_getrusage_thread(uv_rusage_t* rusage);
UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); UV_EXTERN int uv_os_homedir(char* buffer, size_t* size);
UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size);
UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd);
UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd);
UV_EXTERN int uv_os_get_passwd2(uv_passwd_t* pwd, uv_uid_t uid);
UV_EXTERN int uv_os_get_group(uv_group_t* grp, uv_uid_t gid);
UV_EXTERN void uv_os_free_group(uv_group_t* grp);
UV_EXTERN uv_pid_t uv_os_getpid(void); UV_EXTERN uv_pid_t uv_os_getpid(void);
UV_EXTERN uv_pid_t uv_os_getppid(void); UV_EXTERN uv_pid_t uv_os_getppid(void);
#if defined(__PASE__) #if defined(__PASE__)
/* On IBM i PASE, the highest process priority is -10 */ /* On IBM i PASE, the highest process priority is -10 */
# define UV_PRIORITY_LOW 39 // RUNPTY(99) # define UV_PRIORITY_LOW 39 /* RUNPTY(99) */
# define UV_PRIORITY_BELOW_NORMAL 15 // RUNPTY(50) # define UV_PRIORITY_BELOW_NORMAL 15 /* RUNPTY(50) */
# define UV_PRIORITY_NORMAL 0 // RUNPTY(20) # define UV_PRIORITY_NORMAL 0 /* RUNPTY(20) */
# define UV_PRIORITY_ABOVE_NORMAL -4 // RUNTY(12) # define UV_PRIORITY_ABOVE_NORMAL -4 /* RUNTY(12) */
# define UV_PRIORITY_HIGH -7 // RUNPTY(6) # define UV_PRIORITY_HIGH -7 /* RUNPTY(6) */
# define UV_PRIORITY_HIGHEST -10 // RUNPTY(1) # define UV_PRIORITY_HIGHEST -10 /* RUNPTY(1) */
#else #else
# define UV_PRIORITY_LOW 19 # define UV_PRIORITY_LOW 19
# define UV_PRIORITY_BELOW_NORMAL 10 # define UV_PRIORITY_BELOW_NORMAL 10
@ -1202,8 +1333,21 @@ UV_EXTERN uv_pid_t uv_os_getppid(void);
UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority); UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority);
UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority); UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority);
enum {
UV_THREAD_PRIORITY_HIGHEST = 2,
UV_THREAD_PRIORITY_ABOVE_NORMAL = 1,
UV_THREAD_PRIORITY_NORMAL = 0,
UV_THREAD_PRIORITY_BELOW_NORMAL = -1,
UV_THREAD_PRIORITY_LOWEST = -2,
};
UV_EXTERN int uv_thread_getpriority(uv_thread_t tid, int* priority);
UV_EXTERN int uv_thread_setpriority(uv_thread_t tid, int priority);
UV_EXTERN unsigned int uv_available_parallelism(void);
UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count);
UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count);
UV_EXTERN int uv_cpumask_size(void);
UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses,
int* count); int* count);
@ -1236,6 +1380,16 @@ UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size);
UV_EXTERN int uv_os_uname(uv_utsname_t* buffer); UV_EXTERN int uv_os_uname(uv_utsname_t* buffer);
struct uv_metrics_s {
uint64_t loop_count;
uint64_t events;
uint64_t events_waiting;
/* private */
uint64_t* reserved[13];
};
UV_EXTERN int uv_metrics_info(uv_loop_t* loop, uv_metrics_t* metrics);
UV_EXTERN uint64_t uv_metrics_idle_time(uv_loop_t* loop);
typedef enum { typedef enum {
UV_FS_UNKNOWN = -1, UV_FS_UNKNOWN = -1,
@ -1300,6 +1454,7 @@ struct uv_fs_s {
UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*); UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*);
UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*); UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*);
UV_EXTERN int uv_fs_get_system_error(const uv_fs_t*);
UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*); UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*);
UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*); UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*);
UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*); UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*);
@ -1436,6 +1591,8 @@ UV_EXTERN int uv_fs_chmod(uv_loop_t* loop,
const char* path, const char* path,
int mode, int mode,
uv_fs_cb cb); uv_fs_cb cb);
#define UV_FS_UTIME_NOW (INFINITY)
#define UV_FS_UTIME_OMIT (NAN)
UV_EXTERN int uv_fs_utime(uv_loop_t* loop, UV_EXTERN int uv_fs_utime(uv_loop_t* loop,
uv_fs_t* req, uv_fs_t* req,
const char* path, const char* path,
@ -1618,6 +1775,7 @@ UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr);
UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size);
UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size);
UV_EXTERN int uv_ip_name(const struct sockaddr* src, char* dst, size_t size);
UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size);
UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst);
@ -1666,7 +1824,9 @@ UV_EXTERN int uv_chdir(const char* dir);
UV_EXTERN uint64_t uv_get_free_memory(void); UV_EXTERN uint64_t uv_get_free_memory(void);
UV_EXTERN uint64_t uv_get_total_memory(void); UV_EXTERN uint64_t uv_get_total_memory(void);
UV_EXTERN uint64_t uv_get_constrained_memory(void); UV_EXTERN uint64_t uv_get_constrained_memory(void);
UV_EXTERN uint64_t uv_get_available_memory(void);
UV_EXTERN int uv_clock_gettime(uv_clock_id clock_id, uv_timespec64_t* ts);
UV_EXTERN uint64_t uv_hrtime(void); UV_EXTERN uint64_t uv_hrtime(void);
UV_EXTERN void uv_sleep(unsigned int msec); UV_EXTERN void uv_sleep(unsigned int msec);
@ -1725,6 +1885,7 @@ UV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv);
typedef void (*uv_thread_cb)(void* arg); typedef void (*uv_thread_cb)(void* arg);
UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);
UV_EXTERN int uv_thread_detach(uv_thread_t* tid);
typedef enum { typedef enum {
UV_THREAD_NO_FLAGS = 0x00, UV_THREAD_NO_FLAGS = 0x00,
@ -1743,9 +1904,20 @@ UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid,
const uv_thread_options_t* params, const uv_thread_options_t* params,
uv_thread_cb entry, uv_thread_cb entry,
void* arg); void* arg);
UV_EXTERN int uv_thread_setaffinity(uv_thread_t* tid,
char* cpumask,
char* oldmask,
size_t mask_size);
UV_EXTERN int uv_thread_getaffinity(uv_thread_t* tid,
char* cpumask,
size_t mask_size);
UV_EXTERN int uv_thread_getcpu(void);
UV_EXTERN uv_thread_t uv_thread_self(void); UV_EXTERN uv_thread_t uv_thread_self(void);
UV_EXTERN int uv_thread_join(uv_thread_t *tid); UV_EXTERN int uv_thread_join(uv_thread_t *tid);
UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2);
UV_EXTERN int uv_thread_setname(const char* name);
UV_EXTERN int uv_thread_getname(uv_thread_t* tid, char* name, size_t size);
/* The presence of these unions force similar struct layout. */ /* The presence of these unions force similar struct layout. */
#define XX(_, name) uv_ ## name ## _t name; #define XX(_, name) uv_ ## name ## _t name;
@ -1764,11 +1936,13 @@ struct uv_loop_s {
void* data; void* data;
/* Loop reference counting. */ /* Loop reference counting. */
unsigned int active_handles; unsigned int active_handles;
void* handle_queue[2]; struct uv__queue handle_queue;
union { union {
void* unused[2]; void* unused;
unsigned int count; unsigned int count;
} active_reqs; } active_reqs;
/* Internal storage for future extensions. */
void* internal_fields;
/* Internal flag to signal loop stop. */ /* Internal flag to signal loop stop. */
unsigned int stop_flag; unsigned int stop_flag;
UV_LOOP_PRIVATE_FIELDS UV_LOOP_PRIVATE_FIELDS
@ -1777,6 +1951,18 @@ struct uv_loop_s {
UV_EXTERN void* uv_loop_get_data(const uv_loop_t*); UV_EXTERN void* uv_loop_get_data(const uv_loop_t*);
UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data);
/* Unicode utilities needed for dealing with Windows. */
UV_EXTERN size_t uv_utf16_length_as_wtf8(const uint16_t* utf16,
ssize_t utf16_len);
UV_EXTERN int uv_utf16_to_wtf8(const uint16_t* utf16,
ssize_t utf16_len,
char** wtf8_ptr,
size_t* wtf8_len_ptr);
UV_EXTERN ssize_t uv_wtf8_length_as_utf16(const char* wtf8);
UV_EXTERN void uv_wtf8_to_utf16(const char* wtf8,
uint16_t* utf16,
size_t utf16_len);
/* Don't export the private CPP symbols. */ /* Don't export the private CPP symbols. */
#undef UV_HANDLE_TYPE_PRIVATE #undef UV_HANDLE_TYPE_PRIVATE
#undef UV_REQ_TYPE_PRIVATE #undef UV_REQ_TYPE_PRIVATE

View File

@ -1,54 +0,0 @@
/*
* Copyright (c) 1995, 1999
* Berkeley Software Design, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp
*/
#ifndef _IFADDRS_H_
#define _IFADDRS_H_
struct ifaddrs {
struct ifaddrs *ifa_next;
char *ifa_name;
unsigned int ifa_flags;
struct sockaddr *ifa_addr;
struct sockaddr *ifa_netmask;
struct sockaddr *ifa_dstaddr;
void *ifa_data;
};
/*
* This may have been defined in <net/if.h>. Note that if <net/if.h> is
* to be included it must be included before this header file.
*/
#ifndef ifa_broadaddr
#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
#endif
#include <sys/cdefs.h>
__BEGIN_DECLS
extern int getifaddrs(struct ifaddrs **ifap);
extern void freeifaddrs(struct ifaddrs *ifa);
__END_DECLS
#endif

View File

@ -40,7 +40,7 @@
void* cf_state; \ void* cf_state; \
uv_mutex_t cf_mutex; \ uv_mutex_t cf_mutex; \
uv_sem_t cf_sem; \ uv_sem_t cf_sem; \
void* cf_signals[2]; \ struct uv__queue cf_signals; \
#define UV_PLATFORM_FS_EVENT_FIELDS \ #define UV_PLATFORM_FS_EVENT_FIELDS \
uv__io_t event_watcher; \ uv__io_t event_watcher; \
@ -48,8 +48,8 @@
int realpath_len; \ int realpath_len; \
int cf_flags; \ int cf_flags; \
uv_async_t* cf_cb; \ uv_async_t* cf_cb; \
void* cf_events[2]; \ struct uv__queue cf_events; \
void* cf_member[2]; \ struct uv__queue cf_member; \
int cf_error; \ int cf_error; \
uv_mutex_t cf_mutex; \ uv_mutex_t cf_mutex; \

View File

@ -317,7 +317,7 @@
#if defined(EPROTO) && !defined(_WIN32) #if defined(EPROTO) && !defined(_WIN32)
# define UV__EPROTO UV__ERR(EPROTO) # define UV__EPROTO UV__ERR(EPROTO)
#else #else
# define UV__EPROTO UV__ERR(4046) # define UV__EPROTO (-4046)
#endif #endif
#if defined(EPROTONOSUPPORT) && !defined(_WIN32) #if defined(EPROTONOSUPPORT) && !defined(_WIN32)
@ -413,7 +413,6 @@
#elif defined(__APPLE__) || \ #elif defined(__APPLE__) || \
defined(__DragonFly__) || \ defined(__DragonFly__) || \
defined(__FreeBSD__) || \ defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || \
defined(__NetBSD__) || \ defined(__NetBSD__) || \
defined(__OpenBSD__) defined(__OpenBSD__)
# define UV__EHOSTDOWN (-64) # define UV__EHOSTDOWN (-64)
@ -445,4 +444,40 @@
# define UV__EILSEQ (-4027) # define UV__EILSEQ (-4027)
#endif #endif
#if defined(EOVERFLOW) && !defined(_WIN32)
# define UV__EOVERFLOW UV__ERR(EOVERFLOW)
#else
# define UV__EOVERFLOW (-4026)
#endif
#if defined(ESOCKTNOSUPPORT) && !defined(_WIN32)
# define UV__ESOCKTNOSUPPORT UV__ERR(ESOCKTNOSUPPORT)
#else
# define UV__ESOCKTNOSUPPORT (-4025)
#endif
/* FreeBSD defines ENODATA in /usr/include/c++/v1/errno.h which is only visible
* if C++ is being used. Define it directly to avoid problems when integrating
* libuv in a C++ project.
*/
#if defined(ENODATA) && !defined(_WIN32)
# define UV__ENODATA UV__ERR(ENODATA)
#elif defined(__FreeBSD__)
# define UV__ENODATA (-9919)
#else
# define UV__ENODATA (-4024)
#endif
#if defined(EUNATCH) && !defined(_WIN32)
# define UV__EUNATCH UV__ERR(EUNATCH)
#else
# define UV__EUNATCH (-4023)
#endif
#if defined(ENOEXEC) && !defined(_WIN32)
# define UV__ENOEXEC UV__ERR(ENOEXEC)
#else
# define UV__ENOEXEC (-4022)
#endif
#endif /* UV_ERRNO_H_ */ #endif /* UV_ERRNO_H_ */

View File

@ -28,7 +28,7 @@
int inotify_fd; \ int inotify_fd; \
#define UV_PLATFORM_FS_EVENT_FIELDS \ #define UV_PLATFORM_FS_EVENT_FIELDS \
void* watchers[2]; \ struct uv__queue watchers; \
int wd; \ int wd; \
#endif /* UV_LINUX_H */ #endif /* UV_LINUX_H */

View File

@ -1,247 +0,0 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006-2008 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include <limits.h>
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#ifdef __cplusplus
extern "C" {
#endif
# include <wchar.h>
#ifdef __cplusplus
}
#endif
// Define _W64 macros to mark types changing their size, like intptr_t.
#ifndef _W64
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
#endif
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
// realize that, e.g. char has the same size as __int8
// so we give up on __intX for them.
#if (_MSC_VER < 1300)
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#else
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#endif
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
// 7.18.1.2 Minimum-width integer types
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
// 7.18.1.3 Fastest minimum-width integer types
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
// 7.18.1.4 Integer types capable of holding object pointers
#ifdef _WIN64 // [
typedef signed __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else // _WIN64 ][
typedef _W64 signed int intptr_t;
typedef _W64 unsigned int uintptr_t;
#endif // _WIN64 ]
// 7.18.1.5 Greatest-width integer types
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
// 7.18.2 Limits of specified-width integer types
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
#define INT16_MAX _I16_MAX
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX _I32_MAX
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX _I64_MAX
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
// 7.18.2.3 Limits of fastest minimum-width integer types
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
// 7.18.2.4 Limits of integer types capable of holding object pointers
#ifdef _WIN64 // [
# define INTPTR_MIN INT64_MIN
# define INTPTR_MAX INT64_MAX
# define UINTPTR_MAX UINT64_MAX
#else // _WIN64 ][
# define INTPTR_MIN INT32_MIN
# define INTPTR_MAX INT32_MAX
# define UINTPTR_MAX UINT32_MAX
#endif // _WIN64 ]
// 7.18.2.5 Limits of greatest-width integer types
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
// 7.18.3 Limits of other integer types
#ifdef _WIN64 // [
# define PTRDIFF_MIN _I64_MIN
# define PTRDIFF_MAX _I64_MAX
#else // _WIN64 ][
# define PTRDIFF_MIN _I32_MIN
# define PTRDIFF_MAX _I32_MAX
#endif // _WIN64 ]
#define SIG_ATOMIC_MIN INT_MIN
#define SIG_ATOMIC_MAX INT_MAX
#ifndef SIZE_MAX // [
# ifdef _WIN64 // [
# define SIZE_MAX _UI64_MAX
# else // _WIN64 ][
# define SIZE_MAX _UI32_MAX
# endif // _WIN64 ]
#endif // SIZE_MAX ]
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
#ifndef WCHAR_MIN // [
# define WCHAR_MIN 0
#endif // WCHAR_MIN ]
#ifndef WCHAR_MAX // [
# define WCHAR_MAX _UI16_MAX
#endif // WCHAR_MAX ]
#define WINT_MIN 0
#define WINT_MAX _UI16_MAX
#endif // __STDC_LIMIT_MACROS ]
// 7.18.4 Limits of other integer types
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
// 7.18.4.1 Macros for minimum-width integer constants
#define INT8_C(val) val##i8
#define INT16_C(val) val##i16
#define INT32_C(val) val##i32
#define INT64_C(val) val##i64
#define UINT8_C(val) val##ui8
#define UINT16_C(val) val##ui16
#define UINT32_C(val) val##ui32
#define UINT64_C(val) val##ui64
// 7.18.4.2 Macros for greatest-width integer constants
#define INTMAX_C INT64_C
#define UINTMAX_C UINT64_C
#endif // __STDC_CONSTANT_MACROS ]
#endif // _MSC_STDINT_H_ ]

View File

@ -31,7 +31,7 @@ struct uv__work {
void (*work)(struct uv__work *w); void (*work)(struct uv__work *w);
void (*done)(struct uv__work *w, int status); void (*done)(struct uv__work *w, int status);
struct uv_loop_s* loop; struct uv_loop_s* loop;
void* wq[2]; struct uv__queue wq;
}; };
#endif /* UV_THREADPOOL_H_ */ #endif /* UV_THREADPOOL_H_ */

View File

@ -35,21 +35,7 @@
#endif #endif
/* /*
* This file defines data structures for different types of trees: * This file defines data structures for red-black trees.
* splay trees and red-black trees.
*
* A splay tree is a self-organizing data structure. Every operation
* on the tree causes a splay to happen. The splay moves the requested
* node to the root of the tree and partly rebalances it.
*
* This has the benefit that request locality causes faster lookups as
* the requested nodes move to the top of the tree. On the other hand,
* every lookup causes memory writes.
*
* The Balance Theorem bounds the total access time for m operations
* and n inserts on an initially empty tree as O((m + n)lg n). The
* amortized cost for a sequence of m accesses to a splay tree is O(lg n);
*
* A red-black tree is a binary search tree with the node color as an * A red-black tree is a binary search tree with the node color as an
* extra attribute. It fulfills a set of conditions: * extra attribute. It fulfills a set of conditions:
* - every search path from the root to a leaf consists of the * - every search path from the root to a leaf consists of the
@ -61,239 +47,6 @@
* The maximum height of a red-black tree is 2lg (n+1). * The maximum height of a red-black tree is 2lg (n+1).
*/ */
#define SPLAY_HEAD(name, type) \
struct name { \
struct type *sph_root; /* root of the tree */ \
}
#define SPLAY_INITIALIZER(root) \
{ NULL }
#define SPLAY_INIT(root) do { \
(root)->sph_root = NULL; \
} while (/*CONSTCOND*/ 0)
#define SPLAY_ENTRY(type) \
struct { \
struct type *spe_left; /* left element */ \
struct type *spe_right; /* right element */ \
}
#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
#define SPLAY_ROOT(head) (head)->sph_root
#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL)
/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
(head)->sph_root = tmp; \
} while (/*CONSTCOND*/ 0)
#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
(head)->sph_root = tmp; \
} while (/*CONSTCOND*/ 0)
#define SPLAY_LINKLEFT(head, tmp, field) do { \
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
tmp = (head)->sph_root; \
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
} while (/*CONSTCOND*/ 0)
#define SPLAY_LINKRIGHT(head, tmp, field) do { \
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
tmp = (head)->sph_root; \
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
} while (/*CONSTCOND*/ 0)
#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \
SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field); \
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
} while (/*CONSTCOND*/ 0)
/* Generates prototypes and inline functions */
#define SPLAY_PROTOTYPE(name, type, field, cmp) \
void name##_SPLAY(struct name *, struct type *); \
void name##_SPLAY_MINMAX(struct name *, int); \
struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
\
/* Finds the node with the same key as elm */ \
static __inline struct type * \
name##_SPLAY_FIND(struct name *head, struct type *elm) \
{ \
if (SPLAY_EMPTY(head)) \
return(NULL); \
name##_SPLAY(head, elm); \
if ((cmp)(elm, (head)->sph_root) == 0) \
return (head->sph_root); \
return (NULL); \
} \
\
static __inline struct type * \
name##_SPLAY_NEXT(struct name *head, struct type *elm) \
{ \
name##_SPLAY(head, elm); \
if (SPLAY_RIGHT(elm, field) != NULL) { \
elm = SPLAY_RIGHT(elm, field); \
while (SPLAY_LEFT(elm, field) != NULL) { \
elm = SPLAY_LEFT(elm, field); \
} \
} else \
elm = NULL; \
return (elm); \
} \
\
static __inline struct type * \
name##_SPLAY_MIN_MAX(struct name *head, int val) \
{ \
name##_SPLAY_MINMAX(head, val); \
return (SPLAY_ROOT(head)); \
}
/* Main splay operation.
* Moves node close to the key of elm to top
*/
#define SPLAY_GENERATE(name, type, field, cmp) \
struct type * \
name##_SPLAY_INSERT(struct name *head, struct type *elm) \
{ \
if (SPLAY_EMPTY(head)) { \
SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
} else { \
int __comp; \
name##_SPLAY(head, elm); \
__comp = (cmp)(elm, (head)->sph_root); \
if(__comp < 0) { \
SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field); \
SPLAY_RIGHT(elm, field) = (head)->sph_root; \
SPLAY_LEFT((head)->sph_root, field) = NULL; \
} else if (__comp > 0) { \
SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field); \
SPLAY_LEFT(elm, field) = (head)->sph_root; \
SPLAY_RIGHT((head)->sph_root, field) = NULL; \
} else \
return ((head)->sph_root); \
} \
(head)->sph_root = (elm); \
return (NULL); \
} \
\
struct type * \
name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
{ \
struct type *__tmp; \
if (SPLAY_EMPTY(head)) \
return (NULL); \
name##_SPLAY(head, elm); \
if ((cmp)(elm, (head)->sph_root) == 0) { \
if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
} else { \
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
name##_SPLAY(head, elm); \
SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
} \
return (elm); \
} \
return (NULL); \
} \
\
void \
name##_SPLAY(struct name *head, struct type *elm) \
{ \
struct type __node, *__left, *__right, *__tmp; \
int __comp; \
\
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \
__left = __right = &__node; \
\
while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \
if (__comp < 0) { \
__tmp = SPLAY_LEFT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if ((cmp)(elm, __tmp) < 0){ \
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
if (SPLAY_LEFT((head)->sph_root, field) == NULL) \
break; \
} \
SPLAY_LINKLEFT(head, __right, field); \
} else if (__comp > 0) { \
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if ((cmp)(elm, __tmp) > 0){ \
SPLAY_ROTATE_LEFT(head, __tmp, field); \
if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \
break; \
} \
SPLAY_LINKRIGHT(head, __left, field); \
} \
} \
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
} \
\
/* Splay with either the minimum or the maximum element \
* Used to find minimum or maximum element in tree. \
*/ \
void name##_SPLAY_MINMAX(struct name *head, int __comp) \
{ \
struct type __node, *__left, *__right, *__tmp; \
\
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \
__left = __right = &__node; \
\
while (1) { \
if (__comp < 0) { \
__tmp = SPLAY_LEFT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if (__comp < 0){ \
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
if (SPLAY_LEFT((head)->sph_root, field) == NULL) \
break; \
} \
SPLAY_LINKLEFT(head, __right, field); \
} else if (__comp > 0) { \
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if (__comp > 0) { \
SPLAY_ROTATE_LEFT(head, __tmp, field); \
if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \
break; \
} \
SPLAY_LINKRIGHT(head, __left, field); \
} \
} \
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
}
#define SPLAY_NEGINF -1
#define SPLAY_INF 1
#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y)
#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \
: name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \
: name##_SPLAY_MIN_MAX(x, SPLAY_INF))
#define SPLAY_FOREACH(x, name, head) \
for ((x) = SPLAY_MIN(name, head); \
(x) != NULL; \
(x) = SPLAY_NEXT(name, head, x))
/* Macros that define a red-black tree */ /* Macros that define a red-black tree */
#define RB_HEAD(name, type) \ #define RB_HEAD(name, type) \
struct name { \ struct name { \
@ -730,8 +483,8 @@ name##_RB_MINMAX(struct name *head, int val) \
#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) #define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y)
#define RB_FIND(name, x, y) name##_RB_FIND(x, y) #define RB_FIND(name, x, y) name##_RB_FIND(x, y)
#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) #define RB_NFIND(name, x, y) name##_RB_NFIND(x, y)
#define RB_NEXT(name, x, y) name##_RB_NEXT(y) #define RB_NEXT(name, x) name##_RB_NEXT(x)
#define RB_PREV(name, x, y) name##_RB_PREV(y) #define RB_PREV(name, x) name##_RB_PREV(x)
#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) #define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF)
#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) #define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF)

View File

@ -59,16 +59,15 @@
# include "uv/darwin.h" # include "uv/darwin.h"
#elif defined(__DragonFly__) || \ #elif defined(__DragonFly__) || \
defined(__FreeBSD__) || \ defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || \
defined(__OpenBSD__) || \ defined(__OpenBSD__) || \
defined(__NetBSD__) defined(__NetBSD__)
# include "uv/bsd.h" # include "uv/bsd.h"
#elif defined(__CYGWIN__) || \ #elif defined(__CYGWIN__) || \
defined(__MSYS__) || \ defined(__MSYS__) || \
defined(__HAIKU__) || \
defined(__QNX__) || \
defined(__GNU__) defined(__GNU__)
# include "uv/posix.h" # include "uv/posix.h"
#elif defined(__HAIKU__)
# include "uv/posix.h"
#endif #endif
#ifndef NI_MAXHOST #ifndef NI_MAXHOST
@ -93,8 +92,8 @@ typedef struct uv__io_s uv__io_t;
struct uv__io_s { struct uv__io_s {
uv__io_cb cb; uv__io_cb cb;
void* pending_queue[2]; struct uv__queue pending_queue;
void* watcher_queue[2]; struct uv__queue watcher_queue;
unsigned int pevents; /* Pending event mask i.e. mask at next tick. */ unsigned int pevents; /* Pending event mask i.e. mask at next tick. */
unsigned int events; /* Current event mask. */ unsigned int events; /* Current event mask. */
int fd; int fd;
@ -221,21 +220,21 @@ typedef struct {
#define UV_LOOP_PRIVATE_FIELDS \ #define UV_LOOP_PRIVATE_FIELDS \
unsigned long flags; \ unsigned long flags; \
int backend_fd; \ int backend_fd; \
void* pending_queue[2]; \ struct uv__queue pending_queue; \
void* watcher_queue[2]; \ struct uv__queue watcher_queue; \
uv__io_t** watchers; \ uv__io_t** watchers; \
unsigned int nwatchers; \ unsigned int nwatchers; \
unsigned int nfds; \ unsigned int nfds; \
void* wq[2]; \ struct uv__queue wq; \
uv_mutex_t wq_mutex; \ uv_mutex_t wq_mutex; \
uv_async_t wq_async; \ uv_async_t wq_async; \
uv_rwlock_t cloexec_lock; \ uv_rwlock_t cloexec_lock; \
uv_handle_t* closing_handles; \ uv_handle_t* closing_handles; \
void* process_handles[2]; \ struct uv__queue process_handles; \
void* prepare_handles[2]; \ struct uv__queue prepare_handles; \
void* check_handles[2]; \ struct uv__queue check_handles; \
void* idle_handles[2]; \ struct uv__queue idle_handles; \
void* async_handles[2]; \ struct uv__queue async_handles; \
void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \ void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \
uv__io_t async_io_watcher; \ uv__io_t async_io_watcher; \
int async_wfd; \ int async_wfd; \
@ -258,7 +257,7 @@ typedef struct {
#define UV_PRIVATE_REQ_TYPES /* empty */ #define UV_PRIVATE_REQ_TYPES /* empty */
#define UV_WRITE_PRIVATE_FIELDS \ #define UV_WRITE_PRIVATE_FIELDS \
void* queue[2]; \ struct uv__queue queue; \
unsigned int write_index; \ unsigned int write_index; \
uv_buf_t* bufs; \ uv_buf_t* bufs; \
unsigned int nbufs; \ unsigned int nbufs; \
@ -266,13 +265,16 @@ typedef struct {
uv_buf_t bufsml[4]; \ uv_buf_t bufsml[4]; \
#define UV_CONNECT_PRIVATE_FIELDS \ #define UV_CONNECT_PRIVATE_FIELDS \
void* queue[2]; \ struct uv__queue queue; \
#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ #define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */
#define UV_UDP_SEND_PRIVATE_FIELDS \ #define UV_UDP_SEND_PRIVATE_FIELDS \
void* queue[2]; \ struct uv__queue queue; \
struct sockaddr_storage addr; \ union { \
struct sockaddr addr; \
struct sockaddr_storage storage; \
} u; \
unsigned int nbufs; \ unsigned int nbufs; \
uv_buf_t* bufs; \ uv_buf_t* bufs; \
ssize_t status; \ ssize_t status; \
@ -287,8 +289,8 @@ typedef struct {
uv_connect_t *connect_req; \ uv_connect_t *connect_req; \
uv_shutdown_t *shutdown_req; \ uv_shutdown_t *shutdown_req; \
uv__io_t io_watcher; \ uv__io_t io_watcher; \
void* write_queue[2]; \ struct uv__queue write_queue; \
void* write_completed_queue[2]; \ struct uv__queue write_completed_queue; \
uv_connection_cb connection_cb; \ uv_connection_cb connection_cb; \
int delayed_error; \ int delayed_error; \
int accepted_fd; \ int accepted_fd; \
@ -301,35 +303,38 @@ typedef struct {
uv_alloc_cb alloc_cb; \ uv_alloc_cb alloc_cb; \
uv_udp_recv_cb recv_cb; \ uv_udp_recv_cb recv_cb; \
uv__io_t io_watcher; \ uv__io_t io_watcher; \
void* write_queue[2]; \ struct uv__queue write_queue; \
void* write_completed_queue[2]; \ struct uv__queue write_completed_queue; \
#define UV_PIPE_PRIVATE_FIELDS \ #define UV_PIPE_PRIVATE_FIELDS \
const char* pipe_fname; /* strdup'ed */ const char* pipe_fname; /* NULL or strdup'ed */
#define UV_POLL_PRIVATE_FIELDS \ #define UV_POLL_PRIVATE_FIELDS \
uv__io_t io_watcher; uv__io_t io_watcher;
#define UV_PREPARE_PRIVATE_FIELDS \ #define UV_PREPARE_PRIVATE_FIELDS \
uv_prepare_cb prepare_cb; \ uv_prepare_cb prepare_cb; \
void* queue[2]; \ struct uv__queue queue; \
#define UV_CHECK_PRIVATE_FIELDS \ #define UV_CHECK_PRIVATE_FIELDS \
uv_check_cb check_cb; \ uv_check_cb check_cb; \
void* queue[2]; \ struct uv__queue queue; \
#define UV_IDLE_PRIVATE_FIELDS \ #define UV_IDLE_PRIVATE_FIELDS \
uv_idle_cb idle_cb; \ uv_idle_cb idle_cb; \
void* queue[2]; \ struct uv__queue queue; \
#define UV_ASYNC_PRIVATE_FIELDS \ #define UV_ASYNC_PRIVATE_FIELDS \
uv_async_cb async_cb; \ uv_async_cb async_cb; \
void* queue[2]; \ struct uv__queue queue; \
int pending; \ int pending; \
#define UV_TIMER_PRIVATE_FIELDS \ #define UV_TIMER_PRIVATE_FIELDS \
uv_timer_cb timer_cb; \ uv_timer_cb timer_cb; \
void* heap_node[3]; \ union { \
void* heap[3]; \
struct uv__queue queue; \
} node; \
uint64_t timeout; \ uint64_t timeout; \
uint64_t repeat; \ uint64_t repeat; \
uint64_t start_id; uint64_t start_id;
@ -353,7 +358,7 @@ typedef struct {
int retcode; int retcode;
#define UV_PROCESS_PRIVATE_FIELDS \ #define UV_PROCESS_PRIVATE_FIELDS \
void* queue[2]; \ struct uv__queue queue; \
int status; \ int status; \
#define UV_FS_PRIVATE_FIELDS \ #define UV_FS_PRIVATE_FIELDS \
@ -418,6 +423,8 @@ typedef struct {
# define UV_FS_O_DIRECT 0x04000 # define UV_FS_O_DIRECT 0x04000
#elif defined(__linux__) && defined(__x86_64__) #elif defined(__linux__) && defined(__x86_64__)
# define UV_FS_O_DIRECT 0x04000 # define UV_FS_O_DIRECT 0x04000
#elif defined(__linux__) && defined(__loongarch__)
# define UV_FS_O_DIRECT 0x04000
#elif defined(O_DIRECT) #elif defined(O_DIRECT)
# define UV_FS_O_DIRECT O_DIRECT # define UV_FS_O_DIRECT O_DIRECT
#else #else

View File

@ -31,10 +31,10 @@
*/ */
#define UV_VERSION_MAJOR 1 #define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 36 #define UV_VERSION_MINOR 50
#define UV_VERSION_PATCH 0 #define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_IS_RELEASE 0
#define UV_VERSION_SUFFIX "" #define UV_VERSION_SUFFIX "dev"
#define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \ #define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \
(UV_VERSION_MINOR << 8) | \ (UV_VERSION_MINOR << 8) | \

View File

@ -20,7 +20,7 @@
*/ */
#ifndef _WIN32_WINNT #ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0600 # define _WIN32_WINNT 0x0A00
#endif #endif
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
@ -32,32 +32,26 @@ typedef intptr_t ssize_t;
#include <winsock2.h> #include <winsock2.h>
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
typedef struct pollfd {
SOCKET fd;
short events;
short revents;
} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
#endif
#ifndef LOCALE_INVARIANT #ifndef LOCALE_INVARIANT
# define LOCALE_INVARIANT 0x007f # define LOCALE_INVARIANT 0x007f
#endif #endif
#include <mswsock.h> #include <mswsock.h>
/* Disable the typedef in mstcpip.h of MinGW. */
#define _TCP_INITIAL_RTO_PARAMETERS _TCP_INITIAL_RTO_PARAMETERS__AVOID
#define TCP_INITIAL_RTO_PARAMETERS TCP_INITIAL_RTO_PARAMETERS__AVOID
#define PTCP_INITIAL_RTO_PARAMETERS PTCP_INITIAL_RTO_PARAMETERS__AVOID
#include <ws2tcpip.h> #include <ws2tcpip.h>
#undef _TCP_INITIAL_RTO_PARAMETERS
#undef TCP_INITIAL_RTO_PARAMETERS
#undef PTCP_INITIAL_RTO_PARAMETERS
#include <windows.h> #include <windows.h>
#include <process.h> #include <process.h>
#include <signal.h> #include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
# include "uv/stdint-msvc2008.h"
#else
#include <stdint.h> #include <stdint.h>
#endif
#include "uv/tree.h" #include "uv/tree.h"
#include "uv/threadpool.h" #include "uv/threadpool.h"
@ -68,6 +62,11 @@ typedef struct pollfd {
# define S_IFLNK 0xA000 # define S_IFLNK 0xA000
#endif #endif
/* Define missing in Windows Kit Include\{VERSION}\ucrt\sys\stat.h */
#if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES && !defined(S_IFIFO)
# define S_IFIFO _S_IFIFO
#endif
/* Additional signals supported by uv_signal and or uv_kill. The CRT defines /* Additional signals supported by uv_signal and or uv_kill. The CRT defines
* the following signals already: * the following signals already:
* *
@ -84,6 +83,7 @@ typedef struct pollfd {
* variants (Linux and Darwin) * variants (Linux and Darwin)
*/ */
#define SIGHUP 1 #define SIGHUP 1
#define SIGQUIT 3
#define SIGKILL 9 #define SIGKILL 9
#define SIGWINCH 28 #define SIGWINCH 28
@ -216,7 +216,7 @@ typedef struct _AFD_POLL_INFO {
AFD_POLL_HANDLE_INFO Handles[1]; AFD_POLL_HANDLE_INFO Handles[1];
} AFD_POLL_INFO, *PAFD_POLL_INFO; } AFD_POLL_INFO, *PAFD_POLL_INFO;
#define UV_MSAFD_PROVIDER_COUNT 3 #define UV_MSAFD_PROVIDER_COUNT 4
/** /**
@ -256,29 +256,23 @@ typedef union {
} unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */ } unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */
} uv_cond_t; } uv_cond_t;
typedef union { typedef struct {
struct { SRWLOCK read_write_lock_;
unsigned int num_readers_; /* TODO: retained for ABI compatibility; remove me in v2.x */
CRITICAL_SECTION num_readers_lock_; #ifdef _WIN64
HANDLE write_semaphore_; unsigned char padding_[72];
} state_; #else
/* TODO: remove me in v2.x. */ unsigned char padding_[44];
struct { #endif
SRWLOCK unused_;
} unused1_;
/* TODO: remove me in v2.x. */
struct {
uv_mutex_t unused1_;
uv_mutex_t unused2_;
} unused2_;
} uv_rwlock_t; } uv_rwlock_t;
typedef struct { typedef struct {
unsigned int n; unsigned threshold;
unsigned int count; unsigned in;
uv_mutex_t mutex; uv_mutex_t mutex;
uv_sem_t turnstile1; /* TODO: in v2 make this a uv_cond_t, without unused_ */
uv_sem_t turnstile2; CONDITION_VARIABLE cond;
unsigned out;
} uv_barrier_t; } uv_barrier_t;
typedef struct { typedef struct {
@ -288,8 +282,8 @@ typedef struct {
#define UV_ONCE_INIT { 0, NULL } #define UV_ONCE_INIT { 0, NULL }
typedef struct uv_once_s { typedef struct uv_once_s {
unsigned char ran; unsigned char unused;
HANDLE event; INIT_ONCE init_once;
} uv_once_t; } uv_once_t;
/* Platform-specific definitions for uv_spawn support. */ /* Platform-specific definitions for uv_spawn support. */
@ -348,14 +342,14 @@ typedef struct {
uv_idle_t* next_idle_handle; \ uv_idle_t* next_idle_handle; \
/* This handle holds the peer sockets for the fast variant of uv_poll_t */ \ /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \
SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \ SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \
/* Counter to keep track of active tcp streams */ \ /* No longer used. */ \
unsigned int active_tcp_streams; \ unsigned int active_tcp_streams; \
/* Counter to keep track of active udp streams */ \ /* No longer used. */ \
unsigned int active_udp_streams; \ unsigned int active_udp_streams; \
/* Counter to started timer */ \ /* Counter to started timer */ \
uint64_t timer_counter; \ uint64_t timer_counter; \
/* Threadpool */ \ /* Threadpool */ \
void* wq[2]; \ struct uv__queue wq; \
uv_mutex_t wq_mutex; \ uv_mutex_t wq_mutex; \
uv_async_t wq_async; uv_async_t wq_async;
@ -377,6 +371,13 @@ typedef struct {
OVERLAPPED overlapped; \ OVERLAPPED overlapped; \
size_t queued_bytes; \ size_t queued_bytes; \
} io; \ } io; \
/* in v2, we can move these to the UV_CONNECT_PRIVATE_FIELDS */ \
struct { \
ULONG_PTR result; /* overlapped.Internal is reused to hold the result */\
HANDLE pipeHandle; \
DWORD duplex_flags; \
WCHAR* name; \
} connect; \
} u; \ } u; \
struct uv_req_s* next_req; struct uv_req_s* next_req;
@ -477,7 +478,7 @@ typedef struct {
uint32_t payload_remaining; \ uint32_t payload_remaining; \
uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \
} ipc_data_frame; \ } ipc_data_frame; \
void* ipc_xfer_queue[2]; \ struct uv__queue ipc_xfer_queue; \
int ipc_xfer_queue_length; \ int ipc_xfer_queue_length; \
uv_write_t* non_overlapped_writes_tail; \ uv_write_t* non_overlapped_writes_tail; \
CRITICAL_SECTION readfile_thread_lock; \ CRITICAL_SECTION readfile_thread_lock; \
@ -491,15 +492,18 @@ typedef struct {
struct { uv_pipe_connection_fields } conn; \ struct { uv_pipe_connection_fields } conn; \
} pipe; } pipe;
/* TODO: put the parser states in an union - TTY handles are always half-duplex /* TODO: put the parser states in a union - TTY handles are always half-duplex
* so read-state can safely overlap write-state. */ * so read-state can safely overlap write-state. */
#define UV_TTY_PRIVATE_FIELDS \ #define UV_TTY_PRIVATE_FIELDS \
HANDLE handle; \ HANDLE handle; \
union { \ union { \
struct { \ struct { \
/* Used for readable TTY handles */ \ /* Used for readable TTY handles */ \
union { \
/* TODO: remove me in v2.x. */ \ /* TODO: remove me in v2.x. */ \
HANDLE unused_; \ HANDLE unused_; \
int mode; \
} mode; \
uv_buf_t read_line_buffer; \ uv_buf_t read_line_buffer; \
HANDLE read_raw_wait; \ HANDLE read_raw_wait; \
/* Fields used for translating win keystrokes into vt100 characters */ \ /* Fields used for translating win keystrokes into vt100 characters */ \
@ -541,7 +545,10 @@ typedef struct {
unsigned char events; unsigned char events;
#define UV_TIMER_PRIVATE_FIELDS \ #define UV_TIMER_PRIVATE_FIELDS \
void* heap_node[3]; \ union { \
void* heap[3]; \
struct uv__queue queue; \
} node; \
int unused; \ int unused; \
uint64_t timeout; \ uint64_t timeout; \
uint64_t repeat; \ uint64_t repeat; \
@ -599,7 +606,7 @@ typedef struct {
struct uv_process_exit_s { \ struct uv_process_exit_s { \
UV_REQ_FIELDS \ UV_REQ_FIELDS \
} exit_req; \ } exit_req; \
BYTE* child_stdio_buffer; \ void* unused; /* TODO: retained for ABI compat; remove this in v2.x. */ \
int exit_signal; \ int exit_signal; \
HANDLE wait_handle; \ HANDLE wait_handle; \
HANDLE process_handle; \ HANDLE process_handle; \

12
libuv-static.pc.in Normal file
View File

@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=${prefix}
libdir=@libdir@
includedir=@includedir@
Name: libuv-static
Version: @PACKAGE_VERSION@
Description: multi-platform support library with a focus on asynchronous I/O.
URL: http://libuv.org/
Libs: -L${libdir} -l:libuv.a @LIBS@
Cflags: -I${includedir}

View File

@ -2,6 +2,7 @@ prefix=@prefix@
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=@libdir@ libdir=@libdir@
includedir=@includedir@ includedir=@includedir@
LIBUV_STATIC=-L${libdir} -l:libuv.a @LIBS@
Name: libuv Name: libuv
Version: @PACKAGE_VERSION@ Version: @PACKAGE_VERSION@

1
m4/.gitignore vendored
View File

@ -1,4 +1,5 @@
# Ignore libtoolize-generated files. # Ignore libtoolize-generated files.
*.m4 *.m4
!as_case.m4 !as_case.m4
!ax_pthread.m4
!libuv-check-flags.m4 !libuv-check-flags.m4

485
m4/ax_pthread.m4 Normal file
View File

@ -0,0 +1,485 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads. It
# sets the PTHREAD_LIBS output variable to the threads library and linker
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
# flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.)
#
# Also sets PTHREAD_CC to any special C compiler that is needed for
# multi-threaded programs (defaults to the value of CC otherwise). (This
# is necessary on AIX to use the special cc_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also to link with them as well. For example, you might link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
# If you are only building threaded programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
# PTHREAD_CFLAGS.
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or if
# you have any other suggestions or comments. This macro was based on work
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
# grateful for the helpful feedback of numerous users.
#
# Updated for Autoconf 2.68 by Daniel Richard G.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 24
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_SED])
AC_LANG_PUSH([C])
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on Tru64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
ax_pthread_save_CC="$CC"
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
AC_MSG_RESULT([$ax_pthread_ok])
if test "x$ax_pthread_ok" = "xno"; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
CC="$ax_pthread_save_CC"
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
# (Note: HP C rejects this with "bad form for `-t' option")
# -pthreads: Solaris/gcc (Note: HP C also rejects)
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads and
# -D_REENTRANT too), HP C (must be checked before -lpthread, which
# is present but should not be used directly; and before -mthreads,
# because the compiler interprets this as "-mt" + "-hreads")
# -mthreads: Mingw32/gcc, Lynx/gcc
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case $host_os in
freebsd*)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
ax_pthread_flags="-kthread lthread $ax_pthread_flags"
;;
hpux*)
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
# multi-threading and also sets -lpthread."
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
;;
openedition*)
# IBM z/OS requires a feature-test macro to be defined in order to
# enable POSIX threads at all, so give the user a hint if this is
# not set. (We don't define these ourselves, as they can affect
# other portions of the system API in unpredictable ways.)
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
[
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
AX_PTHREAD_ZOS_MISSING
# endif
],
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
;;
solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (N.B.: The stubs are missing
# pthread_cleanup_push, or rather a function called by this macro,
# so we could check for that, but who knows whether they'll stub
# that too in a future libc.) So we'll check first for the
# standard Solaris way of linking pthreads (-mt -lpthread).
ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
;;
esac
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
AS_IF([test "x$GCC" = "xyes"],
[ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
# The presence of a feature test macro requesting re-entrant function
# definitions is, on some systems, a strong hint that pthreads support is
# correctly enabled
case $host_os in
darwin* | hpux* | linux* | osf* | solaris*)
ax_pthread_check_macro="_REENTRANT"
;;
aix*)
ax_pthread_check_macro="_THREAD_SAFE"
;;
*)
ax_pthread_check_macro="--"
;;
esac
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
[ax_pthread_check_cond=0],
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
# Are we compiling with Clang?
AC_CACHE_CHECK([whether $CC is Clang],
[ax_cv_PTHREAD_CLANG],
[ax_cv_PTHREAD_CLANG=no
# Note that Autoconf sets GCC=yes for Clang as well as GCC
if test "x$GCC" = "xyes"; then
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
# if defined(__clang__) && defined(__llvm__)
AX_PTHREAD_CC_IS_CLANG
# endif
],
[ax_cv_PTHREAD_CLANG=yes])
fi
])
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
ax_pthread_clang_warning=no
# Clang needs special handling, because older versions handle the -pthread
# option in a rather... idiosyncratic way
if test "x$ax_pthread_clang" = "xyes"; then
# Clang takes -pthread; it has never supported any other flag
# (Note 1: This will need to be revisited if a system that Clang
# supports has POSIX threads in a separate library. This tends not
# to be the way of modern systems, but it's conceivable.)
# (Note 2: On some systems, notably Darwin, -pthread is not needed
# to get POSIX threads support; the API is always present and
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
# -pthread does define _REENTRANT, and while the Darwin headers
# ignore this macro, third-party headers might not.)
PTHREAD_CFLAGS="-pthread"
PTHREAD_LIBS=
ax_pthread_ok=yes
# However, older versions of Clang make a point of warning the user
# that, in an invocation where only linking and no compilation is
# taking place, the -pthread option has no effect ("argument unused
# during compilation"). They expect -pthread to be passed in only
# when source code is being compiled.
#
# Problem is, this is at odds with the way Automake and most other
# C build frameworks function, which is that the same flags used in
# compilation (CFLAGS) are also used in linking. Many systems
# supported by AX_PTHREAD require exactly this for POSIX threads
# support, and in fact it is often not straightforward to specify a
# flag that is used only in the compilation phase and not in
# linking. Such a scenario is extremely rare in practice.
#
# Even though use of the -pthread flag in linking would only print
# a warning, this can be a nuisance for well-run software projects
# that build with -Werror. So if the active version of Clang has
# this misfeature, we search for an option to squash it.
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
# Create an alternate version of $ac_link that compiles and
# links in two steps (.c -> .o, .o -> exe) instead of one
# (.c -> exe), because the warning occurs only in the second
# step
ax_pthread_save_ac_link="$ac_link"
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
ax_pthread_save_CFLAGS="$CFLAGS"
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
ac_link="$ax_pthread_save_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[ac_link="$ax_pthread_2step_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[break])
])
done
ac_link="$ax_pthread_save_ac_link"
CFLAGS="$ax_pthread_save_CFLAGS"
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
])
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
no | unknown) ;;
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
esac
fi # $ax_pthread_clang = yes
if test "x$ax_pthread_ok" = "xno"; then
for ax_pthread_try_flag in $ax_pthread_flags; do
case $ax_pthread_try_flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-mt,pthread)
AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
PTHREAD_CFLAGS="-mt"
PTHREAD_LIBS="-lpthread"
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
PTHREAD_CFLAGS="$ax_pthread_try_flag"
;;
pthread-config)
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
PTHREAD_LIBS="-l$ax_pthread_try_flag"
;;
esac
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
# if $ax_pthread_check_cond
# error "$ax_pthread_check_macro must be defined"
# endif
static void routine(void *a) { a = 0; }
static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr;
pthread_create(&th, 0, start_routine, 0);
pthread_join(th, 0);
pthread_attr_init(&attr);
pthread_cleanup_push(routine, 0);
pthread_cleanup_pop(0) /* ; */])],
[ax_pthread_ok=yes],
[])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
AC_MSG_RESULT([$ax_pthread_ok])
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$ax_pthread_ok" = "xyes"; then
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_CACHE_CHECK([for joinable pthread attribute],
[ax_cv_PTHREAD_JOINABLE_ATTR],
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[int attr = $ax_pthread_attr; return attr /* ; */])],
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
[])
done
])
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
test "x$ax_pthread_joinable_attr_defined" != "xyes"],
[AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
[$ax_cv_PTHREAD_JOINABLE_ATTR],
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
ax_pthread_joinable_attr_defined=yes
])
AC_CACHE_CHECK([whether more special flags are required for pthreads],
[ax_cv_PTHREAD_SPECIAL_FLAGS],
[ax_cv_PTHREAD_SPECIAL_FLAGS=no
case $host_os in
solaris*)
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
;;
esac
])
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
test "x$ax_pthread_special_flags_added" != "xyes"],
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
ax_pthread_special_flags_added=yes])
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
[ax_cv_PTHREAD_PRIO_INHERIT],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_PRIO_INHERIT;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no])
])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
test "x$ax_pthread_prio_inherit_defined" != "xyes"],
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
ax_pthread_prio_inherit_defined=yes
])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
# More AIX lossage: compile with *_r variant
if test "x$GCC" != "xyes"; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
[#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"],
[x/*],
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
;;
esac
fi
fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
AC_SUBST([PTHREAD_LIBS])
AC_SUBST([PTHREAD_CFLAGS])
AC_SUBST([PTHREAD_CC])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "x$ax_pthread_ok" = "xyes"; then
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
:
else
ax_pthread_ok=no
$2
fi
AC_LANG_POP
])dnl AX_PTHREAD

View File

@ -1,6 +1,7 @@
dnl Macros to check the presence of generic (non-typed) symbols. dnl Macros to check the presence of generic (non-typed) symbols.
dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes gmail com> dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes gmail com>
dnl Copyright (c) 2006-2008 xine project dnl Copyright (c) 2006-2008 xine project
dnl Copyright (c) 2021 libuv project
dnl dnl
dnl This program is free software; you can redistribute it and/or modify dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by dnl it under the terms of the GNU General Public License as published by
@ -63,7 +64,7 @@ AC_DEFUN([CC_CHECK_CFLAGS], [
]) ])
dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found]) dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
dnl Check for CFLAG and appends them to CFLAGS if supported dnl Check for CFLAG and appends them to AM_CFLAGS if supported
AC_DEFUN([CC_CHECK_CFLAG_APPEND], [ AC_DEFUN([CC_CHECK_CFLAG_APPEND], [
AC_CACHE_CHECK([if $CC supports $1 flag], AC_CACHE_CHECK([if $CC supports $1 flag],
AS_TR_SH([cc_cv_cflags_$1]), AS_TR_SH([cc_cv_cflags_$1]),
@ -71,7 +72,9 @@ AC_DEFUN([CC_CHECK_CFLAG_APPEND], [
) )
AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
[CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3]) [AM_CFLAGS="$AM_CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3])
AC_SUBST([AM_CFLAGS])
]) ])
dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not]) dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not])
@ -101,6 +104,20 @@ AC_DEFUN([CC_CHECK_LDFLAGS], [
[$2], [$3]) [$2], [$3])
]) ])
dnl Check if flag is supported by both compiler and linker
dnl If so, append it to AM_CFLAGS
dnl CC_CHECK_FLAG_SUPPORTED_APPEND([FLAG])
AC_DEFUN([CC_CHECK_FLAG_SUPPORTED_APPEND], [
CC_CHECK_CFLAGS([$1],
[CC_CHECK_LDFLAGS([$1],
[AM_CFLAGS="$AM_CFLAGS $1";
DEBUG_CFLAGS="$DEBUG_CFLAGS $1";
AC_SUBST([AM_CFLAGS])
])
])
])
dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
dnl the current linker to avoid undefined references in a shared object. dnl the current linker to avoid undefined references in a shared object.
AC_DEFUN([CC_NOUNDEFINED], [ AC_DEFUN([CC_NOUNDEFINED], [

View File

@ -0,0 +1,7 @@
AC_PREREQ(2.71)
AC_INIT([libuv-release-check], [0.0])
AM_INIT_AUTOMAKE([1.16.5])
LT_PREREQ(2.4.7)
AC_OUTPUT

View File

@ -25,7 +25,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include "win/internal.h" #include "win/internal.h"
#include "win/handle-inl.h" #include "win/handle-inl.h"
#define uv__make_close_pending(h) uv_want_endgame((h)->loop, (h)) #define uv__make_close_pending(h) uv__want_endgame((h)->loop, (h))
#else #else
#include "unix/internal.h" #include "unix/internal.h"
#endif #endif
@ -139,6 +139,9 @@ int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) {
struct poll_ctx* ctx; struct poll_ctx* ctx;
size_t required_len; size_t required_len;
if (buffer == NULL || size == NULL || *size == 0)
return UV_EINVAL;
if (!uv_is_active((uv_handle_t*)handle)) { if (!uv_is_active((uv_handle_t*)handle)) {
*size = 0; *size = 0;
return UV_EINVAL; return UV_EINVAL;

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011, 2018 Ben Noordhuis <info@bnoordhuis.nl> /* Copyright libuv contributors. All rights reserved.
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -18,8 +18,55 @@
*/ */
#include "uv.h" #include "uv.h"
#include "uv-common.h"
#include "idna.h" #include "idna.h"
#include <assert.h>
#include <string.h> #include <string.h>
#include <limits.h> /* UINT_MAX */
static int32_t uv__wtf8_decode1(const char** input) {
uint32_t code_point;
uint8_t b1;
uint8_t b2;
uint8_t b3;
uint8_t b4;
b1 = **input;
if (b1 <= 0x7F)
return b1; /* ASCII code point */
if (b1 < 0xC2)
return -1; /* invalid: continuation byte */
code_point = b1;
b2 = *++*input;
if ((b2 & 0xC0) != 0x80)
return -1; /* invalid: not a continuation byte */
code_point = (code_point << 6) | (b2 & 0x3F);
if (b1 <= 0xDF)
return 0x7FF & code_point; /* two-byte character */
b3 = *++*input;
if ((b3 & 0xC0) != 0x80)
return -1; /* invalid: not a continuation byte */
code_point = (code_point << 6) | (b3 & 0x3F);
if (b1 <= 0xEF)
return 0xFFFF & code_point; /* three-byte character */
b4 = *++*input;
if ((b4 & 0xC0) != 0x80)
return -1; /* invalid: not a continuation byte */
code_point = (code_point << 6) | (b4 & 0x3F);
if (b1 <= 0xF4) {
code_point &= 0x1FFFFF;
if (code_point <= 0x10FFFF)
return code_point; /* four-byte character */
}
/* code point too large */
return -1;
}
static unsigned uv__utf8_decode1_slow(const char** p, static unsigned uv__utf8_decode1_slow(const char** p,
const char* pe, const char* pe,
@ -32,7 +79,7 @@ static unsigned uv__utf8_decode1_slow(const char** p,
if (a > 0xF7) if (a > 0xF7)
return -1; return -1;
switch (*p - pe) { switch (pe - *p) {
default: default:
if (a > 0xEF) { if (a > 0xEF) {
min = 0x10000; min = 0x10000;
@ -62,6 +109,8 @@ static unsigned uv__utf8_decode1_slow(const char** p,
a = 0; a = 0;
break; break;
} }
/* Fall through. */
case 0:
return -1; /* Invalid continuation byte. */ return -1; /* Invalid continuation byte. */
} }
@ -85,9 +134,12 @@ static unsigned uv__utf8_decode1_slow(const char** p,
return a; return a;
} }
unsigned uv__utf8_decode1(const char** p, const char* pe) { unsigned uv__utf8_decode1(const char** p, const char* pe) {
unsigned a; unsigned a;
assert(*p < pe);
a = (unsigned char) *(*p)++; a = (unsigned char) *(*p)++;
if (a < 128) if (a < 128)
@ -96,8 +148,6 @@ unsigned uv__utf8_decode1(const char** p, const char* pe) {
return uv__utf8_decode1_slow(p, pe, a); return uv__utf8_decode1_slow(p, pe, a);
} }
#define foreach_codepoint(c, p, pe) \
for (; (void) (*p <= pe && (c = uv__utf8_decode1(p, pe))), *p <= pe;)
static int uv__idna_toascii_label(const char* s, const char* se, static int uv__idna_toascii_label(const char* s, const char* se,
char** d, char* de) { char** d, char* de) {
@ -121,15 +171,22 @@ static int uv__idna_toascii_label(const char* s, const char* se,
ss = s; ss = s;
todo = 0; todo = 0;
foreach_codepoint(c, &s, se) { /* Note: after this loop we've visited all UTF-8 characters and know
* they're legal so we no longer need to check for decode errors.
*/
while (s < se) {
c = uv__utf8_decode1(&s, se);
if (c == UINT_MAX)
return UV_EINVAL;
if (c < 128) if (c < 128)
h++; h++;
else if (c == (unsigned) -1)
return UV_EINVAL;
else else
todo++; todo++;
} }
/* Only write "xn--" when there are non-ASCII characters. */
if (todo > 0) { if (todo > 0) {
if (*d < de) *(*d)++ = 'x'; if (*d < de) *(*d)++ = 'x';
if (*d < de) *(*d)++ = 'n'; if (*d < de) *(*d)++ = 'n';
@ -137,9 +194,13 @@ static int uv__idna_toascii_label(const char* s, const char* se,
if (*d < de) *(*d)++ = '-'; if (*d < de) *(*d)++ = '-';
} }
/* Write ASCII characters. */
x = 0; x = 0;
s = ss; s = ss;
foreach_codepoint(c, &s, se) { while (s < se) {
c = uv__utf8_decode1(&s, se);
assert(c != UINT_MAX);
if (c > 127) if (c > 127)
continue; continue;
@ -166,10 +227,15 @@ static int uv__idna_toascii_label(const char* s, const char* se,
while (todo > 0) { while (todo > 0) {
m = -1; m = -1;
s = ss; s = ss;
foreach_codepoint(c, &s, se)
while (s < se) {
c = uv__utf8_decode1(&s, se);
assert(c != UINT_MAX);
if (c >= n) if (c >= n)
if (c < m) if (c < m)
m = c; m = c;
}
x = m - n; x = m - n;
y = h + 1; y = h + 1;
@ -181,7 +247,10 @@ static int uv__idna_toascii_label(const char* s, const char* se,
n = m; n = m;
s = ss; s = ss;
foreach_codepoint(c, &s, se) { while (s < se) {
c = uv__utf8_decode1(&s, se);
assert(c != UINT_MAX);
if (c < n) if (c < n)
if (++delta == 0) if (++delta == 0)
return UV_E2BIG; /* Overflow. */ return UV_E2BIG; /* Overflow. */
@ -245,21 +314,27 @@ static int uv__idna_toascii_label(const char* s, const char* se,
return 0; return 0;
} }
#undef foreach_codepoint
long uv__idna_toascii(const char* s, const char* se, char* d, char* de) { ssize_t uv__idna_toascii(const char* s, const char* se, char* d, char* de) {
const char* si; const char* si;
const char* st; const char* st;
unsigned c; unsigned c;
char* ds; char* ds;
int rc; int rc;
if (s == se)
return UV_EINVAL;
ds = d; ds = d;
for (si = s; si < se; /* empty */) { si = s;
while (si < se) {
st = si; st = si;
c = uv__utf8_decode1(&si, se); c = uv__utf8_decode1(&si, se);
if (c == UINT_MAX)
return UV_EINVAL;
if (c != '.') if (c != '.')
if (c != 0x3002) /* 。 */ if (c != 0x3002) /* 。 */
if (c != 0xFF0E) /* */ if (c != 0xFF0E) /* */
@ -284,8 +359,202 @@ long uv__idna_toascii(const char* s, const char* se, char* d, char* de) {
return rc; return rc;
} }
if (d < de) if (d >= de)
*d++ = '\0'; return UV_EINVAL;
*d++ = '\0';
return d - ds; /* Number of bytes written. */ return d - ds; /* Number of bytes written. */
} }
ssize_t uv_wtf8_length_as_utf16(const char* source_ptr) {
size_t w_target_len = 0;
int32_t code_point;
do {
code_point = uv__wtf8_decode1(&source_ptr);
if (code_point < 0)
return -1;
if (code_point > 0xFFFF)
w_target_len++;
w_target_len++;
} while (*source_ptr++);
return w_target_len;
}
void uv_wtf8_to_utf16(const char* source_ptr,
uint16_t* w_target,
size_t w_target_len) {
int32_t code_point;
do {
code_point = uv__wtf8_decode1(&source_ptr);
/* uv_wtf8_length_as_utf16 should have been called and checked first. */
assert(code_point >= 0);
if (code_point > 0xFFFF) {
assert(code_point < 0x10FFFF);
*w_target++ = (((code_point - 0x10000) >> 10) + 0xD800);
*w_target++ = ((code_point - 0x10000) & 0x3FF) + 0xDC00;
w_target_len -= 2;
} else {
*w_target++ = code_point;
w_target_len -= 1;
}
} while (*source_ptr++);
(void)w_target_len;
assert(w_target_len == 0);
}
static int32_t uv__get_surrogate_value(const uint16_t* w_source_ptr,
ssize_t w_source_len) {
uint16_t u;
uint16_t next;
u = w_source_ptr[0];
if (u >= 0xD800 && u <= 0xDBFF && w_source_len != 1) {
next = w_source_ptr[1];
if (next >= 0xDC00 && next <= 0xDFFF)
return 0x10000 + ((u - 0xD800) << 10) + (next - 0xDC00);
}
return u;
}
size_t uv_utf16_length_as_wtf8(const uint16_t* w_source_ptr,
ssize_t w_source_len) {
size_t target_len;
int32_t code_point;
target_len = 0;
while (w_source_len) {
code_point = uv__get_surrogate_value(w_source_ptr, w_source_len);
/* Can be invalid UTF-8 but must be valid WTF-8. */
assert(code_point >= 0);
if (w_source_len < 0 && code_point == 0)
break;
if (code_point < 0x80)
target_len += 1;
else if (code_point < 0x800)
target_len += 2;
else if (code_point < 0x10000)
target_len += 3;
else {
target_len += 4;
w_source_ptr++;
if (w_source_len > 0)
w_source_len--;
}
w_source_ptr++;
if (w_source_len > 0)
w_source_len--;
}
return target_len;
}
int uv_utf16_to_wtf8(const uint16_t* w_source_ptr,
ssize_t w_source_len,
char** target_ptr,
size_t* target_len_ptr) {
size_t target_len;
char* target;
char* target_end;
int32_t code_point;
/* If *target_ptr is provided, then *target_len_ptr must be its length
* (excluding space for NUL), otherwise we will compute the target_len_ptr
* length and may return a new allocation in *target_ptr if target_ptr is
* provided. */
if (target_ptr == NULL || *target_ptr == NULL) {
target_len = uv_utf16_length_as_wtf8(w_source_ptr, w_source_len);
if (target_len_ptr != NULL)
*target_len_ptr = target_len;
} else {
target_len = *target_len_ptr;
}
if (target_ptr == NULL)
return 0;
if (*target_ptr == NULL) {
target = uv__malloc(target_len + 1);
if (target == NULL) {
return UV_ENOMEM;
}
*target_ptr = target;
} else {
target = *target_ptr;
}
target_end = target + target_len;
while (target != target_end && w_source_len) {
code_point = uv__get_surrogate_value(w_source_ptr, w_source_len);
/* Can be invalid UTF-8 but must be valid WTF-8. */
assert(code_point >= 0);
if (w_source_len < 0 && code_point == 0) {
w_source_len = 0;
break;
}
if (code_point < 0x80) {
*target++ = code_point;
} else if (code_point < 0x800) {
*target++ = 0xC0 | (code_point >> 6);
if (target == target_end)
break;
*target++ = 0x80 | (code_point & 0x3F);
} else if (code_point < 0x10000) {
*target++ = 0xE0 | (code_point >> 12);
if (target == target_end)
break;
*target++ = 0x80 | ((code_point >> 6) & 0x3F);
if (target == target_end)
break;
*target++ = 0x80 | (code_point & 0x3F);
} else {
*target++ = 0xF0 | (code_point >> 18);
if (target == target_end)
break;
*target++ = 0x80 | ((code_point >> 12) & 0x3F);
if (target == target_end)
break;
*target++ = 0x80 | ((code_point >> 6) & 0x3F);
if (target == target_end)
break;
*target++ = 0x80 | (code_point & 0x3F);
/* uv__get_surrogate_value consumed 2 input characters */
w_source_ptr++;
if (w_source_len > 0)
w_source_len--;
}
target_len = target - *target_ptr;
w_source_ptr++;
if (w_source_len > 0)
w_source_len--;
}
if (target != target_end && target_len_ptr != NULL)
/* Did not fill all of the provided buffer, so update the target_len_ptr
* output with the space used. */
*target_len_ptr = target - *target_ptr;
/* Check if input fit into target exactly. */
if (w_source_len < 0 && target == target_end && w_source_ptr[0] == 0)
w_source_len = 0;
*target++ = '\0';
/* Characters remained after filling the buffer, compute the remaining length now. */
if (w_source_len) {
if (target_len_ptr != NULL)
*target_len_ptr = target_len + uv_utf16_length_as_wtf8(w_source_ptr, w_source_len);
return UV_ENOBUFS;
}
return 0;
}

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011, 2018 Ben Noordhuis <info@bnoordhuis.nl> /* Copyright libuv contributors. All rights reserved.
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -26,6 +26,6 @@ unsigned uv__utf8_decode1(const char** p, const char* pe);
* is the number of bytes written to |d|, including the trailing nul byte. * is the number of bytes written to |d|, including the trailing nul byte.
* A return value < 0 is a libuv error code. |s| and |d| can not overlap. * A return value < 0 is a libuv error code. |s| and |d| can not overlap.
*/ */
long uv__idna_toascii(const char* s, const char* se, char* d, char* de); ssize_t uv__idna_toascii(const char* s, const char* se, char* d, char* de);
#endif /* UV_SRC_IDNA_H_ */ #endif /* UV_SRC_IDNA_H_ */

View File

@ -17,12 +17,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
# include "uv/stdint-msvc2008.h"
#else
#include <stdint.h> #include <stdint.h>
#endif
#include "uv.h" #include "uv.h"
#include "uv-common.h" #include "uv-common.h"
@ -135,14 +130,15 @@ static int inet_ntop6(const unsigned char *src, char *dst, size_t size) {
tp += strlen(tp); tp += strlen(tp);
break; break;
} }
tp += sprintf(tp, "%x", words[i]); tp += snprintf(tp, sizeof tmp - (tp - tmp), "%x", words[i]);
} }
/* Was it a trailing run of 0x00's? */ /* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words)) if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words))
*tp++ = ':'; *tp++ = ':';
*tp++ = '\0'; *tp++ = '\0';
if (UV_E2BIG == uv__strscpy(dst, tmp, size)) if ((size_t) (tp - tmp) > size)
return UV_ENOSPC; return UV_ENOSPC;
uv__strscpy(dst, tmp, size);
return 0; return 0;
} }

View File

@ -18,91 +18,73 @@
#include <stddef.h> #include <stddef.h>
typedef void *QUEUE[2]; #define uv__queue_data(pointer, type, field) \
((type*) ((char*) (pointer) - offsetof(type, field)))
/* Private macros. */ #define uv__queue_foreach(q, h) \
#define QUEUE_NEXT(q) (*(QUEUE **) &((*(q))[0])) for ((q) = (h)->next; (q) != (h); (q) = (q)->next)
#define QUEUE_PREV(q) (*(QUEUE **) &((*(q))[1]))
#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q)))
#define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q)))
/* Public macros. */ static inline void uv__queue_init(struct uv__queue* q) {
#define QUEUE_DATA(ptr, type, field) \ q->next = q;
((type *) ((char *) (ptr) - offsetof(type, field))) q->prev = q;
}
/* Important note: mutating the list while QUEUE_FOREACH is static inline int uv__queue_empty(const struct uv__queue* q) {
* iterating over its elements results in undefined behavior. return q == q->next;
*/ }
#define QUEUE_FOREACH(q, h) \
for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q))
#define QUEUE_EMPTY(q) \ static inline struct uv__queue* uv__queue_head(const struct uv__queue* q) {
((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q)) return q->next;
}
#define QUEUE_HEAD(q) \ static inline struct uv__queue* uv__queue_next(const struct uv__queue* q) {
(QUEUE_NEXT(q)) return q->next;
}
#define QUEUE_INIT(q) \ static inline void uv__queue_add(struct uv__queue* h, struct uv__queue* n) {
do { \ h->prev->next = n->next;
QUEUE_NEXT(q) = (q); \ n->next->prev = h->prev;
QUEUE_PREV(q) = (q); \ h->prev = n->prev;
} \ h->prev->next = h;
while (0) }
#define QUEUE_ADD(h, n) \ static inline void uv__queue_split(struct uv__queue* h,
do { \ struct uv__queue* q,
QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \ struct uv__queue* n) {
QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \ n->prev = h->prev;
QUEUE_PREV(h) = QUEUE_PREV(n); \ n->prev->next = n;
QUEUE_PREV_NEXT(h) = (h); \ n->next = q;
} \ h->prev = q->prev;
while (0) h->prev->next = h;
q->prev = n;
}
#define QUEUE_SPLIT(h, q, n) \ static inline void uv__queue_move(struct uv__queue* h, struct uv__queue* n) {
do { \ if (uv__queue_empty(h))
QUEUE_PREV(n) = QUEUE_PREV(h); \ uv__queue_init(n);
QUEUE_PREV_NEXT(n) = (n); \ else
QUEUE_NEXT(n) = (q); \ uv__queue_split(h, h->next, n);
QUEUE_PREV(h) = QUEUE_PREV(q); \ }
QUEUE_PREV_NEXT(h) = (h); \
QUEUE_PREV(q) = (n); \
} \
while (0)
#define QUEUE_MOVE(h, n) \ static inline void uv__queue_insert_head(struct uv__queue* h,
do { \ struct uv__queue* q) {
if (QUEUE_EMPTY(h)) \ q->next = h->next;
QUEUE_INIT(n); \ q->prev = h;
else { \ q->next->prev = q;
QUEUE* q = QUEUE_HEAD(h); \ h->next = q;
QUEUE_SPLIT(h, q, n); \ }
} \
} \
while (0)
#define QUEUE_INSERT_HEAD(h, q) \ static inline void uv__queue_insert_tail(struct uv__queue* h,
do { \ struct uv__queue* q) {
QUEUE_NEXT(q) = QUEUE_NEXT(h); \ q->next = h;
QUEUE_PREV(q) = (h); \ q->prev = h->prev;
QUEUE_NEXT_PREV(q) = (q); \ q->prev->next = q;
QUEUE_NEXT(h) = (q); \ h->prev = q;
} \ }
while (0)
#define QUEUE_INSERT_TAIL(h, q) \ static inline void uv__queue_remove(struct uv__queue* q) {
do { \ q->prev->next = q->next;
QUEUE_NEXT(q) = (h); \ q->next->prev = q->prev;
QUEUE_PREV(q) = QUEUE_PREV(h); \ }
QUEUE_PREV_NEXT(q) = (q); \
QUEUE_PREV(h) = (q); \
} \
while (0)
#define QUEUE_REMOVE(q) \
do { \
QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \
QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \
} \
while (0)
#endif /* QUEUE_H_ */ #endif /* QUEUE_H_ */

View File

@ -33,7 +33,7 @@ static int uv__random(void* buf, size_t buflen) {
#if defined(__PASE__) #if defined(__PASE__)
rc = uv__random_readpath("/dev/urandom", buf, buflen); rc = uv__random_readpath("/dev/urandom", buf, buflen);
#elif defined(_AIX) #elif defined(_AIX) || defined(__QNX__)
rc = uv__random_readpath("/dev/random", buf, buflen); rc = uv__random_readpath("/dev/random", buf, buflen);
#elif defined(__APPLE__) || defined(__OpenBSD__) || \ #elif defined(__APPLE__) || defined(__OpenBSD__) || \
(defined(__ANDROID_API__) && __ANDROID_API__ >= 28) (defined(__ANDROID_API__) && __ANDROID_API__ >= 28)
@ -82,7 +82,7 @@ static void uv__random_done(struct uv__work* w, int status) {
uv_random_t* req; uv_random_t* req;
req = container_of(w, uv_random_t, work_req); req = container_of(w, uv_random_t, work_req);
uv__req_unregister(req->loop, req); uv__req_unregister(req->loop);
if (status == 0) if (status == 0)
status = req->status; status = req->status;

View File

@ -1,3 +1,24 @@
/* Copyright libuv project contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "strscpy.h" #include "strscpy.h"
#include <limits.h> /* SSIZE_MAX */ #include <limits.h> /* SSIZE_MAX */

View File

@ -1,3 +1,24 @@
/* Copyright libuv project contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef UV_STRSCPY_H_ #ifndef UV_STRSCPY_H_
#define UV_STRSCPY_H_ #define UV_STRSCPY_H_
@ -7,7 +28,7 @@
*/ */
#include "uv.h" #include "uv.h"
/* Copies up to |n-1| bytes from |d| to |s| and always zero-terminates /* Copies up to |n-1| bytes from |s| to |d| and always zero-terminates
* the result, except when |n==0|. Returns the number of bytes copied * the result, except when |n==0|. Returns the number of bytes copied
* or UV_E2BIG if |d| is too small. * or UV_E2BIG if |d| is too small.
* *

Some files were not shown because too many files have changed in this diff Show More