Compare commits

...

1381 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
cjihrig
533b738838
2020.04.16, Version 1.36.0 (Stable)
Changes since version 1.35.0:

* build: add aix-common.c for AIX cmake build (Jesse Gorzinski)

* zos: explicitly mark message queue events (Irek Fakhrutdinov)

* zos: move mq check out of loop to save cpu cycles (Irek Fakhrutdinov)

* zos: add checks to ensure behavior of epoll_wait (Irek Fakhrutdinov)

* src: add uv__reallocf() (Ben Noordhuis)

* build: ibmi support for cmake (Jesse Gorzinski)

* build: fix gyp build for Android API >= 28 (Lin Zhang)

* udp: return recvmmsg-ed datagrams in order (Saúl Ibarra Corretgé)

* zos,test: fix spawn_empty_env for shared library build (Richard Lau)

* zos: fix non-Release builds (Richard Lau)

* zos: fix return value on expired nanosleep() call (Richard Lau)

* build: fix z/OS cmake build (Richard Lau)

* test: add a bunch of ASSERT macros (Santiago Gimeno)

* test: remove unused extern declaration (Ben Noordhuis)

* test: canonicalize argv[0] in exepath test (Ben Noordhuis)

* test: simplify platform_init() (Ben Noordhuis)

* ibmi: Fix isatty EBADF handling and refactor (Kevin Adler)

* test: Test EBADF tty handling (Kevin Adler)

* build: make cmake build benchmarks (Ben Noordhuis)

* win: use RtlGenRandom from advapi32.dll directly (Ben Noordhuis)

* android: fix OOB write in uv_interface_addresses() (Lin Zhang)

* test: pass test when hostname is single character (毛毛)

* ibmi: set the highest process priority to -10 (Xu Meng)

* build: remove support for gyp (Ben Noordhuis)

* doc: add note to README on cross-compiling (Ben Noordhuis)

* fs: add uv_fs_lutime() (Sk Sajidul Kadir)

* unix: implement cpu_relax() for arm (David Carlier)

* linux: fix uv__accept4() (twosee)

* win: handle file paths in uv_fs_statfs() (erw7)

* unix: fix uv_os_environ() null pointer check (Rikard Falkeborn)

* win: fix uv_os_environ() null pointer check (Rikard Falkeborn)

* unix: fix compilation on macOS 32-bit architectures (Brad King)

* win: replace alloca() with stack-based array (Ben Noordhuis)
2020-04-15 12:31:21 -04:00
Ben Noordhuis
3e5d261440
win: replace alloca() with stack-based array
`required_vars_value_len` has a fixed number of elements. There is no
need to use alloca() to allocate it.

Refs: https://github.com/libuv/libuv/pull/2781
PR-URL: https://github.com/libuv/libuv/pull/2783
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-14 20:44:00 -04:00
Brad King
815b0766ed
unix: fix compilation on macOS 32-bit architectures
In commit 2475296c (build: make code compilable for iOS on Xcode,
2020-01-18, v1.35.0~47) we added a `defined(TARGET_OS_IPHONE)`
preprocessor condition, but `TARGET_OS_IPHONE` is always defined on
Apple to either 0 or 1.  On 32-bit macOS architectures this
leads to an undefined symbol reference to `_close$NOCANCEL`.
Fix the preprocessor condition to use just `TARGET_OS_IPHONE`.

Refs: https://github.com/libuv/libuv/pull/2639
PR-URL: https://github.com/libuv/libuv/pull/2776
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-14 20:38:35 -04:00
Rikard Falkeborn
cd11c2b1ea
win: fix uv_os_environ() null pointer check
Check the pointer to the allocated memory, not the pointer to the
pointer of the allocated memory. Previously, a failed allocation of
*envitems would lead to a NULL pointer dereference.

PR-URL: https://github.com/libuv/libuv/pull/2778
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2020-04-14 20:27:04 -04:00
Rikard Falkeborn
b44d5ee1b4
unix: fix uv_os_environ() null pointer check
Check the pointer to the allocated memory, not the pointer to the
pointer of the allocated memory. Previously, a failed allocation of
*envitems would lead to a NULL pointer dereference.

PR-URL: https://github.com/libuv/libuv/pull/2778
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2020-04-14 20:24:53 -04:00
erw7
ad618647b9
win: handle file paths in uv_fs_statfs()
GetDiskFreeSpaceW() doesn't handle regular file paths well.
This commit switches to using GetFullPathNameW().

Fixes: https://github.com/libuv/libuv/pull/2683
Refs: https://github.com/libuv/libuv/pull/2691
PR-URL: https://github.com/libuv/libuv/pull/2695
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-04-14 20:15:32 -04:00
twosee
fbafdbf71a
linux: fix uv__accept4()
Refs: https://github.com/libuv/libuv/pull/2665
PR-URL: https://github.com/libuv/libuv/pull/2786
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-14 20:03:41 -04:00
David Carlier
a2689ab250 unix: implement cpu_relax() for arm
Emits yield instruction in ARM mode (mainly needs to pass -march=...).

PR-URL: https://github.com/libuv/libuv/pull/2751
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-14 15:30:30 +02:00
Sk Sajidul Kadir
bd4292385f fs: add uv_fs_lutime()
PR-URL: https://github.com/libuv/libuv/pull/2723
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-14 10:06:33 +02:00
Ben Noordhuis
dc7c874660 doc: add note to README on cross-compiling
PR-URL: https://github.com/libuv/libuv/pull/2682
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-04-07 18:26:03 +02:00
Ben Noordhuis
53f3c687fc build: remove support for gyp
Upstream GYP has been unmaintained for some time now. The only big
downstream user is Node.js and they already maintain GYP build files
for their other dependencies.

This commit removes vcbuild.bat because:

1. it's entirely built around GYP, and
2. duplicates a lot of functionality that cmake provides out of the box

This commit also removes appveyor.yml. It hasn't been used after we
stopped providing prebuilt binaries for Windows about two years ago.

As if that isn't enough, this commit also removes the Android build
scripts. They were wrappers around GYP. Use CMake.

PR-URL: https://github.com/libuv/libuv/pull/2682
Refs: https://github.com/libuv/libuv/pull/2681
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-04-07 18:24:13 +02:00
Xu Meng
d21f5aeab0
ibmi: set the highest process priority to -10
On IBMi PASE, the highest process priority is -10.

PR-URL: https://github.com/libuv/libuv/pull/2642
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-06 09:22:24 -04:00
毛毛
0e8ff951f3 test: pass test when hostname is single character
PR-URL: https://github.com/libuv/libuv/pull/2741
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-06 12:57:32 +02:00
Lin Zhang
7656e981b6 android: fix OOB write in uv_interface_addresses()
PR-URL: https://github.com/libuv/libuv/pull/2767
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-06 12:48:32 +02:00
Ben Noordhuis
335e8a6d12 win: use RtlGenRandom from advapi32.dll directly
At least two people have reported that `LoadLibrary("advapi32.dll")`
fails in some configurations.

Libuv already links against advapi32.dll so let's sidestep the issue
by linking to `RtlGenRandom()` directly instead of looking it up at
runtime.

Fixes: https://github.com/libuv/libuv/issues/2759
PR-URL: https://github.com/libuv/libuv/pull/2762
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-04-06 12:40:48 +02:00
Ben Noordhuis
e15a3c45d8 build: make cmake build benchmarks
PR-URL: https://github.com/libuv/libuv/pull/2771
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-06 12:33:29 +02:00
Kevin Adler
4878e8284f
test: Test EBADF tty handling
PR-URL: https://github.com/libuv/libuv/pull/2753
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-06 05:58:54 -04:00
Kevin Adler
5f1ac8ee36
ibmi: Fix isatty EBADF handling and refactor
In e14c56b, support was added to implement true isatty() support when
running in the IBM i PASE environment, but it did not handle EBADF
properly. This commit fixes the EBADF handling, but because the
handling was a bit more complicated than previously, it was moved to a
separate isatty function to keep the mainline code simpler.

This also documents why we can't just use isatty on PASE a little more
completely.

PR-URL: https://github.com/libuv/libuv/pull/2753
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-06 05:58:34 -04:00
Ben Noordhuis
0ed9692a80 test: simplify platform_init()
PR-URL: https://github.com/libuv/libuv/pull/2755
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-27 23:51:32 +01:00
Ben Noordhuis
fa1da18549 test: canonicalize argv[0] in exepath test
Commit ff29322b ("test: canonicalize test runner path") from 2014
changed the test runner to call `realpath(3)` on `argv[0]` in order
to fix the `get_currentexe` test failing with the autotools build when
the executable path contained symbolic links but that is now causing
the `spawn_reads_child_path` test to fail on z/os with the cmake build.

Fix that by only doing path canonicalization in the `get_currentexe`
test, not always.

An auxiliary fix is applied to the `process_title_threadsafe` test
because it assumed that setting the process title to a long string,
then reading it back produces in the original string.

On some platforms however the maximum size of the process title is
limited to the size of the `argv` vector.

Because the test runner used absolute paths until now, the argv vector
was bigger than it is with relative paths, big enough to let this bad
assumption go unnoticed until now.

Minor fixes are applied to tests that assumed 1024 for the maximum
path size because this commit makes visible that some of the CI matrix
systems support much longer paths.

PR-URL: https://github.com/libuv/libuv/pull/2755
Refs: https://github.com/libuv/libuv/pull/2737#issuecomment-602800431
Refs: https://github.com/libuv/libuv/pull/2754#issuecomment-604015785
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-27 23:51:22 +01:00
Ben Noordhuis
87cbf546d8 test: remove unused extern declaration
PR-URL: https://github.com/libuv/libuv/pull/2755
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-27 23:50:44 +01:00
Santiago Gimeno
53caf044e3
test: add a bunch of ASSERT macros
To make the debugging of test issues easier.

The following integer macros are added:

`ASSERT_EQ(a, b)`, `ASSERT_GE(a, b)`, `ASSERT_GT(a, b)`,
`ASSERT_LE(a, b)`, `ASSERT_LT(a, b)` and `ASSERT_NE(a, b)`.

And its corresponding unsigned integer macros:

`ASSERT_UINT64_EQ(a, b)`, `ASSERT_UINT64_GE(a, b)`,
`ASSERT_UINT64_GT(a, b)`, `ASSERT_UINT64_LE(a, b)`,
`ASSERT_UINT64_LT(a, b)` and `ASSERT_UINT64_NE(a, b)`.

Also these macros for `NULL` and pointer checks:

`ASSERT_NULL(a)`, `ASSERT_NOT_NULL(a)`, `ASSERT_PTR_EQ(a, b)` and
`ASSERT_PTR_NE(a, b)`.

And finally these macros for strings and buffers:

`ASSERT_STR_EQ(a, b)`/`ASSERT_STR_NEQ(a, b)` that use the `strcmp()`
call.
`ASSERT_MEM_EQ(a, b)`/`ASSERT_MEM_NEQ(a, b)` and
`ASSERT_MEM_HEX_EQ(a, b)`/`ASSERT_MEM_HEX_NEQ(a, b)` that use the
`memcmp()` call. The former, prints the data in string format and the
latter in hex format.

These macros are used in the following way:
```c
ASSERT_EQ(UV_EINVAL, uv_loop_close(&loop));
```

With a sample output that would be as follows:
```
Assertion failed in test/test-loop-close.c on line 44: `UV_EINVAL == uv_loop_close(&loop)` (-22 == -16)
```

To view multiples examples if their use, the `test-ipc.c` file has been
modified to use these macros.

The `_ISOC99_SOURCE` is defined to support `inttypes.h` in `z/OS`.

PR-URL: https://github.com/libuv/libuv/pull/2739
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-27 14:51:49 +01:00
Richard Lau
c10431165a
build: fix z/OS cmake build
- Correct CMAKE_SYSTEM_NAME.
- Exclude pthread lib on z/OS.
- Remove deleted src/unix/pthread-barrier.c.
- Set LIBPATH for shared library test.

PR-URL: https://github.com/libuv/libuv/pull/2737
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-03-24 09:34:06 -04:00
Richard Lau
875a4fe653
zos: fix return value on expired nanosleep() call
In the emulated nanosleep() function on z/OS an EAGAIN error from
BPX1CTW/BPX4CTW indicates that the timeout has expired. In that
case return 0 and not -1.

PR-URL: https://github.com/libuv/libuv/pull/2737
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-03-24 09:33:58 -04:00
Richard Lau
a9c58e72a3
zos: fix non-Release builds
z/OS doesn't support POSIX semaphores. On Release builds the code
paths that reference POSIX semaphore functions (e.g. sem_init())
are optimized away so linking succeeds but on a non-Release build
the references to the unavailable functions result in unresolved
symbol errors.

Stub the unavailable POSIX semaphore functions on z/OS as so the
code can link on non-Release builds.

PR-URL: https://github.com/libuv/libuv/pull/2737
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-03-24 09:33:47 -04:00
Richard Lau
1099d298d4
zos,test: fix spawn_empty_env for shared library build
z/OS uses LIBPATH instead of LD_LIBRARY_PATH for the search path
for shared libraries.

PR-URL: https://github.com/libuv/libuv/pull/2737
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-03-24 09:33:39 -04:00
Saúl Ibarra Corretgé
d9cd7d437d udp: return recvmmsg-ed datagrams in order
When recvmmsg support was added it returned the datagrams in reverse
received order, which may impact some applications.

To restore the previous behavior, we call recv_cb one last time with
nread == 0 and addr == NULL so applications can free the buffer.

PR-URL: https://github.com/libuv/libuv/pull/2736
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-03-24 08:27:00 +01:00
Lin Zhang
055e89f637 build: fix gyp build for Android API >= 28
PR-URL: https://github.com/libuv/libuv/pull/2749
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-03-23 17:01:55 +01:00
Jesse Gorzinski
104255f5af build: ibmi support for cmake
PR-URL: https://github.com/libuv/libuv/pull/2729
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Kevin Adler <kadler@us.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-18 12:50:10 -04:00
Ben Noordhuis
1bcfbfd003
src: add uv__reallocf()
Modeled after FreeBSD's `reallocf(3)`: a version of `realloc(3)` that
frees the memory when reallocation fails, simplifying error handling in
many cases.

PR-URL: https://github.com/libuv/libuv/pull/2735
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-03-15 10:00:15 -04:00
Irek Fakhrutdinov
506e4bee7b zos: add checks to ensure behavior of epoll_wait
PR-URL: https://github.com/libuv/libuv/pull/2013
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Signed-off-by: Irek Fakhrutdinov <ifakhrutdinov@rocketsoftware.com>
2020-03-15 11:32:10 +01:00
Irek Fakhrutdinov
7d988e0763 zos: move mq check out of loop to save cpu cycles
PR-URL: https://github.com/libuv/libuv/pull/2013
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-15 11:31:24 +01:00
Irek Fakhrutdinov
f06734057b zos: explicitly mark message queue events
The os390 epoll_wait implementation uses poll() to detect events in
both file descriptors and the message queue used for file system
events. The only message queue ID is always placed at the end of the
array passed to the poll() call. When the poll() call returns all FDs
and the message queue are checked for events by iterating through that
array. In order to distinguish the message queue from the FDs its ID
value is compared with the only message queue ID we have and if it
matches the message queue handler function is called.

When the message queue ID is relatively small, it may have the same
value as the value of one of the file descriptors. If this happens,
the message queue handler is called for the matching file descriptor,
and this call fails. The file descriptor ends up being unhandled and
this makes the next poll() call to return immediately. Eventually this
will happen again and again, leading to an infinite busy loop and high
CPU usage.

To prevent the incorrect interpretation of file descriptors as the
message queue, a new field has been added to the epoll event struct.
This field is checked instead of the ID value and the message queue
handler function is never called for file descriptors.

PR-URL: https://github.com/libuv/libuv/pull/2013
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-15 11:31:21 +01:00
Jesse Gorzinski
742e0ba7df
build: add aix-common.c for AIX cmake build
PR-URL: https://github.com/libuv/libuv/pull/2731
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2020-03-13 13:18:37 -04:00
cjihrig
584ba94885
Now working on version 1.35.1
Fixes: https://github.com/libuv/libuv/issues/2709
2020-03-11 12:25:36 -04:00
cjihrig
87ee20d512
Add SHA to ChangeLog 2020-03-11 12:23:28 -04:00
cjihrig
e45f1ec38d
2020.03.12, Version 1.35.0 (Stable)
Changes since version 1.34.2:

* src: android build fix (David Carlier)

* build: make code compilable for iOS on Xcode (ssrlive)

* ibmi: skip unsupported fs test cases (Xu Meng)

* ibmi: ensure that pipe backlog is not zero (Xu Meng)

* test,udp6: fix udp_ipv6 test flakiness (Jameson Nash)

* test: fix fs_event_watch_dir_recursive flakiness (Santiago Gimeno)

* pipe: disallow listening on an IPC pipe (Witold Kręcicki)

* build,cmake: improve buil experience (Isabella Muerte)

* unix: remove support for FreeBSD < 10 (Saúl Ibarra Corretgé)

* linux: simplify uv__accept() (Ben Noordhuis)

* linux: assume presence of SOCK_CLOEXEC flag (Ben Noordhuis)

* linux: simplify uv__dup2_cloexec() (Ben Noordhuis)

* freebsd,linux: simplify uv__make_socketpair() (Ben Noordhuis)

* unix: fix error handling in uv__make_socketpair() (Ben Noordhuis)

* freebsd,linux: simplify uv__make_pipe() (Ben Noordhuis)

* unix: fix error handling in uv__make_pipe() (Ben Noordhuis)

* linux: simplify uv__async_eventfd() (Ben Noordhuis)

* linux: assume the presence of inotify system calls (Ben Noordhuis)

* doc: strip ICC profile from 2 jpg files (Dominique Dumont)

* unix: make uv_tcp_keepalive predictable (Manuel BACHMANN)

* docs: uv_setup_args() may take ownership of argv (Ben Noordhuis)

* unix: fix error path in uv_setup_args() (Ben Noordhuis)

* unix: fix size check in uv_get_process_title() (Ben Noordhuis)

* doc: add erw7 to maintainers (erw7)

* test: fixed udp4_echo_server implementation (Marek Vavrusa)

* test: added udp ping benchmark (1,10,100 pingers) (Marek Vavrusa)

* freebsd,linux: add recvmmsg() + sendmmsg() udp implementation (Marek
  Vavrusa)

* win,pipe: DRY/simplify some code paths (Jameson Nash)

* win: address some style nits (Jameson Nash)

* win,pipe: ensure `req->event_handle` is defined (Elliot Saba)

* win,pipe: consolidate overlapped initialization (Elliot Saba)

* win,pipe: erase event_handle after deleting pointer (Jameson Nash)

* build: fix android cmake build, build missing file (Ben Noordhuis)

* test: skip some UDP tests on IBMi (Xu Meng)

* test: skip some spawn test cases on IBMi (Xu Meng)

* src: fix wrong method name in comment (TK-one)

* test: add UV_TIMEOUT_MULTIPLIER environment var (Ben Noordhuis)

* unix: fix uv_cpu_info always returning UV_ENOTDIR on OpenBSD (Ben
  Davies)

* test: skip the pwd_shell test on IBMi (Xu Meng)

* win,tty: Change to restore cursor shape with uv_tty_reset() (erw7)

* win,tty: Added set cursor style to CSI sequences (erw7)

* test: handle EINTR, fix EOF check in poll test (Ben Noordhuis)

* unix: use socklen_t instead of size_t (Ben Noordhuis)

* doc: fix header file location (TK-one)

* unix: fix signal handle closing deferral (Ben Noordhuis)

* ibmi: set the amount of memory in use to zero (Xu Meng)

* zos: return on realloc failure in scandir() (Milad Farazmand)

* zos: fix scandir() error path NULL pointer deref (Ben Noordhuis)
2020-03-11 12:23:27 -04:00
Ben Noordhuis
a9974da019 zos: fix scandir() error path NULL pointer deref
Commit b5155dd2 ("zos: return on realloc failure in scandir()")
introduced a bug where `nl` is dereferenced when it's NULL after
reallocation fails.

PR-URL: https://github.com/libuv/libuv/pull/2734
Refs: https://github.com/libuv/libuv/pull/2693
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-11 16:55:02 +01:00
Milad Farazmand
b5155dd2ac zos: return on realloc failure in scandir()
Fixes: https://github.com/libuv/libuv/issues/2692
PR-URL: https://github.com/libuv/libuv/pull/2693
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-10 11:29:53 +01:00
Xu Meng
af7143b6f2 ibmi: set the amount of memory in use to zero
On IBMi PASE, the amount of memory in use includes storage used for
memory and disks. So we hard-code the amount of memory in use to zero
on IBMi, based on discussion in nodejs/node#32043.

PR-URL: https://github.com/libuv/libuv/pull/2732
Refs: https://github.com/nodejs/node/pull/32043
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-03-10 11:00:03 +01:00
Ben Noordhuis
70469dcaa6 unix: fix signal handle closing deferral
The way libuv handled closing of `uv_signal_t` handles with pending
events introduced an infidelity where `uv_loop_alive()` returned false
while the signal handle was still in the closing-but-not-closed state.

Fixes: https://github.com/libuv/libuv/issues/2721
PR-URL: https://github.com/libuv/libuv/pull/2722
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-03-10 10:58:29 +01:00
TK-one
e8644693ea doc: fix header file location
PR-URL: https://github.com/libuv/libuv/pull/2720
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-04 09:29:50 +01:00
Ben Noordhuis
4e38e2a5bc unix: use socklen_t instead of size_t
It has been reported that it generates (otherwise harmless)
`-Wshorten-64-to-32` compiler warnings when building for iOS.

Fixes: https://github.com/libuv/libuv/issues/2714
PR-URL: https://github.com/libuv/libuv/pull/2716
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2020-03-02 11:14:44 +01:00
Ben Noordhuis
af3330b723 test: handle EINTR, fix EOF check in poll test
The test had two bugs:

1. It didn't handle EINTR when calling send() and recv().

2. It checked `errno` on EOF but that's only set when the return value
   is less than zero.

PR-URL: https://github.com/libuv/libuv/pull/2713
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-02-29 09:37:56 +01:00
erw7
288a06727b win,tty: Added set cursor style to CSI sequences
PR-URL: https://github.com/libuv/libuv/pull/1884
Refs: https://github.com/libuv/libuv/issues/1874
Co-authored-by: Bert Belder <bertbelder@gmail.com>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2020-02-29 14:11:36 +09:00
erw7
73ca4ac0d1 win,tty: Change to restore cursor shape with uv_tty_reset()
PR-URL: https://github.com/libuv/libuv/pull/1884
Co-authored-by: Bert Belder <bertbelder@gmail.com>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2020-02-29 14:11:16 +09:00
Xu Meng
174a6edf0d
test: skip the pwd_shell test on IBMi
On IBMi PASE, the value of pw_shell is always an empty string.

PR-URL: https://github.com/libuv/libuv/pull/2592
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-02-28 14:03:38 -05:00
Ben Davies
7611294da9
unix: fix uv_cpu_info always returning UV_ENOTDIR on OpenBSD
The wrong names and name sizes were being used with `sysctl(2)`, which
in particular made the call to get the machine's CPU speed always fail
with ENOTDIR.

PR-URL: https://github.com/libuv/libuv/pull/2685
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-28 13:54:43 -05:00
Ben Noordhuis
0f37283dae
test: add UV_TIMEOUT_MULTIPLIER environment var
Add an environment variable that lets people running the test suite
specify a timeout multiplier. Useful when running the tests on slow
machines.

Fixes: https://github.com/libuv/libuv/issues/2678
PR-URL: https://github.com/libuv/libuv/pull/2679
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-02-28 13:50:28 -05:00
TK-one
92808aeab5
src: fix wrong method name in comment
PR-URL: https://github.com/libuv/libuv/pull/2689
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-28 13:33:57 -05:00
Xu Meng
2abfa11a2c
test: skip some spawn test cases on IBMi
On IBMi PASE, there is no root user or nobody user.
User may grant root-like privileges, including setting uid/gid
to 0.

PR-URL: https://github.com/libuv/libuv/pull/2676
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-02-28 13:21:43 -05:00
Xu Meng
a9a371e4cf test: skip some UDP tests on IBMi
The watcher_cross_stop test timeout with too many AF_INET sockets
on IBMi PASE. In the udp_connect test, UDP connections can not be
disconnected with AF_UNSPEC on IBMi PASE.

PR-URL: https://github.com/libuv/libuv/pull/2673
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-02-28 11:51:36 +01:00
Ben Noordhuis
c07a7c6cfa build: fix android cmake build, build missing file
Commit f261d04d ("android: enable getentropy on Android >= 28") didn't
add random-getentropy.c to the set of files to build on Android. This
commit rectifies that.

Fixes: https://github.com/libuv/libuv/issues/2702
PR-URL: https://github.com/libuv/libuv/pull/2704
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-02-28 11:47:55 +01:00
Jameson Nash
7de386c584 win,pipe: erase event_handle after deleting pointer
PR-URL: https://github.com/libuv/libuv/pull/2620
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2020-02-27 09:13:04 +01:00
Elliot Saba
618c9212c2 win,pipe: consolidate overlapped initialization
PR-URL: https://github.com/libuv/libuv/pull/2620
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2020-02-27 09:12:59 +01:00
Elliot Saba
56fc3de48c win,pipe: ensure req->event_handle is defined
Previously, this field was being used uninitialized, leading to the
uv_write call returning failure. This only happens in the rare fallback
path where UV_HANDLE_EMULATE_IOCP is set, meaning that the OVERLAPPED
opened pipe already was associated with an IOCP.

Fixes: https://github.com/libuv/libuv/issues/629
PR-URL: https://github.com/libuv/libuv/pull/2620
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2020-02-27 09:12:52 +01:00
Jameson Nash
a5da270f78 win: address some style nits
PR-URL: https://github.com/libuv/libuv/pull/2620
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2020-02-27 09:12:46 +01:00
Jameson Nash
4fa5fb9f7f win,pipe: DRY/simplify some code paths
PR-URL: https://github.com/libuv/libuv/pull/2620
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2020-02-27 09:12:09 +01:00
Marek Vavrusa
3d7136639a freebsd,linux: add recvmmsg() + sendmmsg() udp implementation
This commits adds support for recvmmsg() and sendmmsg() extensions to
recvmsg() and sendmsg() that allows the caller to receive and send
multiple message from a socket using a single system call. This has
performance benefits for some applications.

Co-authored-by: Ondřej Surý <ondrej@sury.org>
Co-authored-by: Witold Kręcicki <wpk@culm.net>

PR-URL: https://github.com/libuv/libuv/pull/2532
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-02-20 11:52:54 +01:00
Marek Vavrusa
56598f3d10 test: added udp ping benchmark (1,10,100 pingers)
The UDP pummel benchmark does not model usual UDP servers well,
in UDP services like DNS, DHCP or NTP, there is usually just one
socket bound to the registered port and a large number of
requestors asking queries, this benchmark is simple 1 sender : 1 receiver thread
benchmark with multiple senders multiplexing on the event loop.

The test reports number of senders and attained rate of requests,
and is based on TCP benchmark-ping-pong.c.

PR-URL: https://github.com/libuv/libuv/pull/2532
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-02-20 11:52:18 +01:00
Marek Vavrusa
618533b7e3 test: fixed udp4_echo_server implementation
It was missing socket binding and the on_recv() callback was wrong.

PR-URL: https://github.com/libuv/libuv/pull/2532
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-02-20 11:51:16 +01:00
erw7
18ff13c71e doc: add erw7 to maintainers
PR-URL: https://github.com/libuv/libuv/pull/2662
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-02-18 17:38:54 +09:00
Ben Noordhuis
7b28d36056 unix: fix size check in uv_get_process_title()
It was checking that the destination buffer was big enough to hold
the total capacity of the process title (the total storage of argv)
when instead it should be checking that it's big enough to hold
the _current_ process title, which is normally much shorter.

Fixes: https://github.com/libuv/libuv/issues/2666
PR-URL: https://github.com/libuv/libuv/pull/2668
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-02-08 12:28:34 +01:00
Ben Noordhuis
ea3a5318ab unix: fix error path in uv_setup_args()
Only update the `process_title` struct on success, otherwise it points
to memory libuv doesn't own. Notably, libuv only owns `argv[0]` _after_
copying the argv table.

PR-URL: https://github.com/libuv/libuv/pull/2668
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-02-08 12:28:34 +01:00
Ben Noordhuis
fb4c563132 docs: uv_setup_args() may take ownership of argv
PR-URL: https://github.com/libuv/libuv/pull/2668
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-02-08 12:28:34 +01:00
Manuel BACHMANN
21aff3b4c4
unix: make uv_tcp_keepalive predictable
Current UNIX systems define various defaults for
TCP_KEEPINTVL and TCP_KEEPCNT, which makes the time
between TCP_KEEPIDLE delay is reached and timeout
effectively occurs unpredictable (Linux: /proc/sys
/net/ipv4/tcp_keepalive_intvl;tcp_keepalive_probes).

Do the following: set TCP_KEEPINTVL to 1 second (same
as Win32 default) and TCP_KEEPCNT to 10 times (same
as Win32 hardcoded value).

Fixes: https://github.com/libuv/libuv/issues/2664
PR-URL: https://github.com/libuv/libuv/pull/2669
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-07 22:52:45 +01:00
Dominique Dumont
fb5a35ee91
doc: strip ICC profile from 2 jpg files
The embedded color profiles are proprietary data. Considering that
embedding a color profile in a image is not necessary when color
accuracy is not important, it's better to strip them.

This was done with:

convert -strip docs/src/static/diagrams.key/Data/st0-311.jpg \
  docs/src/static/diagrams.key/Data/st0-311.jpg
convert -strip docs/src/static/diagrams.key/Data/st1-475.jpg \
  docs/src/static/diagrams.key/Data/st1-475.jpg

convert command comes from ImageMagick project.

Fixes: https://github.com/libuv/libuv/issues/2670
PR-URL: https://github.com/libuv/libuv/pull/2672
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-07 22:08:04 +01:00
Ben Noordhuis
24d73d065f linux: assume the presence of inotify system calls
This lets us get rid of the system call wrappers and simplify
the fs event watcher code a great deal.

All system calls were added well before 2.6.32, our baseline kernel.

PR-URL: https://github.com/libuv/libuv/pull/2665
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-04 16:36:59 +01:00
Ben Noordhuis
dfd64933d5 linux: simplify uv__async_eventfd()
Assume the presence of the eventfd2() system call on Linux. It was added
in 2.6.27 and our baseline is 2.6.32.

PR-URL: https://github.com/libuv/libuv/pull/2665
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-04 16:36:59 +01:00
Ben Noordhuis
1b92af1343 unix: fix error handling in uv__make_pipe()
This commit checks that setting the close-on-exec and non-blocking flags
on the file descriptors succeeds, and closes the file descriptors when
it fails.

PR-URL: https://github.com/libuv/libuv/pull/2665
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-04 16:36:59 +01:00
Ben Noordhuis
233490819c freebsd,linux: simplify uv__make_pipe()
Assume the presence of the pipe2() system call. It was added
in FreeBSD 10 and Linux 2.6.27.

PR-URL: https://github.com/libuv/libuv/pull/2665
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-04 16:36:59 +01:00
Ben Noordhuis
06616db362 unix: fix error handling in uv__make_socketpair()
This commit checks that setting the close-on-exec flag on the file
descriptors succeeds, and closes the file descriptors when it fails.

PR-URL: https://github.com/libuv/libuv/pull/2665
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-04 16:36:59 +01:00
Ben Noordhuis
ab6fc15a16 freebsd,linux: simplify uv__make_socketpair()
Assume the presence of the SOCK_CLOEXEC flag. It was added in FreeBSD 10
and before Linux 2.6.32.

PR-URL: https://github.com/libuv/libuv/pull/2665
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-04 16:36:59 +01:00
Ben Noordhuis
0574343b31 linux: simplify uv__dup2_cloexec()
Assume the presence of the dup3() system call on Linux. It was added
in 2.6.27 and our baseline is 2.6.32.

PR-URL: https://github.com/libuv/libuv/pull/2665
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-04 16:36:59 +01:00
Ben Noordhuis
13e5b0cf49 linux: assume presence of SOCK_CLOEXEC flag
PR-URL: https://github.com/libuv/libuv/pull/2665
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-04 16:36:59 +01:00
Ben Noordhuis
067473ed5c linux: simplify uv__accept()
Assume the presence of the accept4() system call on Linux. It was added
in 2.6.28 and our baseline is 2.6.32. That lets us get rid of the system
call wrapper and the fallback logic in uv__accept().

PR-URL: https://github.com/libuv/libuv/pull/2665
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-02-04 16:36:59 +01:00
Saúl Ibarra Corretgé
9f1a052094 unix: remove support for FreeBSD < 10
PR-URL: https://github.com/libuv/libuv/pull/2663
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-02-04 13:55:29 +01:00
Isabella Muerte
018363a163 build,cmake: improve buil experience
* Add two policies to reduce "regex" if statements
* Add CMAKE_MODULE_PATH for custom CMake modules
* Remove hard-coded C89 flag
* C compiler extensions are enabled via CMake
* The C standard minimum of C90 is now required (As C89 was never an
  international standard)
* CMAKE_C_VISIBILITY_PRESET is now used to set symbols to hidden
  instead of a hard-coded compiler flag
* Add (unused) LIBUV_BUILD_BENCH option
  This will allow #1886 to be implemented in a later commit
* Add compiler flag checks for gcc-style warnings
  This allows more compilers to be used with the same compiler settings
* Move uv_test_sources to be under the LIBUV_BUILD_TESTS check
  This clears up a lot of CMakeLists.txt file to allow us to work on the
  "core" of the project. We will eventually be able to move all the tests
  to tests/CMakeLists.txt
* Make the compiler flag checks more readable
* Fix indentation of test sources per request
* Fix target_include_directories when installing versus building
* Improve performance for unix when creating the libuv.pc.in file
* Improve performance when setting `UV_VERSION_MAJOR`
* Fix typo in lint-no-unused-parameter generator expression
* Fix clang-cl detection on newer CMake versions
* Fix targeting newer windows versions
* Fix building under Windows with Visual Studio Generator

PR-URL: https://github.com/libuv/libuv/pull/2504
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2020-02-04 08:30:48 +01:00
Witold Kręcicki
a629688008 pipe: disallow listening on an IPC pipe
PR-URL: https://github.com/libuv/libuv/pull/2559
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2020-01-31 11:09:16 +01:00
Santiago Gimeno
1ff8420661
test: fix fs_event_watch_dir_recursive flakiness
This test sometimes times out on `macos` because not all the expected events are
received: the create and delete events may coalesce. To avoid it, make sure
not to start deleting the files until all the create events are received.

Also, take into account in the test that a create event of the `subdir`
directory can be detected even though we start watching for the events after its
creation.

PR-URL: https://github.com/libuv/libuv/pull/2648
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-01-27 22:36:25 +01:00
Jameson Nash
16a05637ef test,udp6: fix udp_ipv6 test flakiness
We seem to be receiving unrelated network traffic from other libuv
tests. Add some debugging output, in case that happens in the future,
and filter out any messages received that we didn't send.

Fixes: https://github.com/libuv/libuv/issues/2130
Fixes: https://github.com/libuv/libuv/issues/2467
PR-URL: https://github.com/libuv/libuv/pull/2617
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-01-27 14:58:56 -05:00
Xu Meng
1b045d464d
ibmi: ensure that pipe backlog is not zero
On IBMi PASE, listen(pipe_fd, backlog=0) leads to "Connection refused" error

PR-URL: https://github.com/libuv/libuv/pull/2641
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-01-26 17:55:34 +01:00
Xu Meng
ed1dc8537e
ibmi: skip unsupported fs test cases
On IBMi PASE, we need to skip some file permission tests for `root`.
And the file stat of symbolic links are different as well.

PR-URL: https://github.com/libuv/libuv/pull/2628
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-01-26 17:51:49 +01:00
ssrlive
2475296c4e
build: make code compilable for iOS on Xcode
Fixes: https://github.com/libuv/libuv/issues/2638
PR-URL: https://github.com/libuv/libuv/pull/2639
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-01-26 17:27:56 +01:00
David Carlier
8270add421 src: android build fix
ip_mreq_source struct are not defined in Android NDK <= 16, regardless
of the API level.

Fixes: https://github.com/libuv/libuv/issues/2633
PR-URL: https://github.com/libuv/libuv/pull/2637
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-01-26 17:22:26 +01:00
cjihrig
3ac654c8a2
Now working on version 1.34.3
Fixes: https://github.com/libuv/libuv/issues/2646
2020-01-23 09:22:55 -05:00
cjihrig
a5a6bf7052
Add SHA to ChangeLog 2020-01-23 09:20:03 -05:00
cjihrig
f868c9ab0c
2020.01.24, Version 1.34.2 (Stable)
Changes since version 1.34.1:

* misc: adjust stalebot deadlines (Jameson Nash)

* test: fix env-vars flakiness (cjihrig)

* test: avoid truncating output lines (Jameson Nash)

* darwin: stop calling SetApplicationIsDaemon() (Ben Noordhuis)

* ibmi: implement uv_interface_addresses() (Xu Meng)

* osx,fsevent: fix race during uv_loop_close (Jameson Nash)

* osx,fsevent: clear pointer when deleting it [NFCI] (Jameson Nash)

* Revert "aix: replace ECONNRESET with EOF if already closed" (Jameson
  Nash)

* unix: handle uv__open_cloexec return value correctly (Anna Henningsen)
2020-01-23 09:20:02 -05:00
Anna Henningsen
02e7a78628
unix: handle uv__open_cloexec return value correctly
`uv__open_cloexec()` already returns a libuv error code in case
of failure, and not `-1` like syscalls do.

Fixes: https://github.com/nodejs/help/issues/2099
PR-URL: https://github.com/libuv/libuv/pull/2645
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-01-21 20:02:56 +01:00
Jameson Nash
8249bd19cf Revert "aix: replace ECONNRESET with EOF if already closed"
This reverts commit ca08b48252, for the
same reasons that it was reverted the last time it was merged.

Refs: https://github.com/libuv/libuv/pull/475
Refs: https://github.com/libuv/libuv/pull/2447
PR-URL: https://github.com/libuv/libuv/pull/2602
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2020-01-21 12:36:11 -05:00
Jameson Nash
07ddcb3052 osx,fsevent: clear pointer when deleting it [NFCI]
Set this to NULL just before disposing it to make mistakes more
painfully obvious, hopefully.

PR-URL: https://github.com/libuv/libuv/pull/2626
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-01-21 12:29:20 -05:00
Jameson Nash
c8a3f5c93c osx,fsevent: fix race during uv_loop_close
The mutex also needs to protect the access to the state->loop variable,
since that's owned by the child thread and will be destroyed as soon as
it processes our message.

Fixes: https://github.com/libuv/libuv/issues/2625
PR-URL: https://github.com/libuv/libuv/pull/2626
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-01-21 12:29:20 -05:00
Xu Meng
c68111759d ibmi: implement uv_interface_addresses()
On IBMi PASE we need to call Qp2getifaddrs() to get the network
interface configurations. And to call QDCRLIND to get the physical
addresses.

PR-URL: https://github.com/libuv/libuv/pull/2614
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-01-21 09:32:11 +01:00
Ben Noordhuis
6e3e422c2d darwin: stop calling SetApplicationIsDaemon()
It's been reported that calling this function causes the Core Graphics
framework to start reporting bogus values.

Commit 565cdd16 ('Revert "darwin: speed up uv_set_process_title()"')
attempted to fix this but apparently merely postponed the moment
when `CGDisplayPixelsWide()` and friends start reporting bogus values.

The Chromium code base mentions that calling `SetApplicationIsDaemon()`
prevents the HIServices framework from terminating the process when it
can't connect to launchservicesd.

Libuv itself doesn't use HIServices but it's possible that the libuv
user does. If said user doesn't call `SetApplicationIsDaemon()`, it's
possible this commit introduces an observable change in behavior.

The `SetApplicationIsDaemon()` call was introduced in commit 08e0e63f
("darwin: avoid calling GetCurrentProcess") from October 2013 to work
around a bug in macos 10.9 where the Activity Monitor showed the program
as "Not responding."

Fixes: https://github.com/libuv/libuv/issues/2566 (for real, hopefully)
Fixes: https://github.com/nodejs/node/issues/31328
PR-URL: https://github.com/libuv/libuv/pull/2593
Refs: https://cs.chromium.org/chromium/src/sandbox/mac/system_services.cc?l=26&rcl=a06d2fe5a279ddecd358d919d461080e2c53c92e
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-01-21 09:25:49 +01:00
Jameson Nash
64e5a65bc9 test: avoid truncating output lines
If the output data contained a null byte (for example, because it was
really utf16), we'd truncate the output there. This commonly would
manifest as the output on the CI bot being:

> not ok 308 - threadpool_cancel_random
> # exit code 3
> # Output from process :
> # A

Now we'll attempt to print out the whole error message as text (albeit
with the wrong encoding, but the ascii content should still nearly
always be readable).

PR-URL: https://github.com/libuv/libuv/pull/2611
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-01-16 17:46:31 -05:00
cjihrig
6d9e89be8b
test: fix env-vars flakiness
It has been observed that running the tests via shell script
can cause special environment variables to be missing. This
commit ensures that a special Windows environment variable is set.

Fixes: https://github.com/libuv/libuv/issues/2622
PR-URL: https://github.com/libuv/libuv/pull/2624
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-01-13 20:48:55 -05:00
Jameson Nash
a740889e70 misc: adjust stalebot deadlines
PR-URL: https://github.com/libuv/libuv/pull/2498
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-01-13 12:07:16 -05:00
cjihrig
33cb9f4a3f
Now working on version 1.34.2
Fixes: https://github.com/libuv/libuv/issues/2595
2020-01-12 18:35:34 -05:00
cjihrig
9eff868308
Add SHA to ChangeLog 2020-01-12 18:33:21 -05:00
cjihrig
8aa5636ec7
2020.01.13, Version 1.34.1 (Stable)
Changes since version 1.34.0:

* unix: fix -Wstrict-aliasing compiler warning (Ben Noordhuis)

* unix: cache address of dlsym("mkostemp") (Ben Noordhuis)

* build: remove -pedantic from compiler flags (Ben Noordhuis)

* Revert "darwin: assume pthread_setname_np() is available" (Ben
  Noordhuis)

* Revert "darwin: speed up uv_set_process_title()" (Ben Noordhuis)

* darwin: assume pthread_setname_np() is available (Ben Noordhuis)

* ibmi: fix the false isatty() issue on IBMi (Xu Meng)

* test: fix test failure under NetBSD and OpenBSD (David Carlier)

* test: skip some test cases on IBMi (Xu Meng)

* test: skip uv_(get|set)_process_title on IBMi (Xu Meng)

* doc: remove binaries for Windows from README (Richard Lau)

* unix: fix -Wunused-but-set-variable warning (George Zhao)

* unix: pass sysctl size arg using ARRAY_SIZE macro (David Carlier)

* test: disallow running the test suite as root (cjihrig)

* unix: suppress -Waddress-of-packed-member warning (Ben Noordhuis)

* misc: make more tags "not-stale" (Jameson Nash)

* test: fix pthread memory leak (Trevor Norris)

* docs: delete socks5-proxy sample (Jameson Nash)

* ibmi: fix the CMSG length issue (Xu Meng)

* docs: fix formatting (Jameson Nash)

* unix: squelch fchmod() EPERM on CIFS share (Ben Noordhuis)

* docs: fix linkcheck (Jameson Nash)

* docs: switch from linux.die.net to man7.org (Jameson Nash)

* win: remove abort when non-IFS LSP detection fails (virtualyw)

* docs: clarify that uv_pipe_t is a pipe (Jameson Nash)

* win,tty: avoid regressions in utf-8 handling (Jameson Nash)

* win: remove bad assert in uv_loop_close (Jameson Nash)

* test: fix -fno-common build errors (Ben Noordhuis)

* build: turn on -fno-common to catch regressions (Ben Noordhuis)

* test: fix fs birth time test failure (Ben Noordhuis)

* tty,unix: avoid affecting controlling TTY (Jameson Nash)
2020-01-12 18:33:21 -05:00
Jameson Nash
1399d851b1
tty,unix: avoid affecting controlling TTY
Since this re-open logic is supposed to be transparent to the parent
program, this flag helps ensure that there are no unintended
side-effects. This flag is already the default (and only possible
option) on FreeBSD. Normally, Linux will also act as if you passed
NOCTTY. However, it appears that mac OS sometimes strips the parent
process of its controlling terminal if you don't pass this flag.

Fixes: https://github.com/libuv/libuv/issues/973
Fixes: https://github.com/JuliaLang/julia/issues/16398
PR-URL: https://github.com/libuv/libuv/pull/2619
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-01-12 17:40:13 -05:00
Ben Noordhuis
22ebdc5c35
test: fix fs birth time test failure
The test checks that the creation time equals the birth time on systems
that support the notion of birth time (macOS, Linux.)

The test was flaky because there was a write taking place between the
creation of the file and the fstat() call, sometimes changing the ctime
by fractions of milliseconds... First fstat(), only then write().

Fixes: https://github.com/libuv/libuv/issues/2235
PR-URL: https://github.com/libuv/libuv/pull/2621
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-01-12 17:36:08 -05:00
Ben Noordhuis
c7f99c7ba5 build: turn on -fno-common to catch regressions
Refs: https://github.com/libuv/libuv/issues/2603
PR-URL: https://github.com/libuv/libuv/pull/2604
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-01-10 11:10:25 -05:00
Ben Noordhuis
d42a108583 test: fix -fno-common build errors
Fixes: https://github.com/libuv/libuv/issues/2603
PR-URL: https://github.com/libuv/libuv/pull/2604
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-01-10 11:09:04 -05:00
Jameson Nash
623aa05ac7 win: remove bad assert in uv_loop_close
This assert was stronger than necessary (we assert the actual condition
later in this function). And it's vulnerable to a race condition
occurring in uv__work_done where we drain the work queue but still have
a stale message on this object.

Fixes: https://github.com/libuv/libuv/issues/2610
PR-URL: https://github.com/libuv/libuv/pull/2615
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-01-10 11:03:34 -05:00
Jameson Nash
3016fbc40b win,tty: avoid regressions in utf-8 handling
This code already had special handling for decoding utf-8
characters correctly for the UCS-2 conhost
(trailing incomplete bytes and characters > 0xFFFF).
Rather than trying to duplicate that, we can simply
delete the duplicate code-path and selectively disable
the parts that do not apply.

PR-URL: https://github.com/libuv/libuv/pull/1965
Ref: https://github.com/JuliaLang/julia/issues/27267
Co-authored-by: Mustafa M. <mus-m@outlook.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-01-09 10:59:36 -05:00
Jameson Nash
02a36bb3ba docs: clarify that uv_pipe_t is a pipe
Some people have misread this section to imply that libuv does not
support Unix `pipe` objects, while it only should be saying that the
UV_CREATE_PIPE makes a socketpair. Clarify the docs to say specifically
that `uv_pipe_t` represents any local file stream.

PR-URL: https://github.com/libuv/libuv/pull/2607
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-01-09 10:38:02 -05:00
virtualyw
e1fad5a37f win: remove abort when non-IFS LSP detection fails
Fixes: https://github.com/libuv/libuv/issues/1425
PR-URL: https://github.com/libuv/libuv/pull/2600
Refs: https://github.com/libuv/libuv/pull/2124
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-01-08 12:00:28 -05:00
Jameson Nash
8cb8afe253 docs: switch from linux.die.net to man7.org
The former was missing `urandom`, while the later is the host site for
https://www.kernel.org/doc/man-pages

PR-URL: https://github.com/libuv/libuv/pull/2608
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-01-08 11:52:02 -05:00
Jameson Nash
c072a3846d docs: fix linkcheck
Prefer https when available, follow permanent redirects, and find
alternate sources for dead links.

PR-URL: https://github.com/libuv/libuv/pull/2608
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-01-08 11:51:04 -05:00
Ben Noordhuis
a1af6685b7
unix: squelch fchmod() EPERM on CIFS share
uv_fs_copyfile() calls fchmod() to change the target file's permissions
to the source file's permissions but that operation errors with EPERM on
CIFS shares unless they are mounted with the "noperm" option.

Since UNIX-style permissions don't make sense for CIFS anyway, let's
handle the error in libuv by recognizing that it's a CIFS share and
continuing when that is the case.

The same logic probably applies to (a subset of) FUSE file systems but
those haven't been whitelisted yet.

Fixes: https://github.com/libuv/libuv/issues/2596
Refs: https://github.com/nodejs/node/issues/31170
PR-URL: https://github.com/libuv/libuv/pull/2597
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2020-01-07 23:49:45 -05:00
Jameson Nash
2b79df6456
docs: fix formatting
Introduced in https://github.com/libuv/libuv/pull/2404
and https://github.com/libuv/libuv/pull/2347.

PR-URL: https://github.com/libuv/libuv/pull/2609
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-01-07 23:43:09 -05:00
Xu Meng
51a0ae7817
ibmi: fix the CMSG length issue
On IBMi, msg_controllen of struct msghdr can not exceed 256.
The default UV__CMSG_FD_COUNT value 64 leads EINVAL error.
Set UV__CMSG_FD_COUNT to 60 on IBMi to resolve the issue.

PR-URL: https://github.com/libuv/libuv/pull/2591
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2020-01-07 23:39:28 -05:00
Jameson Nash
3596f833e8
docs: delete socks5-proxy sample
It is known to fail asserts and leak memory, making it not particularly
good as sample code.  Since we have relatively little interest in
maintaining this (especially now that we have the libuv guide and other
docs), it is clearer to delete it.

Refs: https://github.com/libuv/libuv/pull/2414
Refs: https://github.com/libuv/libuv/issues/1604
PR-URL: https://github.com/libuv/libuv/pull/2605
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-01-07 23:34:48 -05:00
Trevor Norris
bbb8b1ffac
test: fix pthread memory leak
When the thread attributes object returned by pthread_getattr_np() is no
longer required, it should be destroyed using pthread_attr_destroy().

PR-URL: https://github.com/libuv/libuv/pull/2583
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-01-07 23:25:50 -05:00
Jameson Nash
6432886e0d misc: make more tags "not-stale"
PR-URL: https://github.com/libuv/libuv/pull/2539
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-01-07 12:43:00 -05:00
Ben Noordhuis
5cb8860b45 unix: suppress -Waddress-of-packed-member warning
Fixes: https://github.com/libuv/libuv/issues/2418
PR-URL: https://github.com/libuv/libuv/pull/2584
Refs: https://github.com/libuv/libuv/pull/2580
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-30 18:25:11 +01:00
cjihrig
af45b6ba2f
test: disallow running the test suite as root
The test suite is known to have issues when run as root. This
commit prevents the test suite from running when the euid is 0.

Fixes: https://github.com/libuv/libuv/issues/2549
PR-URL: https://github.com/libuv/libuv/pull/2585
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-12-26 10:09:24 -05:00
David Carlier
2ab3dc1567 unix: pass sysctl size arg using ARRAY_SIZE macro
PR-URL: https://github.com/libuv/libuv/pull/2510
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:55:59 +01:00
George Zhao
93ca478adb unix: fix -Wunused-but-set-variable warning
PR-URL: https://github.com/libuv/libuv/pull/2517
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:40:04 +01:00
Richard Lau
3e56d99817 doc: remove binaries for Windows from README
Binaries for Windows was experimental and removed from libuv 1.19.0
onwards.

PR-URL: https://github.com/libuv/libuv/pull/2556
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:37:19 +01:00
Xu Meng
93634e2904 test: skip uv_(get|set)_process_title on IBMi
uv_(get|set)_process_title is not implemented on IBMi.

PR-URL: https://github.com/libuv/libuv/pull/2574
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
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: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:35:23 +01:00
Xu Meng
5b12c313e1 test: skip some test cases on IBMi
On IBMi, uv_uptime() and uv_fs_event_init() return UV_ENOSYS.
Set NO_FS_EVENTS on IBMi.

PR-URL: https://github.com/libuv/libuv/pull/2573
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
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: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:33:04 +01:00
David Carlier
5a88a63b00 test: fix test failure under NetBSD and OpenBSD
For the dl api, OpenBSD reports only wrong binary format.
Others are unsupported.

PR-URL: https://github.com/libuv/libuv/pull/2572
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:31:02 +01:00
Xu Meng
e14c56bd90 ibmi: fix the false isatty() issue on IBMi
On IBMi PASE isatty() always returns true for stdin, stdout and stderr.
Use ioctl() instead to identify whether it's actually a TTY.

PR-URL: https://github.com/libuv/libuv/pull/2565
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-12-16 15:26:57 +01:00
Ben Noordhuis
d077d066fd darwin: assume pthread_setname_np() is available
Stop dlsym-ing the symbol name at run-time, that was only necessary to
support macOS and iOS versions that were already near-obsolete when this
feature was introduced in August 2013.

This reapplies commit bee1bf5dd7 from October.

PR-URL: https://github.com/libuv/libuv/pull/2568
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:22:25 +01:00
Ben Noordhuis
565cdd16bb Revert "darwin: speed up uv_set_process_title()"
This reverts commit 038eacfbf4.

It was reported that this change causes a regression when trying
to obtain the screen resolution with `CGDisplayPixelsWide()` or
`CGDisplayPixelsHigh()` after changing the process title.

This is the second time this change had to be reverted due to
regressions and, although third time is allegedly the charm,
leaving well enough alone is the proverb I plan to adhere to...

Fixes: https://github.com/libuv/libuv/issues/2566
PR-URL: https://github.com/libuv/libuv/pull/2568
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:22:25 +01:00
Ben Noordhuis
56f8366873 Revert "darwin: assume pthread_setname_np() is available"
This reverts commit bee1bf5dd7.

This is necessary in order to be able to revert commit 038eacfbf4
("darwin: speed up uv_set_process_title()") from October.

PR-URL: https://github.com/libuv/libuv/pull/2568
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:21:34 +01:00
Ben Noordhuis
f0923d0251 build: remove -pedantic from compiler flags
This flag emits warnings with some versions of gcc that we don't care
about (libuv targets POSIX conformance, not strict ISO C conformance)
and it's arguably not that useful as libuv is compiled in -std=gnu89
mode.

Fixes: https://github.com/libuv/libuv/pull/2567
PR-URL: https://github.com/libuv/libuv/pull/2570
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-16 15:19:08 +01:00
Ben Noordhuis
a0530ce77e unix: cache address of dlsym("mkostemp")
Look up the "mkostemp" symbol once instead of on every call
to uv_fs_mkstemp().

PR-URL: https://github.com/libuv/libuv/pull/2564
Reviewed-By: Anna Henningsen <anna@addaleax.net>
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: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-08 12:27:31 +01:00
Ben Noordhuis
0d3b487f5d unix: fix -Wstrict-aliasing compiler warning
Fixes: https://github.com/libuv/libuv/issues/2563
PR-URL: https://github.com/libuv/libuv/pull/2564
Reviewed-By: Anna Henningsen <anna@addaleax.net>
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: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-08 12:27:31 +01:00
cjihrig
d01f050099
Now working on version 1.34.1
Fixes: https://github.com/libuv/libuv/issues/2538
2019-12-03 22:13:41 -05:00
cjihrig
d998dc33da
Add SHA to ChangeLog 2019-12-03 22:11:29 -05:00
cjihrig
15ae750151
2019.12.05, Version 1.34.0 (Stable)
Changes since version 1.33.1:

* unix: move random-sysctl to random-sysctl-linux (nia)

* netbsd: use KERN_ARND sysctl to get entropy (nia)

* unix: refactor uv__fs_copyfile() logic (cjihrig)

* build: fix android build, add missing sources (Ben Noordhuis)

* build: fix android build, fix symbol redefinition (Ben Noordhuis)

* build: fix android autotools build (Ben Noordhuis)

* fs: handle non-functional statx system call (Milad Farazmand)

* unix,win: add uv_sleep() (cjihrig)

* doc: add richardlau to maintainers (Richard Lau)

* aix: fix netmask for IPv6 (Richard Lau)

* aix: clean up after errors in uv_interface_addresses() (Richard Lau)

* aix: fix setting of physical addresses (Richard Lau)

* fs: add uv_fs_mkstemp (Saúl Ibarra Corretgé)

* unix: switch uv_sleep() to nanosleep() (Ben Noordhuis)

* unix: retry on EINTR in uv_sleep() (Ben Noordhuis)

* zos: fix nanosleep() emulation (Ben Noordhuis)
2019-12-03 22:11:28 -05:00
Ben Noordhuis
635e0ce607
zos: fix nanosleep() emulation
* Remove an assert() that wasn't actually being tested because the CI
  builds libuv with `-DNDEBUG` on that platform.

* Fix the emulation to update `errno` correctly.

* Fix the emulation to update the `rem` out parameter correctly.

PR-URL: https://github.com/libuv/libuv/pull/2552
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-12-03 19:17:42 -05:00
Ben Noordhuis
7a914e7f3d
unix: retry on EINTR in uv_sleep()
Reception of a signal makes nanosleep() return prematurely. Restart the
system call when that happens.

PR-URL: https://github.com/libuv/libuv/pull/2552
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-12-03 19:17:37 -05:00
Ben Noordhuis
664f9c0011
unix: switch uv_sleep() to nanosleep()
Before this commit, uv_sleep() made two library calls: sleep() to sleep
for the requested number of seconds, and then an usleep() call to sleep
for the remaining milliseconds. Make a single nanosleep() call instead.

Receiving a signal will wake up prematurely from sleep() but then
re-enter sleep mode again in usleep(), which seems undesirable.

PR-URL: https://github.com/libuv/libuv/pull/2552
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-12-03 19:16:19 -05:00
Saúl Ibarra Corretgé
5500253cac fs: add uv_fs_mkstemp
Thanks to Andreas Hauptmann and Bastian Schmitz for their earlier work.

Supersedes: https://github.com/libuv/libuv/pull/2074
Closes: https://github.com/libuv/libuv/issues/2555
PR-URL: https://github.com/libuv/libuv/pull/2557
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-12-03 09:03:50 +01:00
Richard Lau
0a4e0b9d30
aix: fix setting of physical addresses
Changes based on code in `src/unix/bsd-ifaddrs.c`.

PR-URL: https://github.com/libuv/libuv/pull/2546
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-12-02 12:54:59 -05:00
Richard Lau
cf6a678fa4
aix: clean up after errors in uv_interface_addresses()
PR-URL: https://github.com/libuv/libuv/pull/2545
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-11-28 09:38:31 -05:00
Richard Lau
e3d378747c
aix: fix netmask for IPv6
Use SIOCGIFNETMASK6 for IPv6 network interfaces.

The SIOCGIFNETMASK and SIOCGIFNETMASK6 ioctl() calls on AIX appear to
return the address family as `0` so explicitly set the address family.

Fixes: https://github.com/nodejs/node/issues/30504
PR-URL: https://github.com/libuv/libuv/pull/2545
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-11-28 09:37:48 -05:00
Richard Lau
c6331a42ce
doc: add richardlau to maintainers
PR-URL: https://github.com/libuv/libuv/pull/2551
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-11-26 14:36:16 -05:00
cjihrig
8c73eee23f
unix,win: add uv_sleep()
This commit exposes the uv_sleep() function that previously
only existed in the test runner.

PR-URL: https://github.com/libuv/libuv/pull/2548
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-11-25 12:13:39 -05:00
Milad Farazmand
96cfa783a2 fs: handle non-functional statx system call
statx is not implemented on RHEL 7 and trying to call it from within a
docker container might result in a return value of 1 (which is not an
expected value according to statx man page, expected values are 0 or -1)
and errno is set to 0, in which case assume statx is not implemented.

Above behaviour has been seen on RHEL 7 running on a s390.

PR-URL: https://github.com/libuv/libuv/pull/2529
Refs: https://bugzilla.redhat.com/show_bug.cgi?id=1759152
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-11-22 04:16:31 +01:00
Ben Noordhuis
f961844392
build: fix android autotools build
This commit contains an untested change but the sources list was so
woefully incomplete that even if it doesn't fix things outright, it
definitely makes it less worse.

PR-URL: https://github.com/libuv/libuv/pull/2542
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-11-19 15:10:49 -05:00
Ben Noordhuis
6de351debe
build: fix android build, fix symbol redefinition
linux-core defines uv_get_free_memory() and uv_get_total_memory() so
don't include sysinfo-memory.c too. The cmake and autotools builds
don't do so either.

PR-URL: https://github.com/libuv/libuv/pull/2542
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-11-19 15:10:38 -05:00
Ben Noordhuis
717bda8b7e
build: fix android build, add missing sources
PR-URL: https://github.com/libuv/libuv/pull/2542
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-11-19 15:10:04 -05:00
cjihrig
780c08a63e
unix: refactor uv__fs_copyfile() logic
The Unix/macOS uv__fs_copyfile() implementation falls back to
using uv_fs_sendfile(). This commit refactors the error handling
to use the sendfile() req's result field, which is an ssize_t
instead of using the return value, which is an int. The int
value was coming back as a negative number for some large files.

Refs: https://github.com/nodejs/node/issues/30085
PR-URL: https://github.com/libuv/libuv/pull/2533
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-10-30 10:07:37 -04:00
nia
a62f8ced7a netbsd: use KERN_ARND sysctl to get entropy
PR-URL: https://github.com/libuv/libuv/pull/2528
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-10-29 13:36:05 +01:00
nia
2dcf2e8188 unix: move random-sysctl to random-sysctl-linux
PR-URL: https://github.com/libuv/libuv/pull/2528
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-10-29 13:31:41 +01:00
cjihrig
747a0f34d7
Now working on version 1.33.2
Fixes: https://github.com/libuv/libuv/issues/2525
2019-10-19 16:40:16 -05:00
cjihrig
278ae2fe00
Add SHA to ChangeLog 2019-10-19 16:32:27 -05:00
cjihrig
07ad32138f
2019.10.20, Version 1.33.1 (Stable)
Changes since version 1.33.0:

* linux: fix arm64 SYS__sysctl build breakage (Ben Noordhuis)
2019-10-19 16:32:27 -05:00
Ben Noordhuis
83f59ff1c1
linux: fix arm64 SYS__sysctl build breakage
The arm64 architecture never had a _sysctl system call and therefore
doesn't have a SYS__sysctl define either. Always return UV_ENOSYS.

Fixes: https://github.com/libuv/libuv/issues/2522
PR-URL: https://github.com/libuv/libuv/pull/2524
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-10-19 16:25:30 -05:00
cjihrig
cb7e5a6aff
Now working on version 1.33.1
Fixes: https://github.com/libuv/libuv/issues/2491
2019-10-16 14:55:35 -04:00
cjihrig
146c13db14
Add SHA to ChangeLog 2019-10-16 14:53:29 -04:00
cjihrig
e56e42e931
2019.10.17, Version 1.33.0 (Stable)
Changes since version 1.32.0:

* Revert "linux: drop code path for epoll_pwait-less kernels" (Yang Yu)

* build: fix build error with __ANDROID_API__ < 21 (Yang Yu)

* win: fix reading hidden env vars (Anna Henningsen)

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

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

* docs: fix literal-includes in User Guide (Nhan Khong)

* win, tty: fix problem of receiving unexpected SIGWINCH (erw7)

* unix: fix {Net,Open}BSD build (David Carlier)

* win,mingw: Fix undefined MCAST_* constants (Crunkle)

* build: Add link for test/fixtures/lorem_ipsum.txt (Andrew Paprocki)

* fs: use statvfs in uv__fs_statfs() for Haiku (Calvin Hill)

* fsevents: stop using fsevents to watch files (Jameson Nash)

* fsevents: regression in watching / (Jameson Nash)

* build,cmake: don't try to detect a C++ compiler (Isabella Muerte)

* build: fix build warning on cygwin (MaYuming)

* unix: set sin_len and sin6_len (Ouyang Yadong)

* test: fix order of operations in test (cjihrig)

* doc: improve uv_fs_readdir() cleanup docs (cjihrig)

* build: remove duplicated test in build files (ZYSzys)

* android: enable getentropy on Android >= 28 (David Carlier)

* android: fix build (David Carlier)

* darwin: speed up uv_set_process_title() (Ben Noordhuis)

* darwin: assume pthread_setname_np() is available (Ben Noordhuis)

* unix,udp: ensure addr is non-null (Jameson Nash)

* win,tty: add uv_tty_{get,set}_vterm_state (erw7)

* win: fix uv_statfs_t leak in uv_fs_statfs() (Ryan Liptak)

* build: install files on windows via cmake (Carl Lei)

* darwin,test: include AvailabilityMacros.h (Saúl Ibarra Corretgé)

* darwin,test: update loop time after sleeping (Saúl Ibarra Corretgé)

* doc: remove old FreeBSD 9 related note (Saúl Ibarra Corretgé)

* doc: improve uv_{send,recv}_buffer_size() docs (Ryan Liptak)

* build: move -Wno-long-long check to configure time (Ben Noordhuis)

* unix: update uv_fs_copyfile() fallback logic (Stefan Bender)

* win: cast setsockopt struct to const char* (Shelley Vohr)
2019-10-16 14:53:28 -04:00
Shelley Vohr
68818b621a
win: cast setsockopt struct to const char*
Fixes: https://github.com/libuv/libuv/issues/2519
PR-URL: https://github.com/libuv/libuv/pull/2520
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-10-16 12:57:37 -04:00
Stefan Bender
ddcaff9a10
unix: update uv_fs_copyfile() fallback logic
This commit fixes uv_fs_copyfile() in cases where an unknown error
occurs when copy-on-write is requested by setting
UV_FS_COPYFILE_FICLONE. The original approach tried to catch some of
the errors raised by the ioctl() call, assuming that sendfile() would
also fail in those cases. This is not necessarily true, as some
variants of ioctl() also raise EINVAL (some maybe EBADF), but sendfile()
works just fine.

This patch reverses the logic, falling back to sendfile() in any
case where ioctl() returns an error. In other words, it tries much
harder to make uv_fs_copyfile() work.

Related to that, the original approach returned UV_ENOTSUP
unconditionally in cases where ioctl() failed and
UV_FS_COPYFILE_FICLONE_FORCE was set. However, ioctl() may have
failed for other reasons than being not supported. The function
now returns the actual error raised by ioctl(), leaving it to the
caller to deal with it.

Fixes: https://github.com/libuv/libuv/issues/2483
PR-URL: https://github.com/libuv/libuv/pull/2514
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-10-16 10:49:42 -04:00
Ben Noordhuis
f9c35197e6
build: move -Wno-long-long check to configure time
xlc reportedly doesn't support the `-Wno-long-long` flag. Detect that
at configure time instead of trying to fix it up at build time.

This enables the flag for both the library and the test suite instead
of just the test suite but that seems fine to me.

PR-URL: https://github.com/libuv/libuv/pull/2512
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-10-14 21:33:39 -04:00
Ryan Liptak
e668e10acb
doc: improve uv_{send,recv}_buffer_size() docs
PR-URL: https://github.com/libuv/libuv/pull/2508
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-10-14 21:22:57 -04:00
Saúl Ibarra Corretgé
65f142a9a6
doc: remove old FreeBSD 9 related note
PR-URL: https://github.com/libuv/libuv/pull/2509
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
2019-10-14 21:20:09 -04:00
Saúl Ibarra Corretgé
1df44df057 darwin,test: update loop time after sleeping
Otherwise we run the risk of running the timer before the fsevent
callback since the timer due time is "now" because it's as long as the
process already slept.

Refs: https://github.com/libuv/libuv/issues/2491
PR-URL: https://github.com/libuv/libuv/pull/2516
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-10-14 23:52:34 +02:00
Saúl Ibarra Corretgé
39a801d66d darwin,test: include AvailabilityMacros.h
It's necessary for MAC_OS_X_VERSION_10_12 to be defined.

Refs: https://github.com/libuv/libuv/issues/2491
PR-URL: https://github.com/libuv/libuv/pull/2516
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-10-14 23:51:34 +02:00
Carl Lei
e797163e75
build: install files on windows via cmake
PR-URL: https://github.com/libuv/libuv/pull/2443
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-10-09 15:34:12 -04:00
Ryan Liptak
076df64dbb
win: fix uv_statfs_t leak in uv_fs_statfs()
PR-URL: https://github.com/libuv/libuv/pull/2505
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-10-09 12:57:35 -04:00
erw7
fd2ce38dd6 win,tty: add uv_tty_{get,set}_vterm_state
PR-URL: https://github.com/libuv/libuv/pull/2501
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
Reviewed-By: Jameson Nash <vtjnash+github@gmail.com>
2019-10-09 09:36:36 +02:00
Jameson Nash
fdef604a1e unix,udp: ensure addr is non-null
Update this code to be more in line with the Windows version.

Previously, callers (such as nodejs) might assume it was always safe to de-reference this parameter:
d2634be562/src/tcp_wrap.cc (L349) called from d2634be562/src/udp_wrap.cc (L567)

I suspect this may have been unreachable, and that it was guaranteed by the kernel to be `>= sizeof(struct sockaddr)`, so this should be a NFC simplification.

PR-URL: https://github.com/libuv/libuv/pull/2330
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-10-08 21:55:30 +02:00
Ben Noordhuis
bee1bf5dd7 darwin: assume pthread_setname_np() is available
Stop dlsym-ing the symbol name at run-time, that was only necessary to
support macOS and iOS versions that were already near-obsolete when this
feature was introduced in August 2013.

PR-URL: https://github.com/libuv/libuv/pull/2480
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-10-08 12:50:26 +02:00
Ben Noordhuis
038eacfbf4 darwin: speed up uv_set_process_title()
Libuv loaded and unloaded the Core Services and Application Services for
every call to uv_set_process_title().

Change that to load them on the first call to uv_set_process_title() and
delay unloading until libuv is unloaded.

Speeds up process_title_threadsafe by about 10x on my system. It should
fail less often (hopefully not at all) on the CI now.

PR-URL: https://github.com/libuv/libuv/pull/2480
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-10-08 12:49:47 +02:00
David Carlier
e83dba7f93 android: fix build
PR-URL: https://github.com/libuv/libuv/pull/2486
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-10-08 09:20:52 +02:00
David Carlier
f261d04d0a android: enable getentropy on Android >= 28
PR-URL: https://github.com/libuv/libuv/pull/2486
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-10-08 09:19:47 +02:00
ZYSzys
8b1e352ffa
build: remove duplicated test in build files
Remove duplicated test-ip6-addr.c in cmake build file
and gyp file.

PR-URL: https://github.com/libuv/libuv/pull/2494
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-10-07 22:12:29 -04:00
cjihrig
d6b79ffb1b
doc: improve uv_fs_readdir() cleanup docs
When cleaning up after uv_fs_readdir(), it is important to
call uv_fs_req_cleanup() on the readdir request prior to calling
uv_fs_closedir(), because the latter frees memory that the
former needs in order to do its job.

PR-URL: https://github.com/libuv/libuv/pull/2497
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-10-06 16:08:04 +02:00
cjihrig
f47f01b57c
test: fix order of operations in test
In the fs_readdir_empty_dir test, the uv_fs_readdir() request is
cleaned up after calling uv_fs_closedir(). However, the readdir
request should be cleaned up before calling uv_fs_closedir().

Fixes: https://github.com/libuv/libuv/issues/2496
PR-URL: https://github.com/libuv/libuv/pull/2497
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-10-06 16:07:01 +02:00
Ouyang Yadong
645be48a80 unix: set sin_len and sin6_len
FreeBSD defines `sin_len` and `sin6_len` inside `sockaddr_in` and
`sockaddr_in6`. `sockaddr`s come from `getsockname` and `uv_ip4_addr`
will differ in the first byte if libuv doesn't set `sin_len` correctly.

PR-URL: https://github.com/libuv/libuv/pull/2492
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-10-04 23:58:18 +02:00
MaYuming
0ff717e39c build: fix build warning on cygwin
Signed-off-by: MaYuming <maym@appexnetworks.com>
PR-URL: https://github.com/libuv/libuv/pull/2489
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-10-04 23:54:06 +02:00
Isabella Muerte
edbf293479 build,cmake: don't try to detect a C++ compiler
- Bump CMake version to 3.4 so we can eventually use all the
cool things like better generator expression support, and
`target_sources`, and also better MSVC runtime linkage support

- Reorganize includes to be all in one place.

- Rename libuv_buildtests option to LIBUV_BUILD_TESTS. It is disabled
unless BUILD_TESTING is ON *and* libuv is the "root" project. This helps
projects that might use libuv as a git submodule, or as a download that
is then passed to `add_subdirectory`.

Refs: https://github.com/libuv/libuv/pull/2490
PR-URL: https://github.com/libuv/libuv/pull/2495
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-10-04 23:49:25 +02:00
Jameson Nash
ae12376dbb fsevents: regression in watching /
This case got lost by accident in
https://github.com/libuv/libuv/pull/2082,
preventing the realpath `/` from ever matching.

Fixes: https://github.com/nodejs/node/issues/28917
PR-URL: https://github.com/libuv/libuv/pull/2460
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-09-26 16:07:46 +02:00
Jameson Nash
97b85e8b75 fsevents: stop using fsevents to watch files
Goes back to just using it to watch folders,
but keeps the other logic changes around.

Refs: https://github.com/libuv/libuv/pull/387
Refs: https://github.com/libuv/libuv/pull/2082
Refs: https://github.com/libuv/libuv/pull/1572
Refs: https://github.com/nodejs/node/issues/29460
Fixes: https://github.com/libuv/libuv/issues/2488
Closes: https://github.com/libuv/libuv/pull/2452
PR-URL: https://github.com/libuv/libuv/pull/2459
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-09-26 16:01:27 +02:00
Calvin Hill
501b5cc53e fs: use statvfs in uv__fs_statfs() for Haiku
PR-URL: https://github.com/libuv/libuv/pull/2477
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-09-25 16:40:50 +02:00
Andrew Paprocki
123e3bd7a7 build: Add link for test/fixtures/lorem_ipsum.txt
Test `test-fs.c` fails when built in a relocated directory because
the build does link the required test fixture.

PR-URL: https://github.com/libuv/libuv/pull/2444
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
Reviewed-By: Jameson Nash <vtjnash+github@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-09-25 14:55:27 +02:00
Crunkle
2140e2c08c win,mingw: Fix undefined MCAST_* constants
Fixes: https://github.com/libuv/libuv/issues/2464
Refs: https://github.com/libuv/libuv/pull/2471
PR-URL: https://github.com/libuv/libuv/pull/2461
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-09-25 14:48:10 +02:00
David Carlier
59146f2f4b unix: fix {Net,Open}BSD build
Mainly disabling source membership for udp feature, unsupported.

PR-URL: https://github.com/libuv/libuv/pull/2458
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-09-25 14:46:24 +02:00
erw7
501304225e win, tty: fix problem of receiving unexpected SIGWINCH
Fix an issue where WINDOWS_BUFFER_SIZE_EVENT occurs and unexpected
SIGWINCH is received before calling
uv__tty_console_resize_message_loop_thread.

Refs: https://github.com/neovim/neovim/pull/10978#issuecomment-530742148
PR-URL: https://github.com/libuv/libuv/pull/2478
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-09-25 14:43:23 +02:00
Nhan Khong
75075d6cdb docs: fix literal-includes in User Guide
Using raw copies in place of sphinx literalinclude
directives as the API of v1.x is now stable.

Fixes: https://github.com/libuv/libuv/issues/2350
PR-URL: https://github.com/libuv/libuv/pull/2353
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-09-25 14:39:23 +02:00
Saúl Ibarra Corretgé
9b2c9b6c1f win: simplify mkdtemp
Use our builtin getrandom helper instead of the more verbose CryptoAPI
functions, which also happen to be deprecated.

PR-URL: https://github.com/libuv/libuv/pull/2485
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-09-25 14:37:26 +02:00
Ben Noordhuis
4ed2a78f0e unix,win: add uv_random()
Add an API for obtaining cryptographically strong random data from the
system PRNG.

Co-authored-by: Saúl Ibarra Corretgé <s@saghul.net>
Refs: https://github.com/libuv/libuv/pull/1055
PR-URL: https://github.com/libuv/libuv/pull/2347
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-09-18 08:09:14 +02:00
Anna Henningsen
fd1502f563
win: fix reading hidden env vars
There are some special environment variables on Windows that
start with a '=' sign, e.g. per-drive working directories.
In those cases, an initial '=' in the name of the environment
variable needs to be skipped when looking for the '=' that separates
it from its value.

PR-URL: https://github.com/libuv/libuv/pull/2473
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash+github@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-09-17 22:07:34 +02:00
Yang Yu
e2c0f60c10 build: fix build error with __ANDROID_API__ < 21
Fix the following undefined symbols error with __ANDROID_API__ < 21:
- epoll_create1
- epoll_pwait
- futimens
2019-09-16 11:16:56 +02:00
Yang Yu
3bff0d3878 Revert "linux: drop code path for epoll_pwait-less kernels"
This reverts commit f43c663433.
2019-09-16 11:16:56 +02:00
cjihrig
549f52c467
Now working on version 1.32.1
Fixes: https://github.com/libuv/libuv/issues/2457
2019-09-09 12:55:37 -04:00
cjihrig
cd8f9315b6
Add SHA to ChangeLog 2019-09-09 12:53:17 -04:00
cjihrig
697bea87b3
2019.09.10, Version 1.32.0 (Stable)
Changes since version 1.31.0:

* misc: enable stalebot (Saúl Ibarra Corretgé)

* win: map ERROR_ENVVAR_NOT_FOUND to UV_ENOENT (cjihrig)

* win: use L'\0' as UTF-16 null terminator (cjihrig)

* win: support retrieving empty env variables (cjihrig)

* unix,stream: fix returned error codes (Santiago Gimeno)

* test: fix typo in DYLD_LIBRARY_PATH (Ben Noordhuis)

* unix,signal: keep handle active if pending signal (Santiago Gimeno)

* openbsd: fix uv_cpu_info (Santiago Gimeno)

* src: move uv_free_cpu_info to uv-common.c (Santiago Gimeno)

* tcp: add uv_tcp_close_reset method (Santiago Gimeno)

* test: fix udp-multicast-join tests (Santiago Gimeno)

* test: remove assertion in fs_statfs test (cjihrig)

* doc: clarify uv_buf_t usage in uv_alloc_cb (Tomas Krizek)

* win: fix typo in preprocessor expression (Konstantin Podsvirov)

* timer: fix uv_timer_start on closing timer (seny)

* udp: add source-specific multicast support (Vladimir Karnushin)

* udp: fix error return values (Santiago Gimeno)

* udp: drop IPV6_SSM_SUPPORT macro (Santiago Gimeno)

* udp: fix uv__udp_set_source_membership6 (Santiago Gimeno)

* udp: use sockaddr_storage instead of union (Santiago Gimeno)

* build,zos: add _OPEN_SYS_SOCK_EXT3 flag (Santiago Gimeno)

* test: add specific source multicast tests (Santiago Gimeno)

* include: map EILSEQ error code (cjihrig)

* win, tty: improve SIGWINCH performance (Bartosz Sosnowski)

* build: fix ios build error (MaYuming)

* aix: replace ECONNRESET with EOF if already closed (Milad Farazmand)

* build: add cmake library VERSION, SOVERSION (Eneas U de Queiroz)

* build: make include/ public in CMakeLists.txt (Ben Noordhuis)

* build: export USING_UV_SHARED=1 to cmake deps (Ben Noordhuis)

* build: cmake_minimum_required(VERSION 2.8.12) (Daniel Hahler)

* aix: Fix broken cmpxchgi() XL C++ specialization. (Andrew Paprocki)

* test: fix -Wsign-compare warning (Ben Noordhuis)

* unix: simplify open(O_CLOEXEC) feature detection (Ben Noordhuis)

* unix: fix UV_FS_O_DIRECT definition on Linux (Joran Dirk Greef)

* doc: uv_handle_t documentation suggestion (Daniel Bevenius)
2019-09-09 12:53:10 -04:00
Daniel Bevenius
25682fafeb
doc: uv_handle_t documentation suggestion
This commit contains a suggestion to hopefully improve the
documentation of uv_handle_t's member uv_loop_t.

PR-URL: https://github.com/libuv/libuv/pull/2446
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-09-09 11:09:30 -04:00
Joran Dirk Greef
9b12e023ab unix: fix UV_FS_O_DIRECT definition on Linux
According to http://man7.org/linux/man-pages/man2/open.2.html, the
O_DIRECT flag is Linux-specific. One must define _GNU_SOURCE to obtain
the correct definition.

However, defining _GNU_SOURCE in the headers is unhygienic and affects
the libuv consumer.

On Linux, we now define UV_FS_O_DIRECT explicitly according to
architecture, only falling back to O_DIRECT if defined, or 0 if not.

Fixes: https://github.com/libuv/libuv/issues/2420
PR-URL: https://github.com/libuv/libuv/pull/2441
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-09-06 22:50:27 +02:00
Ben Noordhuis
1f63e287b6 unix: simplify open(O_CLOEXEC) feature detection
Platforms that support O_CLOEXEC have supported it for a long time
and don't need feature detection. Libuv can just assume it works as
advertised.

The feature detection was broken for old Linux kernels because they
don't report EINVAL for unknown open() flags, they simply open the
file without setting the FD_CLOEXEC flag.

Libuv could fix that by checking afterwards with fcntl() if the flag
was actually set but it doesn't support kernels that old in the first
place so let's simplify the logic.

Fixes: https://github.com/libuv/libuv/issues/2450
PR-URL: https://github.com/libuv/libuv/pull/2454
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-09-06 22:49:22 +02:00
Ben Noordhuis
c898f2e838 test: fix -Wsign-compare warning
PR-URL: https://github.com/libuv/libuv/pull/2451
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-09-06 22:48:06 +02:00
Andrew Paprocki
4a972bf0e5 aix: Fix broken cmpxchgi() XL C++ specialization.
The preprocessor was used to select a special implementation when
building on AIX using XL C++ (strangely, not XL C).  This code
implemented `cmpxchgi()` by directly reading the old value and then
calling `__compare_and_swap()`, an intrinsic that does not provide
any sort of memory barrier guarantees.  The return value was not
used, and the value read prior to the `__compare_and_swap()` call
was returned.  There is no way that this code could provide the
required semantics of the function and it causes observable data
races and strange library failures in production under load.

XL C/C++ for AIX has provided support for the GCC intrinsic used in
the GCC/Clang cases since version 12.1 of the compiler.  This
version of the compiler is old enough that it doesn't warrant a
version check.  (The compiler was released 8-Jun-2012, maintenance
ended 9-Jul-2019, and service ends 30-Apr-2020.)

This change fixes all observed atomic issues and unifies XL C/C++
with GCC/Clang.

Relevant XL C/C++ for AIX V12.1 documentation links:
  - [__compare_and_swap](https://www.ibm.com/support/knowledgecenter/en/SSGH3R_12.1.0/com.ibm.xlcpp121.aix.doc/compiler_ref/bif_compare_and_swap_compare_and_swaplp.html)
  - [__sync_val_compare_and_swap](https://www.ibm.com/support/knowledgecenter/en/SSGH3R_12.1.0/com.ibm.xlcpp121.aix.doc/compiler_ref/bif_gcc_atomic_val_comp_swap.html)

PR-URL: https://github.com/libuv/libuv/pull/2455
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-09-06 10:17:12 +02:00
Daniel Hahler
1f1f1126b3 build: cmake_minimum_required(VERSION 2.8.12)
The lower minimum version makes it possible to build neovim but it
should be understood that libuv tests nor supports cmake versions
that old.

PR-URL: https://github.com/libuv/libuv/pull/2373
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-09-06 10:09:15 +02:00
Ben Noordhuis
6325a7c840 build: export USING_UV_SHARED=1 to cmake deps
Build the shared library with `BUILDING_UV_SHARED=1` and export
`USING_UV_SHARED=1` to dependents so they get the right declspec.

Fixes: https://github.com/libuv/libuv/issues/1938
PR-URL: https://github.com/libuv/libuv/pull/2431
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-09-06 10:07:47 +02:00
Ben Noordhuis
be449a1979 build: make include/ public in CMakeLists.txt
Fixes: https://github.com/libuv/libuv/issues/1938
PR-URL: https://github.com/libuv/libuv/pull/2431
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-09-06 10:07:22 +02:00
Eneas U de Queiroz
ba1a770bdb build: add cmake library VERSION, SOVERSION
This mimics the behavior of the automake build, using
libuv.so.${UV_VERSION_MAJOR}.0.0 as the output file, and setting the
soname property to be libuv.so.${UV_VERSION_MAJOR}, currently ending up
like this:

    libuv.so.1.0.0
    libuv.so.1 -> libuv.so.1.0.0
    libuv.so -> libuv.so.1

The version information is extracted from the PACKAGE_VERSION string.

PR-URL: https://github.com/libuv/libuv/pull/2445
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2019-09-06 10:02:02 +02:00
Milad Farazmand
ca08b48252 aix: replace ECONNRESET with EOF if already closed
PR-URL: https://github.com/libuv/libuv/pull/2447
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-09-06 09:59:54 +02:00
MaYuming
5ba93edef6 build: fix ios build error
`_NSGetEnviron()` is not available on that platform.

PR-URL: https://github.com/libuv/libuv/pull/2449
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Signed-off-by: MaYuming <maym@appexnetworks.com>
2019-09-05 20:46:48 +02:00
Bartosz Sosnowski
7d950c0d10 win, tty: improve SIGWINCH performance
Continuing improvement of SIGWINCH from PR #2308.

Running SetWinEventHook without filtering for the specific PIDs has
significant impact on the performance of the entire system. This PR
changes the way SIGWINCH is handled.

The SetWinEventHook callback now signals a separate thread,
uv__tty_console_resize_watcher_thread. This thread calls
uv__tty_console_signal_resize() which checks if the console was actually
resized. The uv__tty_console_resize_watcher_thread makes sure to not to
call the uv__tty_console_signal_resize function more than 30 times per
second.

The SetWinEventHook will not be installed, if the PID of the
conhost.exe process that owns the console window cannot be
determinated. This can happen when a 32bit libuv app is running on a
64bit Windows.

For such cases PR #1408 is partially reverted - when tty reads
WINDOW_BUFFER_SIZE_EVENT, it will also trigger a call to
uv__tty_console_signal_resize(). This will also help when the app is
running under console emulators. Documentation was also updated to
reflect that.

Refs: https://github.com/microsoft/terminal/issues/1811
Refs: https://github.com/microsoft/terminal/issues/410
Refs: https://github.com/libuv/libuv/pull/2308

PR-URL: https://github.com/libuv/libuv/pull/2381
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-09-05 11:36:02 +02:00
cjihrig
43c74a6ee9
include: map EILSEQ error code
PR-URL: https://github.com/libuv/libuv/pull/2440
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-08-26 10:13:37 -04:00
Santiago Gimeno
24e65f776d
test: add specific source multicast tests
PR-URL: https://github.com/libuv/libuv/pull/2202
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-23 21:12:58 +02:00
Santiago Gimeno
80e931b38c
build,zos: add _OPEN_SYS_SOCK_EXT3 flag
To support source specific multicast operations.

PR-URL: https://github.com/libuv/libuv/pull/2202
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-23 21:12:53 +02:00
Santiago Gimeno
7452507f7d
udp: use sockaddr_storage instead of union
PR-URL: https://github.com/libuv/libuv/pull/2202
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-23 21:12:47 +02:00
Santiago Gimeno
f91702a470
udp: fix uv__udp_set_source_membership6
Use the correct socket options: `MCAST_JOIN_SOURCE_GROUP` and
`MCAST_LEAVE_SOURCE_GROUP`.
Set mreq.gsr_interface = 0 if iface_addr = NULL.

PR-URL: https://github.com/libuv/libuv/pull/2202
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-23 21:12:41 +02:00
Santiago Gimeno
9efc1961fe
udp: drop IPV6_SSM_SUPPORT macro
All the supported platforms support specific source multicast.

PR-URL: https://github.com/libuv/libuv/pull/2202
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-23 21:12:36 +02:00
Santiago Gimeno
288ec700e4
udp: fix error return values
PR-URL: https://github.com/libuv/libuv/pull/2202
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-23 21:12:29 +02:00
Vladimir Karnushin
91d95f8ceb
udp: add source-specific multicast support
PR-URL: https://github.com/libuv/libuv/pull/2202
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-08-23 21:09:47 +02:00
seny
2ee2d4622a
timer: fix uv_timer_start on closing timer
Return `UV_EINVAL` in this case.

Fixes: https://github.com/libuv/libuv/issues/2416
PR-URL: https://github.com/libuv/libuv/pull/2424
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-08-23 20:42:37 +02:00
Konstantin Podsvirov
fa41f13444
win: fix typo in preprocessor expression
PR-URL: https://github.com/libuv/libuv/pull/2434
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-08-23 20:31:01 +02:00
Tomas Krizek
641ec77265
doc: clarify uv_buf_t usage in uv_alloc_cb
Clarify the uv_buf_t isn't reused and the user is responsible for
freeing it in the recv/read callback.

Previously, this wasn't clear when reading only the docs for
uv_udp_recv_cb and uv_alloc_cb.

PR-URL: https://github.com/libuv/libuv/pull/2438
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-08-23 20:27:48 +02:00
cjihrig
1bd7cc5ce9
test: remove assertion in fs_statfs test
The f_files value can equal 0, making the current assertion
incorrect. Including 0 in the assertion range leads to a
type-limits compiler warning. So, this commit just removes
the redundant assertion.

Fixes: https://github.com/libuv/libuv/issues/2417
PR-URL: https://github.com/libuv/libuv/pull/2426
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-20 10:33:32 -04:00
Santiago Gimeno
b571851e6e
test: fix udp-multicast-join tests
The messages must be actually sent to the multicast address.

PR-URL: https://github.com/libuv/libuv/pull/2185
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-19 23:47:10 +02:00
Santiago Gimeno
958e85fbd8
tcp: add uv_tcp_close_reset method
It resets a TCP connection by sending a RST packet. Due to some platform
inconsistencies, mixing of `uv_shutdown` and `uv_tcp_close_reset` calls
is not allowed.

Fixes: https://github.com/libuv/libuv/issues/1991
PR-URL: https://github.com/libuv/libuv/pull/2425
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-08-19 23:41:15 +02:00
Santiago Gimeno
040543eebf
src: move uv_free_cpu_info to uv-common.c
PR-URL: https://github.com/libuv/libuv/pull/2433
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-19 23:01:17 +02:00
Santiago Gimeno
d6fd0a529a
openbsd: fix uv_cpu_info
Make sure the `uv_cpu_info_t` array is fully freed in case of error.
Also, make it more robust by setting `count` to `0` and `cpu_info` to
`NULL` in case of error, so a subsequent call to `uv_free_cpu_info()`
does not segfault.

Refs: https://github.com/libuv/libuv/issues/2068
PR-URL: https://github.com/libuv/libuv/pull/2432
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-19 22:50:48 +02:00
Santiago Gimeno
1de151700d
unix,signal: keep handle active if pending signal
Keep the signal handler active after being closed until all the caught
signals have been delivered.

Fixes: https://github.com/libuv/libuv/issues/2398
Fixes: https://github.com/libuv/libuv/issues/2415
PR-URL: https://github.com/libuv/libuv/pull/2423
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-08-19 22:39:06 +02:00
Ben Noordhuis
54a5e9262f test: fix typo in DYLD_LIBRARY_PATH
It looks like I managed to introduce a typo between two incarnations
of the pull request, causing the test to fail on macOS when using the
autotools dynamic library build.

I even managed to spell it correctly in the skip message, just not in
the actual environment variable lookup... I hang my head in shame at
such a silly mistake.

Fixes: https://github.com/libuv/libuv/issues/2421
PR-URL: https://github.com/libuv/libuv/pull/2422
Refs: https://github.com/libuv/libuv/pull/2408
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-17 16:02:56 +02:00
Santiago Gimeno
66132c66e4
unix,stream: fix returned error codes
PR-URL: https://github.com/libuv/libuv/pull/2427
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-16 17:41:29 +02:00
cjihrig
9e80057051
win: support retrieving empty env variables
This commit adds Windows support for retrieving empty
environment variables via uv_os_getenv().

Fixes: https://github.com/libuv/libuv/issues/2413
PR-URL: https://github.com/libuv/libuv/pull/2419
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-13 10:57:32 -04:00
cjihrig
6c9c4fe991
win: use L'\0' as UTF-16 null terminator
uv__convert_utf8_to_utf16() always null terminates its
UTF-16 output. This commit updates the code to use L'\0'
as the terminator, instead of '\0'.

Fixes: https://github.com/libuv/libuv/issues/2413
PR-URL: https://github.com/libuv/libuv/pull/2419
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-13 10:57:27 -04:00
cjihrig
b0fd17193e
win: map ERROR_ENVVAR_NOT_FOUND to UV_ENOENT
Fixes: https://github.com/libuv/libuv/issues/2413
PR-URL: https://github.com/libuv/libuv/pull/2419
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-13 10:56:25 -04:00
Saúl Ibarra Corretgé
8ed9112f50 misc: enable stalebot
PR-URL: https://github.com/libuv/libuv/pull/2410
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-08-09 21:14:03 +02:00
cjihrig
6f776765c7
Now working on version 1.31.1
Fixes: https://github.com/libuv/libuv/issues/2403
2019-08-09 10:59:08 -04:00
cjihrig
3072edfdcc
Add SHA to ChangeLog 2019-08-09 10:57:12 -04:00
cjihrig
0a6771cee4
2019.08.10, Version 1.31.0 (Stable)
Changes since version 1.30.1:

* win,fs: don't modify global file translation mode (Javier Blazquez)

* win: fix uv_os_tmpdir when env var is 260 chars (Mustafa M)

* win: prevent tty event explosion machine hang (Javier Blazquez)

* win: add UV_FS_O_FILEMAP (João Reis)

* win, fs: mkdir return UV_EINVAL for invalid names (Bartosz Sosnowski)

* github: add root warning to template (cjihrig)

* win: misc fs cleanup (cjihrig)

* unix,win: add uv_fs_statfs() (cjihrig)

* test: avoid AF_LOCAL (Carlo Marcelo Arenas Belón)

* unix,win: add ability to retrieve all env variables (Saúl Ibarra
  Corretgé)

* Revert "darwin: speed up uv_set_process_title()" (Ben Noordhuis)

* doc: add %p to valgrind log-file arg (Zach Bjornson)

* doc: fix typo in basics.rst (Nan Xiao)

* ibmi: support Makefile build for IBM i (Xu Meng)

* OpenBSD: only get active CPU core count (Ben Davies)

* test: fix gcc 8 warnings for tests (Nhan Khong)

* ibmi: use correct header files (Xu Meng)

* unix: clear UV_HANDLE_READING flag before callback (zyxwvu Shi)

* unix: fix unused-function warning on BSD (Nhan Khong)

* test: fix test runner on MinGW (Crunkle)

* win: remove try-except outside MSVC (Crunkle)

* win: fix uv_spawn() ENOMEM on empty env (Ben Noordhuis)
2019-08-09 10:57:12 -04:00
Ben Noordhuis
1fc72276f9
win: fix uv_spawn() ENOMEM on empty env
Commit ba780231 ("unix,win: handle zero-sized allocations uniformly")
makes `uv__malloc()` return NULL when `size == 0`.

That's exactly the size that is passed to it when uv_spawn() tries to
spawn a process with an empty environment so handle that edge case.

Fixes: https://github.com/nodejs/node/issues/29008
PR-URL: https://github.com/libuv/libuv/pull/2408
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash+github@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-08-09 09:59:47 -04:00
Crunkle
813264add0
win: remove try-except outside MSVC
Fixes: https://github.com/libuv/libuv/issues/2407
PR-URL: https://github.com/libuv/libuv/pull/2412
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-08-09 09:53:55 -04:00
Crunkle
be1e71916d
test: fix test runner on MinGW
MinGW does not export the _set_fmode function via its
libmsvcrt.a import library unless on an ARM platform. This
causes the test target build to fail without manually
adjusting the link parameters.

It is safe to assume that _fmode is available in all stable
releases, and it should be preferred unless using MSVC. This
is unrelated to #2407, but when both are fixed, MinGW builds
should complete successfully.

PR-URL: https://github.com/libuv/libuv/pull/2411
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-07 14:46:47 -04:00
Nhan Khong
b144695014
unix: fix unused-function warning on BSD
This commit fixes a warning about uv__fs_preadv() being
unused on BSD.

PR-URL: https://github.com/libuv/libuv/pull/2367
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-07 13:49:51 -04:00
zyxwvu Shi
be8b3513d3
unix: clear UV_HANDLE_READING flag before callback
The UV_HANDLE_READING stream flag should be removed before
stopping the IO watcher and calling the callback. If the
callback calls uv_read_start(), the IO watcher will be started
then after the callback the UV_HANDLE_READING flag is removed.
This will result in epoll constantly reporting POLLIN events
while no one handles it, causing 100% CPU usage.

PR-URL: https://github.com/libuv/libuv/pull/2382
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-06 12:55:46 -04:00
Xu Meng
1bd72eb51f
ibmi: use correct header files
IBM i defines both of the __PASE__ and _AIX macros.
Commit 693b534 includes the wrong header file.
Need to check macro __PASE__ prior to _AIX.

PR-URL: https://github.com/libuv/libuv/pull/2371
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-08-06 12:19:34 -04:00
Nhan Khong
faa800605e
test: fix gcc 8 warnings for tests
In test-ipc.c, remove unnecessarily casting uv_stream_s to
uv_pipe_s that makes gcc complain about stric-aliasing
(-Wstrict-aliasing).

In test-queue-foreach-delete.c, using C99 variadic macros
to fix a gcc 8 warnings (-Wcast-function-type).

PR-URL: https://github.com/libuv/libuv/pull/2344
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-08-06 12:01:15 -04:00
Ben Davies
64ab7cc740
OpenBSD: only get active CPU core count
Newer computers may have some cores offline because of the
Meltdown/Spectre patches from a while ago, making uv_cpu_info
potentially misleading and leading to people attempting to use more
threads than they actually have available. This makes it so only the
cores that are online and doing any work are counted.

PR-URL: https://github.com/libuv/libuv/pull/2326
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-08-06 11:23:18 -04:00
Xu Meng
8ff0cd70c6
ibmi: support Makefile build for IBM i
libuv can only be compiled using node-gyp on IBM i.
This commit allows it compiled with autoconf & automake.

PR-URL: https://github.com/libuv/libuv/pull/2379
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-08-06 11:06:36 -04:00
Nan Xiao
f5ca3e868c
doc: fix typo in basics.rst
PR-URL: https://github.com/libuv/libuv/pull/2366
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-08-06 10:59:05 -04:00
Zach Bjornson
ed128ef397
doc: add %p to valgrind log-file arg
Since the tests fork processes, a single log file
is largely unreadable.

PR-URL: https://github.com/libuv/libuv/pull/2383
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-08-06 10:48:41 -04:00
Ben Noordhuis
97e86dde84 Revert "darwin: speed up uv_set_process_title()"
This reverts commit 00c6b1649d.

It's been reported (and I can confirm) that this change breaks
`process.title = 'foo'` in Node.js.

Since libuv just calls out to Core Services and Application Services,
and since those frameworks are really just black boxes that you can't
look inside, it's impossible to debug what exactly goes wrong. Revert
it is then.

Fixes: https://github.com/nodejs/node/issues/28945
PR-URL: https://github.com/libuv/libuv/pull/2405
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-03 21:23:43 +02:00
Saúl Ibarra Corretgé
2480b6158a unix,win: add ability to retrieve all env variables
Fixes: https://github.com/libuv/libuv/issues/2400

PR-URL: https://github.com/libuv/libuv/pull/2404
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-08-03 08:33:42 +02:00
Carlo Marcelo Arenas Belón
ef218cede9 test: avoid AF_LOCAL
Linux specific and practically an alias of AF_UNIX which is POSIX

PR-URL: https://github.com/libuv/libuv/pull/2388

Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-01 22:16:31 +02:00
cjihrig
bf86d5fbaf
unix,win: add uv_fs_statfs()
Fixes: https://github.com/libuv/libuv/issues/2386
PR-URL: https://github.com/libuv/libuv/pull/2396
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-08-01 07:21:15 -10:00
cjihrig
79c2d74058
win: misc fs cleanup
This commit removes two extraneous semicolons and an unused
variable that was generating a compiler warning.

PR-URL: https://github.com/libuv/libuv/pull/2402
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-07-31 05:14:29 -10:00
cjihrig
3f6298c135
github: add root warning to template
A number of bug reports about the test suite are the result
of the user running the test suite as root. It might be
wishful thinking, but perhaps some of the bug reports can
be eliminated by adding some text to the GitHub issue
template.

PR-URL: https://github.com/libuv/libuv/pull/2397
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-07-31 05:00:48 -10:00
Bartosz Sosnowski
ecff27857d win, fs: mkdir return UV_EINVAL for invalid names
Makes uv_fs_mkdir return UV_EINVAL for invalid filenames instead of
UV_ENOENT.

Ref: https://github.com/nodejs/node/issues/28599

PR-URL: https://github.com/libuv/libuv/pull/2375
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-07-16 18:23:07 +02:00
João Reis
2c279504f9 win: add UV_FS_O_FILEMAP
Reading and writing files using a memory file mapping can be
significantly faster on Windows.

PR-URL: https://github.com/libuv/libuv/pull/2295
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-07-16 18:20:10 +02:00
Javier Blazquez
dabc737d78 win: prevent tty event explosion machine hang
The tty subsystem on Windows was listening for console events from all
processes to detect when our console window was being resized. This
could cause an explosion in the number of events queued by the system
when running many console applications in parallel that all wrote to
their console quickly. The end result was a complete machine hang.

Now we determine, whenever possible, what our corresponding conhost.exe
process is and listen for console events from that process only. This
detection does not work in 32-bit applications running on 64-bit
Windows so those default to the old behavior of listening to all
processes.

PR-URL: https://github.com/libuv/libuv/pull/2308
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-07-12 10:14:26 +02:00
Mustafa M
a5d3743778 win: fix uv_os_tmpdir when env var is 260 chars
When TMP environment variable is 261 chars (including the trailing
slash) or 260 chars without the trailing slash, uv_os_tmpdir throws an
UV_EIO error which it shouldn't, since the total input string size
allowable for this function is PATH_MAX+1 (including the trailing slash)

PR-URL: https://github.com/libuv/libuv/pull/2341
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-07-03 14:18:04 +02:00
Javier Blazquez
c905e0bed8
win,fs: don't modify global file translation mode
The MSVC runtime provides a global variable that can be used to set the
default file translation mode so that file open calls don't need to
explicitly specify that mode.

libuv was changing that global mode to binary from its default of text.
However, libuv doesn't actually need to do that anymore, and the
application may not want the default changed under it. This change stops
libuv from modifying that global mode.

PR-URL: https://github.com/libuv/libuv/pull/2324
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-07-02 11:01:42 -04:00
cjihrig
04a48e9ac8
Now working on version 1.30.2
Fixes: https://github.com/libuv/libuv/issues/2363
2019-07-02 10:57:15 -04:00
cjihrig
8785ce8997
Add SHA to ChangeLog 2019-07-02 10:55:04 -04:00
cjihrig
1551969c84
2019.07.03, Version 1.30.1 (Stable)
Changes since version 1.30.0:

* doc: fix incorrect versionchanged (cjihrig)

* test: allow UV_ECONNRESET in tcp_try_write_error (cjihrig)

* unix: add uv_get_constrained_memory() cygwin stub (cjihrig)

* build: fix android cmake build (Ben Noordhuis)

* unix: squelch -Wcast-function-type warning (Ben Noordhuis)

* build: fix compile error with uClibc (zlargon)
2019-07-02 10:55:03 -04:00
Leon Huang
60526073b6 build: fix compile error with uClibc
uClibc does not have header "gnu/libc-version.h"

PR-URL: https://github.com/libuv/libuv/pull/2329
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-07-02 11:58:15 +02:00
Ben Noordhuis
a5ffb50dd7 unix: squelch -Wcast-function-type warning
PR-URL: https://github.com/libuv/libuv/pull/2346
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-07-02 11:36:07 +02:00
Ben Noordhuis
c4ff0457b9 build: fix android cmake build
Fix two 'multiple definition' symbol errors caused by compiling in
sysinfo-memory.c when linux-core.c also provides them (and those
are the correct ones.)

Bug introduced in commit 3a1be725 ("linux: read free/total memory from
/proc/meminfo") released in libuv v1.29.0. It slipped under the radar
because there are no Android machines in our CI matrix.

Fixes: https://github.com/libuv/libuv/issues/2357
PR-URL: https://github.com/libuv/libuv/pull/2362
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-07-02 11:34:27 +02:00
cjihrig
6b74e7b6bf
unix: add uv_get_constrained_memory() cygwin stub
PR-URL: https://github.com/libuv/libuv/pull/2361
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-07-01 14:36:00 -04:00
cjihrig
f66db9c5c5
test: allow UV_ECONNRESET in tcp_try_write_error
Recent CI failures imply that uv_try_write() can return
UV_ECONNRESET - specifically on FreeBSD. This commit
updates the test to pass when that error code is returned.

PR-URL: https://github.com/libuv/libuv/pull/2355
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-06-27 17:23:53 -04:00
cjihrig
1a06462cd3
doc: fix incorrect versionchanged
Version 1.29.2 never happened. Update the versionchanged from
9a10058e72 to be 1.30.0.

PR-URL: https://github.com/libuv/libuv/pull/2354
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-06-27 13:20:14 -04:00
cjihrig
f50a746fa6
Now working on version 1.30.1
Fixes: https://github.com/libuv/libuv/issues/2343
2019-06-27 10:20:17 -04:00
cjihrig
e441553b68
Add SHA to ChangeLog 2019-06-27 10:18:47 -04:00
cjihrig
365b6f2a0e
2019.06.28, Version 1.30.0 (Stable)
Changes since version 1.29.1:

* darwin: fall back to F_BARRIERFSYNC (Ben Noordhuis)

* darwin: add 32 bit close$NOCANCEL implementation
  (ken-cunningham-webuse)

* build, core, unix: add support for Haiku (Leorize)

* darwin,linux: more conservative minimum stack size (Ben Noordhuis)

* threadpool: increase UV_THREADPOOL_SIZE limit (Vlad A)

* unix: return actual error from `uv_try_write()` (Anna Henningsen)

* darwin: fix build error with macos 10.10 (Ben Noordhuis)

* unix: make uv_cwd() report UV_ENOBUFS (Ben Noordhuis)

* unix: make uv_fs_read() fill all buffers (Ben Noordhuis)

* test: give hrtime test a custom 10s timeout (Ben Noordhuis)

* fs: fix uv_fs_copyfile if same src and dst (Santiago Gimeno)

* build: add cmake option to skip building tests (Niels Lohmann)

* doc: add link to nodejs.org (Jenil Christo)

* unix: fix a comment typo in signal.c (Evgeny Ermakov)

* unix: remove redundant cast in process.c (gengjiawen)

* doc: fix wrong mutex function prototypes (Leo Chung)
2019-06-27 10:18:46 -04:00
Leo Chung
5fc58eb3d5 doc: fix wrong mutex function prototypes
The `:lines:` numbers were wrong, they showed the signatures of the
uv_fs_access and uv_fs_chmod functions.
2019-06-25 08:57:42 +02:00
gengjiawen
69c78f9ff7
unix: remove redundant cast in process.c
PR-URL: https://github.com/libuv/libuv/pull/2300
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-24 22:00:03 -04:00
Evgeny Ermakov
d92c5d1314
unix: fix a comment typo in signal.c
PR-URL: https://github.com/libuv/libuv/pull/2318
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Vladimír Čunát <v@cunat.cz>
2019-06-24 21:41:46 -04:00
Jenil Christo
805401b0b3
doc: add link to nodejs.org
PR-URL: https://github.com/libuv/libuv/pull/2325
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-24 21:32:13 -04:00
Niels Lohmann
f8cab71872
build: add cmake option to skip building tests
In case libuv is included via add_subdirectory, its tests are always
built and executed. This cannot be skipped currently, because switching
BUILD_TESTING to false would also switch off all other tests in the
parent project.

This commit adds a switch "libuv_buildtests" which can individually
switch of the compilation and execution of libuv's tests. It is ON by
default, so the default behavior does not change. However, projects
that include libuv via add_subdirectory can not set libuv_buildtests to
OFF if they are not interested in its tests.

PR-URL: https://github.com/libuv/libuv/pull/2094
Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-24 21:22:38 -04:00
Santiago Gimeno
0b29acb0ca
fs: fix uv_fs_copyfile if same src and dst
Specifically return success.
It fixes a tight loop on unices as `sendfile()` was returning 0 and also
makes the function behave the same both on `unix` and `windows`.

It partially implements: https://github.com/libuv/libuv/issues/2237

PR-URL: https://github.com/libuv/libuv/pull/2298
Refs: https://github.com/nodejs/node/issues/27746
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-23 14:37:11 +02:00
Ben Noordhuis
5fd480678c test: give hrtime test a custom 10s timeout
The test is supposed to complete in about 3.5s but it can
hit the 5s timeout when run on a system with high load.

Fixes: https://github.com/libuv/libuv/issues/2342
PR-URL: https://github.com/libuv/libuv/pull/2345
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-21 15:58:36 +02:00
Ben Noordhuis
087c461ee9 unix: make uv_fs_read() fill all buffers
The fallback for systems that lack preadv() only filled the first
buffer.

This commit rectifies that to fill all (or at least as many as possible)
buffers.

Fixes: https://github.com/libuv/libuv/issues/2332
PR-URL: https://github.com/libuv/libuv/pull/2338
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-06-20 12:06:31 +02:00
Ben Noordhuis
6e18112127 unix: make uv_cwd() report UV_ENOBUFS
Make uv_cwd() do what the documentation says it did when the destination
buffer is too small: report UV_ENOBUFS and set the `size` in/out param
to the size of the path including the trailing nul byte.

Fixes: https://github.com/libuv/libuv/issues/2333
PR-URL: https://github.com/libuv/libuv/pull/2335
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>
2019-06-20 12:04:16 +02:00
Ben Noordhuis
53f4772115 darwin: fix build error with macos 10.10
F_BARRIERFSYNC isn't defined when building on that platform.

PR-URL: https://github.com/libuv/libuv/pull/2334
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-06-20 12:01:30 +02:00
Anna Henningsen
ee24ce900e
unix: return actual error from uv_try_write()
So far, for some (?) errors, `uv_try_write()` returns `EAGAIN`
regardless of the actual error, so `ECONNRESET` and `EPIPE` errors
can be swallowed here.

This commit changes `uv_try_write()` so that it prefers to return
the actual error it has seen.

PR-URL: https://github.com/libuv/libuv/pull/2321
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-06-10 15:17:21 +02:00
Vlad A
9a10058e72 threadpool: increase UV_THREADPOOL_SIZE limit
Increase the UV_THREADPOOL_SIZE limit to 1024 and update the docs.

Fixes: https://github.com/libuv/libuv/pull/2296
PR-URL: https://github.com/libuv/libuv/pull/2314
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-06-07 10:59:44 +02:00
Ben Noordhuis
d89bd156cf darwin,linux: more conservative minimum stack size
uv_thread_create() inspects min(PTHREAD_STACK_MIN, RLIMIT_STACK) to
find out the minimum allowed stack size. After spelunking through
kernel and libc code, I came to the conclusion that allowing such
small stacks does not mix well with signals.

Musl's PTHREAD_STACK_MIN is 2 KB but signal handlers on many
architectures need at least 1 KB to store the signal context,
making it almost impossible to do anything on the thread without
signal delivery overflowing the stack.

Therefore, increase the lower bound to 8 KB. That corresponds to
PTHREAD_STACK_MIN + MINSIGSTKSZ on arm64, which has the largest
MINSIGSTKSZ of the architectures that musl supports.

PR-URL: https://github.com/libuv/libuv/pull/2310
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-06-07 09:59:00 +02:00
Leorize
abe4f3d58d build, core, unix: add support for Haiku
This commit add support for Haiku, an open-source operating system
inspired by BeOS.

PR-URL: https://github.com/libuv/libuv/pull/2301
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-07 09:57:06 +02:00
ken-cunningham-webuse
ffad651b9d darwin: add 32 bit close$NOCANCEL implementation
The link symbol for close$NOCANCEL is slightly different for 32 bit
builds.

PR-URL: https://github.com/libuv/libuv/pull/2309
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-07 09:52:04 +02:00
Ben Noordhuis
9a41731949 darwin: fall back to F_BARRIERFSYNC
Fall back to F_BARRIERFSYNC if F_FULLFSYNC is not supported by the file
system, only fall back to fsync() if both fcntls fail.

F_BARRIERFSYNC should be at least as safe as fsync() because it's fsync
coupled with a barrier.

PR-URL: https://github.com/libuv/libuv/pull/2317
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-07 09:38:28 +02:00
cjihrig
4a4c9a688f
Now working on version 1.29.2
Fixes: https://github.com/libuv/libuv/issues/2306
2019-05-21 09:47:22 -04:00
cjihrig
3f5c1f339d
Add SHA to ChangeLog 2019-05-21 09:44:45 -04:00
cjihrig
d16e6094e1
2019.05.22, Version 1.29.1 (Stable)
Changes since version 1.29.0:

* unix: simplify uv/posix.h include logic (cjihrig)

* test: increase test timeout (cjihrig)

* linux: fix sscanf() overflows reading from /proc (Ben Noordhuis)
2019-05-21 09:44:45 -04:00
Ben Noordhuis
d7f0055b80
linux: fix sscanf() overflows reading from /proc
Use `"%" PRIu64` and uint64_t for sscanf-ing large values, not `"%lu"`
and unsigned long. The latter can overflow when libuv is a 32 bits
application running on a 64 bits machine.

Fixes: https://github.com/libuv/libuv/issues/2297
PR-URL: https://github.com/libuv/libuv/pull/2305
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-21 09:02:15 -04:00
cjihrig
fddcd14825
test: increase test timeout
The test threadpool_multiple_event_loops has been timing
out consistently on FreeBSD in the CI. This commit attempts
to mitigate the problem by extending the test timeout.

PR-URL: https://github.com/libuv/libuv/pull/2304
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-05-21 08:50:33 -04:00
cjihrig
693b534f2c
unix: simplify uv/posix.h include logic
This commit includes uv/posix.h in one #elif instead of four.

PR-URL: https://github.com/libuv/libuv/pull/2302
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-05-20 14:07:46 -04:00
cjihrig
2169a53cd2
Now working on 1.29.1
Fixes: https://github.com/libuv/libuv/issues/2293
2019-05-15 13:16:23 -04:00
cjihrig
77db62edac
Add SHA to ChangeLog 2019-05-15 13:14:17 -04:00
cjihrig
43957efd92
2019.05.16, Version 1.29.0 (Stable)
Changes since version 1.28.0:

* ibmi: read memory and CPU usage info (Xu Meng)

* doc: update the cmake testing instruction (zlargon)

* unix: fix race condition in uv_async_send() (Ben Noordhuis)

* linux: use O_CLOEXEC instead of EPOLL_CLOEXEC (Ben Noordhuis)

* doc: mark uv_async_send() as async-signal-safe (Ben Noordhuis)

* linux: init st_flags and st_gen when using statx (Oscar Waddell)

* linux: read free/total memory from /proc/meminfo (Ben Noordhuis)

* test: test zero-sized uv_fs_sendfile() writes (Ben Noordhuis)

* unix: don't assert on UV_PROCESS_WINDOWS_* flags (Ben Noordhuis)

* linux: set correct mac address for IP-aliases (Santiago Gimeno)

* win,util: fix null pointer dereferencing (Tobias Nießen)

* unix,win: fix `uv_fs_poll_stop()` when active (Anna Henningsen)

* doc: add missing uv_fs_type entries (Michele Caini)

* doc: fix build with sphinx 2.x (FX Coudert)

* unix: don't make statx system call on Android (George Zhao)

* unix: fix clang scan-build warning (Kyle Edwards)

* unix: fall back to kqueue on older macOS systems
  (ken-cunningham-webuse)

* unix,win: add uv_get_constrained_memory() (Kelvin Jin)

* darwin: fix thread cancellation fd leak (Ben Noordhuis)

* linux: fix thread cancellation fd leak (Ben Noordhuis)
2019-05-15 13:14:17 -04:00
Ben Noordhuis
2138dd2f08
linux: fix thread cancellation fd leak
Same as the previous commit but this time for Linux.

Specifically, the glibc close() wrapper is a cancellation point;
the thread is unwound when close() is called when the thread is
in the "cancel" state.

That's according to spec and therefore arguably less severe than
MacOS's "EINTR without actually closing" behavior but we can avoid
the file descriptor leak altogether by sidestepping glibc and
making the system call directly.

Musl libc is unaffected, its close() wrapper doesn't check
the cancel state.

PR-URL: https://github.com/libuv/libuv/pull/2291
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-15 12:19:46 -04:00
Ben Noordhuis
9063c27f92
darwin: fix thread cancellation fd leak
The close() system call tests for thread cancellation first. That has
the unfortunate side effect of aborting the sytem call with EINTR
without actually closing the file descriptor when the thread is in
the "cancel" state. Work around that by calling close$NOCANCEL().

This might well qualify as an academic bug because approximately no one
uses thread cancellation but let's aim for correctness anyway.

PR-URL: https://github.com/libuv/libuv/pull/2291
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-15 12:18:57 -04:00
Kelvin Jin
c4e9657d59
unix,win: add uv_get_constrained_memory()
Fixes: https://github.com/libuv/libuv/issues/2286
PR-URL: https://github.com/libuv/libuv/pull/2289
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-15 11:35:05 -04:00
ken-cunningham-webuse
6602fca820
unix: fall back to kqueue on older macOS systems
Newer macOS systems (10.7+) use fsevents() for the fs_event backend,
but older macOS systems don't have full functionality for this in
the macOS fsevents() API. Fall back to kqueue for these systems.

PR-URL: https://github.com/libuv/libuv/pull/2290
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-15 11:28:19 -04:00
Kyle Edwards
69c85fa88e
unix: fix clang scan-build warning
When building libuv with clang scan-build, an "Assigned value is
garbage or undefined" warning is emitted unless the return value
of open() is verified to be >= 0. This commit fixes the warning.

PR-URL: https://github.com/libuv/libuv/pull/2140
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-05-13 22:11:50 -04:00
George Zhao
a833f921b8
unix: don't make statx system call on Android
Fixes: https://github.com/libuv/libuv/issues/2282
PR-URL: https://github.com/libuv/libuv/pull/2284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-13 21:42:52 -04:00
FX Coudert
68173cc802
doc: fix build with sphinx 2.x
app.info() was deprecated on Jan 4, 2017 (sphinx-doc/sphinx#3267),
and removed as of Sphinx 2.0.0. This commit removes the usage of
app.info().

PR-URL: https://github.com/libuv/libuv/pull/2265
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-05-13 16:06:29 -04:00
Michele Caini
557b04cdce
doc: add missing uv_fs_type entries
PR-URL: https://github.com/libuv/libuv/pull/2280
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-13 16:00:58 -04:00
Anna Henningsen
6c760b6207 unix,win: fix uv_fs_poll_stop() when active
Fix `uv_fs_poll_stop()` for active handles by not attempting to
mark the `uv_fs_poll_t` handle as closing when `uv_close()`
hasn’t been called on it.

Fixes: https://github.com/libuv/libuv/issues/2287
PR-URL: https://github.com/libuv/libuv/pull/2288
Refs: https://github.com/libuv/libuv/pull/1875
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-05-06 15:02:01 +02:00
Tobias Nießen
620be96fc4
win,util: fix null pointer dereferencing
If uv__calloc returns NULL, the function jumps to the error label and
attempts to access array elements of cpu_infos (which is NULL).

PR-URL: https://github.com/libuv/libuv/pull/2264
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>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-26 20:10:27 +02:00
Santiago Gimeno
8b87533863
linux: set correct mac address for IP-aliases
IP-alias format is the interface name followed by a colon and a string
(usually a number). Set the physical address to the one in the 'base'
interface.

PR-URL: https://github.com/libuv/libuv/pull/2248
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-26 20:04:16 +02:00
Ben Noordhuis
a74e54bc8f unix: don't assert on UV_PROCESS_WINDOWS_* flags
UV_PROCESS_WINDOWS_HIDE_CONSOLE and UV_PROCESS_WINDOWS_HIDE_GUI were
whitelisted on Windows but not Unices. Now they are.

Bug introduced in commit 4c2dcca27 ("win: support more fine-grained
windows hiding") which I reviewed but where I failed to spot it. Mea
culpa.

Fixes: https://github.com/libuv/libuv/issues/2266
PR-URL: https://github.com/libuv/libuv/pull/2278
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Kyle Edwards <kyle.edwards@kitware.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-04-23 21:47:21 +02:00
Ben Noordhuis
cb30144f52 test: test zero-sized uv_fs_sendfile() writes
This was reported as a bug in November 2018 but it appears to be working
now. Add a regression test to ensure it stays that way.

Fixes: https://github.com/libuv/libuv/issues/2076
PR-URL: https://github.com/libuv/libuv/pull/2279
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-04-23 21:43:23 +02:00
Ben Noordhuis
3a1be72532 linux: read free/total memory from /proc/meminfo
It was reported that uv_get_free_memory() and uv_get_total_memory()
report the wrong values inside an lxc container.

Libuv calls sysinfo(2) but that isn't intercepted by lxc. /proc/meminfo
however is because /proc is a FUSE fs inside the container.

This commit makes libuv try /proc/meminfo first and fall back to
sysinfo(2) in case /proc isn't mounted.

Fixes: https://github.com/libuv/libuv/issues/2249
PR-URL: https://github.com/libuv/libuv/pull/2258
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-23 11:49:37 +02:00
Oscar Waddell
1c2dc9c8d1 linux: init st_flags and st_gen when using statx
Explicitly initialize uv_stat_t fields st_flags and st_gen when using
statx as uv__to_stat does when statx is not available. This makes
valgrind happier.

PR-URL: https://github.com/libuv/libuv/pull/2263
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2019-04-23 11:28:10 +02:00
Ben Noordhuis
03e389eb43 doc: mark uv_async_send() as async-signal-safe
Refs: https://github.com/libuv/libuv/issues/2173
PR-URL: https://github.com/libuv/libuv/pull/2273
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-23 10:46:56 +02:00
Ben Noordhuis
ab5859129b linux: use O_CLOEXEC instead of EPOLL_CLOEXEC
It was reported that EPOLL_CLOEXEC is not defined on Android API < 21,
a.k.a. Lollipop. Since EPOLL_CLOEXEC is an alias for O_CLOEXEC on all
architectures, we just use that instead.

Fixes: https://github.com/libuv/libuv/issues/2167
PR-URL: https://github.com/libuv/libuv/pull/2272
Refs: https://github.com/libuv/libuv/pull/2216
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-23 10:45:28 +02:00
Ben Noordhuis
37042a5bca unix: fix race condition in uv_async_send()
After inspection of the code, it seems like there is a race window
between the cmpxchgi() and uv__async_send() calls.

If the event loop thread is already busy looping over the async handles,
it can invoke the callback - which in turn can close the handle - before
the other thread reaches the uv__async_send() call. That's bad because
it accesses the handle that at that point might not be valid anymore.

Fix that by introducing an ad hoc spinlock that blocks the event loop
thread until the sending thread is done. It's not pretty or elegant
but it fixes the immediate bug and appears to have no measurable
impact on the async handle benchmarks.

Fixes: https://github.com/libuv/libuv/issues/2226
PR-URL: https://github.com/libuv/libuv/pull/2231
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-04-22 16:22:36 +02:00
Leon Huang
87a116c4d0 doc: update the cmake testing instruction
PR-URL: https://github.com/libuv/libuv/pull/2253
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-22 16:20:20 +02:00
Xu Meng
16fe9a8602 ibmi: read memory and CPU usage info
PR-URL: https://github.com/libuv/libuv/pull/2261
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-22 16:16:28 +02:00
cjihrig
2e443b12bd
Now working on 1.28.1
Fixes: https://github.com/libuv/libuv/issues/2228
2019-04-15 11:21:31 -04:00
cjihrig
500c929772
Add SHA to ChangeLog 2019-04-15 11:19:27 -04:00
cjihrig
7bf8fabfa9
2019.04.16, Version 1.28.0 (Stable)
Changes since version 1.27.0:

* unix,win: add uv_gettimeofday() (cjihrig)

* unix,win: add uv_fs_{open,read,close}dir() (cjihrig)

* unix: fix uv_interface_addresses() (Andreas Rohner)

* fs: remove macOS-specific copyfile(3) (Rich Trott)

* fs: add test for copyfile() respecting permissions (Rich Trott)

* build: partially revert 5234b1c43a (Ben Noordhuis)

* zos: fix setsockopt error when using AF_UNIX (Milad Farazmand)

* unix: suppress EINTR/EINPROGRESS in uv_fs_close() (Ben Noordhuis)

* build: use cmake APPLE variable to detect platform (zlargon)

* distcheck: remove duplicate test/ entry (Jameson Nash)

* unix: remove unused cmpxchgl() function (Ben Noordhuis)

* unix: support sockaddr_un in uv_udp_send() (Yury Selivanov)

* unix: guard use of PTHREAD_STACK_MIN (Kamil Rytarowski)

* unix,win: introduce uv_timeval64_t (cjihrig)

* doc: document uv_timeval_t and uv_timeval64_t (cjihrig)
2019-04-15 11:19:26 -04:00
cjihrig
2a9d626b4c
doc: document uv_timeval_t and uv_timeval64_t
PR-URL: https://github.com/libuv/libuv/pull/2246
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-11 14:10:14 -04:00
cjihrig
2e090c8f2c
unix,win: introduce uv_timeval64_t
Fixes: https://github.com/libuv/libuv/issues/2243
PR-URL: https://github.com/libuv/libuv/pull/2246
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-11 14:08:17 -04:00
Kamil Rytarowski
38bb0f5f5f
unix: guard use of PTHREAD_STACK_MIN
PTHREAD_STACK_MIN is an optional part of the POSIX spec and
NetBSD deliberately does not implement it as it's a variable
value in runtime.

PR-URL: https://github.com/libuv/libuv/pull/2252
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-04-11 12:36:55 -04:00
Yury Selivanov
89a027d862
unix: support sockaddr_un in uv_udp_send()
PR-URL: https://github.com/libuv/libuv/pull/2220
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-11 11:04:43 -04:00
Ben Noordhuis
280f7b2496
unix: remove unused cmpxchgl() function
PR-URL: https://github.com/libuv/libuv/pull/2230
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-04-11 10:50:19 -04:00
Jameson Nash
0da05ce652
distcheck: remove duplicate test/ entry
It can be confusing to distcheck that we list it explicitly,
since it already adds it automatically, and we have configure
and build products in there.

Fixes: https://github.com/libuv/libuv/issues/2199
Refs: https://github.com/libuv/libuv/issues/2198
PR-URL: https://github.com/libuv/libuv/pull/2229
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-11 10:17:51 -04:00
zlargon
9521339c2e
build: use cmake APPLE variable to detect platform
- CMake 3.14: supports Cross Compiling for iOS, tvOS, or watchOS
  using simple toolchain files.
  https://cmake.org/cmake/help/v3.14/release/3.14.html#platforms

- CMake 3.10: APPLE variable set to TURE when the target system
  is an Apple platform (macOS, iOS, tvOS or watchOS).
  https://cmake.org/cmake/help/v3.10/variable/APPLE.html

- CMake 3.0: APPLE variable support since v3.0.
  https://cmake.org/cmake/help/v3.0/variable/APPLE.html

PR-URL: https://github.com/libuv/libuv/pull/2245
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-11 10:00:06 -04:00
Ben Noordhuis
a40a5e897d
unix: suppress EINTR/EINPROGRESS in uv_fs_close()
close() is interruptible, meaning that a signal delivered when the
close() system call is executing, can result in a return value of
-1 with errno set to EINTR or EINPROGRESS. A survey of supported
Unices suggests the file descriptor is in fact closed and so there
is nothing to do except ignore the error.

Libuv already handled it correctly for internal file descriptors
throug uv__close() and uv__close_nocheckstdio() but uv_fs_close()
did not until now.

PR-URL: https://github.com/libuv/libuv/pull/2236
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-04-11 09:39:37 -04:00
Milad Farazmand
fd67cd538c
zos: fix setsockopt error when using AF_UNIX
PR-URL: https://github.com/libuv/libuv/pull/2224
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Yury Selivanov <yury@magic.io>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-11 09:31:29 -04:00
Ben Noordhuis
3c521dedb4
build: partially revert 5234b1c43a
This undoes the changes commit 5234b1c4 ("build,sunos: better handling
of non-GCC compiler") makes to configure.ac and Makefile.am because they
break the build on the centos6 buildbots with the following error:

    # <snip>
    checking for _FILE_OFFSET_BITS value needed for large files... no
    ./configure: line 12957: syntax error near unexpected token `;'
    ./configure: line 12957: `; then'
    Build step 'Execute shell' marked build as failure

Refs: https://github.com/libuv/libuv/pull/2200
PR-URL: https://github.com/libuv/libuv/pull/2234
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-04-11 09:14:09 -04:00
Rich Trott
c7b87b0d51
fs: add test for copyfile() respecting permissions
Add test to test-fs-copyfile.c to check that uv_fs_copyfile() respects
destination file permissions. Previously, in macOS, it did not.

PR-URL: https://github.com/libuv/libuv/pull/2233
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2019-04-10 21:47:41 -04:00
Rich Trott
5bc4d7738a
fs: remove macOS-specific copyfile(3)
Using copyfile(3) on macOS apparently results in situations where file
permissions are ignored. Using the same code for other UNIX-like
operating systems seems to fix the issue.

Refs: https://github.com/nodejs/node/issues/26936#issuecomment-476992597
PR-URL: https://github.com/libuv/libuv/pull/2233
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2019-04-10 21:45:23 -04:00
Andreas Rohner
d0fb86cdf3
unix: fix uv_interface_addresses()
The memset() in the inner loop clears previously copied phys_addrs. As a
result, every interface is reported to have a phys_addr of
00:00:00:00:00:00, except the last one. This bug only manifests on
systems with multiple interfaces.

PR-URL: https://github.com/libuv/libuv/pull/2153
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-04-10 06:52:11 +02:00
cjihrig
99440bb673
unix,win: add uv_fs_{open,read,close}dir()
Co-authored-by: Julien Gilli <jgilli@nodejs.org>
Co-authored-by: Jeremy Whitlock <jwhitlock@apache.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/libuv/libuv/pull/2057
Refs: https://github.com/joyent/libuv/issues/1430
Refs: https://github.com/joyent/libuv/pull/1521
Refs: https://github.com/joyent/libuv/pull/1574
Refs: https://github.com/libuv/libuv/pull/175
Refs: https://github.com/nodejs/node/issues/583
Refs: https://github.com/libuv/libuv/pull/416
Refs: https://github.com/libuv/libuv/issues/170
2019-03-26 18:47:51 -04:00
cjihrig
575d41481e
unix,win: add uv_gettimeofday()
PR-URL: https://github.com/libuv/libuv/pull/2221
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-25 20:23:49 -04:00
cjihrig
23bb992d7b
Now working on version 1.27.1
Fixes: https://github.com/libuv/libuv/issues/2213
2019-03-16 14:35:15 -04:00
cjihrig
04f51e7c8a
Add SHA to ChangeLog 2019-03-16 14:31:48 -04:00
cjihrig
a4fc9a66cc
2019.03.17, Version 1.27.0 (Stable)
Changes since version 1.26.0:

* doc: describe unix signal handling better (Vladimír Čunát)

* linux: use statx() to obtain file birth time (Ben Noordhuis)

* src: fill sockaddr_in6.sin6_len when it's defined (Santiago Gimeno)

* test: relax uv_hrtime() test assumptions (Ben Noordhuis)

* build: make cmake install LICENSE only once (Thomas Karl Pietrowski)

* bsd: plug uv_fs_event_start() error path fd leak (Ben Noordhuis)

* unix: fix __FreeBSD_kernel__ typo (cjihrig)

* doc: add note about uv_run() not being reentrant (Ben Noordhuis)

* unix, win: make fs-poll close wait for resource cleanup (Anna
  Henningsen)

* doc: fix typo in uv_thread_options_t definition (Ryan Liptak)

* win: skip winsock initialization in safe mode (evgley)

* unix: refactor getsockname/getpeername methods (Santiago Gimeno)

* win,udp: allow to use uv_udp_open on bound sockets (Santiago Gimeno)

* udp: add support for UDP connected sockets (Santiago Gimeno)

* build: fix uv_test shared uv Windows cmake build (ptlomholt)

* build: add android-configure scripts to EXTRA_DIST (Ben Noordhuis)

* build: add missing header (cjihrig)

* sunos: add perror() output prior to abort() (Andrew Paprocki)

* test,sunos: disable UV_DISCONNECT handling (Andrew Paprocki)

* sunos: disable __attribute__((unused)) (Andrew Paprocki)

* test,sunos: use unistd.h code branch (Andrew Paprocki)

* build,sunos: better handling of non-GCC compiler (Andrew Paprocki)

* test,sunos: fix statement not reached warnings (Andrew Paprocki)

* sunos: fix argument/prototype mismatch in atomics (Andrew Paprocki)

* test,sunos: test-ipc.c lacks newline at EOF (Andrew Paprocki)

* test: change spawn_stdin_stdout return to void (Andrew Paprocki)

* test: remove call to floor() in test driver (Andrew Paprocki)
2019-03-16 14:31:48 -04:00
Andrew Paprocki
f0ed5df5e8
test: remove call to floor() in test driver
Using `floor()` instead of integer division causes the test driver
to require linking against `libm` on Solaris.

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:22:56 -04:00
Andrew Paprocki
874083d5b3
test: change spawn_stdin_stdout return to void
The return type is changed to avoid having to craft an artificial
`return` just for the Studio compiler.

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:22:56 -04:00
Andrew Paprocki
7f2d5bc32b
test,sunos: test-ipc.c lacks newline at EOF
The Studio compiler issues a warning because the source file lacks a
newline at the end of the file.

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:22:56 -04:00
Andrew Paprocki
c75893fd13
sunos: fix argument/prototype mismatch in atomics
The `atomic_cas_uint` and `atomic_cas_ulong` functions expect `uint_t`
and `ulong_t` parameters, respectively, so cast the `int`/`long` inputs
to avoid loud compiler warnings.

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:22:56 -04:00
Andrew Paprocki
53c15c09e4
test,sunos: fix statement not reached warnings
The Studio C compiler issues a warning if there is a `return` after an
`abort()` call or an unreachable `return` after a prior `return`.

The Studio C compiler issues a warning if there is a `return` after a
prior `return`, or an endless loop (e.g., `for (;;)`) with a `return` at
the end of the function.

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:22:16 -04:00
Andrew Paprocki
5234b1c43a
build,sunos: better handling of non-GCC compiler
`AC_PROG_CC` sets the `GCC` shell variable, which is supposed to be
used to enable GCC-specific options.  A `GCC` check is added to only
pass the pre-existing GCC-specific options when using GCC.

The `GCC` variable is passed as an `AM_CONDITIONAL` and is used in
`Makefile.am` is used to address the following:

- Only pass `-pthreads` on `SUNOS` when using GCC
- Only use `-Wno-long-long` when using GCC

With the above changes, the Solaris build is now fixed when using the
native Studio compiler along with the minor adjustments:

- Always pass `-D_REENTRANT` to get thread-safe `errno`

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:20:58 -04:00
Andrew Paprocki
aa4ff14a5a
test,sunos: use unistd.h code branch
Tests do not compile when selecting the non-`unistd.h` branch.

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:20:48 -04:00
Andrew Paprocki
f62240b2d1
sunos: disable __attribute__((unused))
The Studio compiler prints out a warning when this attribute is used
because it does not support it (at least as of the latest 12.6 version):
https://docs.oracle.com/cd/E77782_01/html/E77788/gjzke.html#scrolltoc

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:20:40 -04:00
Andrew Paprocki
bdf9a96afa
test,sunos: disable UV_DISCONNECT handling
Solaris does not support the non-standard Linux `POLLRDHUP` event, so
disable the code awaiting the disconnects to exit the loop.  Without
this, the `poll_duplex` and `poll_unidirectional` tests will hang and
timeout.

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:20:31 -04:00
Andrew Paprocki
450b93aaff
sunos: add perror() output prior to abort()
There are three `abort()` calls within the I/O subsystem related to
Solaris ports (`port_associate()`, `port_dissociate()`, and
`port_getn()`).  To simplify debugging issues where the kernel is
setting `errno` and returning failure, call `perror()` to see the
`errno` value cause of the failure.

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:19:43 -04:00
cjihrig
bc36f0c34a
build: add missing header
Refs: https://github.com/libuv/libuv/pull/2198#issuecomment-466118047
PR-URL: https://github.com/libuv/libuv/pull/2219
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-03-16 13:11:45 -04:00
Ben Noordhuis
1a33dcb11b
build: add android-configure scripts to EXTRA_DIST
Commit baa81465a ("build: add compile for android arm64/x86/x86-64")
introduced a number of new android-configure scripts but didn't add
them to EXTRA_DIST in Makefile.am, causing `make dist` to fail.

This commit also removes checkspare.sh from EXTRA_DIST. I broke that
in commit a7a16219d ("unix: remove checksparse.sh") from last June.
Mea culpa!

Fixes: https://github.com/libuv/libuv/issues/2190
PR-URL: https://github.com/libuv/libuv/pull/2198
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-03-16 12:34:10 -04:00
Poul Thomas Lomholt
c4a77f5bc7
build: fix uv_test shared uv Windows cmake build
This commit fixes a linker error when building tests
via cmake on Windows by adding the proper
USING_UV_SHARED=1 define when linking to the shared
libuv.

Fixes: https://github.com/libuv/libuv/issues/2188
PR-URL: https://github.com/libuv/libuv/pull/2187
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-03-16 12:11:01 -04:00
Santiago Gimeno
90415a3394
udp: add support for UDP connected sockets
Add two new methods:

`uv_udp_connect()` to connect / disconnect an UDP handle.
`uv_udp_getpeername()` to get the remote peer address of a connected UDP
handle.

Modify `uv_udp_send()` and `uv_udp_try_send()` to accept a `NULL` `addr`
to send messages over an "UDP connection".

Refs: https://github.com/libuv/leps/pull/10
PR-URL: https://github.com/libuv/libuv/pull/1872
Backport-PR-URL: https://github.com/libuv/libuv/pull/2217
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-03-16 12:05:37 -04:00
Santiago Gimeno
03061d54f0
win,udp: allow to use uv_udp_open on bound sockets
PR-URL: https://github.com/libuv/libuv/pull/1872
Backport-PR-URL: https://github.com/libuv/libuv/pull/2217
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-03-16 12:05:32 -04:00
Santiago Gimeno
d16897c493
unix: refactor getsockname/getpeername methods
PR-URL: https://github.com/libuv/libuv/pull/1872
Backport-PR-URL: https://github.com/libuv/libuv/pull/2217
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-03-16 12:05:23 -04:00
evgley
af31d01492
win: skip winsock initialization in safe mode
uv_winsock_init calls abort() if socket operation failed, which means
all libuv-based applications are not able to start in safe mode
without network.

PR-URL: https://github.com/libuv/libuv/pull/2205
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-03-16 11:42:41 -04:00
Ryan Liptak
419975e54e
doc: fix typo in uv_thread_options_t definition
PR-URL: https://github.com/libuv/libuv/pull/2195
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-03-16 11:37:00 -04:00
Anna Henningsen
bdb5838eac
unix, win: make fs-poll close wait for resource cleanup
Wait until all fs requests spawned by an `uv_fs_poll_t`
have finished and all timers created by it have fully been
closed before calling the close callback.

Fixes: https://github.com/libuv/libuv/issues/1869
PR-URL: https://github.com/libuv/libuv/pull/1875
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-11 09:50:01 +00:00
Ben Noordhuis
7262dd0490 doc: add note about uv_run() not being reentrant
PR-URL: https://github.com/libuv/libuv/pull/2208
Refs: https://github.com/libuv/help/issues/81
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-03-08 08:40:06 +01:00
cjihrig
45a49688c8
unix: fix __FreeBSD_kernel__ typo
Fixes: https://github.com/libuv/libuv/issues/2212
PR-URL: https://github.com/libuv/libuv/pull/2214
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-03-01 13:05:06 -05:00
Ben Noordhuis
09ba4778d8 bsd: plug uv_fs_event_start() error path fd leak
Close the watched file's file descriptor when initialization fails due
to out-of-memory conditions.

PR-URL: https://github.com/libuv/libuv/pull/2197
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-02-26 03:46:46 +01:00
Thomas Karl Pietrowski
bcef1c16fb build: make cmake install LICENSE only once
The license file is installed twice. Once where it should be installed
and the second time into the pkg-config directory. Among other files
from other projects it might be confusing why there is a license file
among with other files. Additionally, that is normally not the right
location for license files. Guess, that is only a copy/pasting mistake.

PR-URL: https://github.com/libuv/libuv/pull/2204
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-25 12:51:51 +01:00
Ben Noordhuis
cdee607d48 test: relax uv_hrtime() test assumptions
Expecting `uv_sleep(45)` to wake up within 80 ms is not a reasonable
assumption: the operating system may not reschedule the process within
that time frame when the system is overloaded.

The test fails intermittently on our own CI and packagers have reported
similar failures.

Fixes: https://github.com/libuv/libuv/issues/2117
PR-URL: https://github.com/libuv/libuv/pull/2186
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-02-21 13:02:44 +01:00
Santiago Gimeno
98db18479a
src: fill sockaddr_in6.sin6_len when it's defined
As some calls in some platforms require.

PR-URL: https://github.com/libuv/libuv/pull/2189
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-16 21:49:34 +01:00
Ben Noordhuis
19d8eb0c92 linux: use statx() to obtain file birth time
Kernels > 4.11 support the statx() system call that lets one retrieve
the birth time of a file. Teach libuv about it.

Fixes: https://github.com/libuv/libuv/issues/2152
PR-URL: https://github.com/libuv/libuv/pull/2184
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-02-12 11:16:44 +01:00
Vladimír Čunát
4fc5a0ee61 doc: describe unix signal handling better
- SIGTERM seems OK to handle - I tested that on Linux, read POSIX, etc.
  I can't see why it should be different from SIGUSR1, for example,
  except that the default handler is different.
- Also raise(15) is caught by the handler for me, and I can't see
  why it wouldn't.

The main source of knowledge for this is POSIX.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03_03

PR-URL: https://github.com/libuv/libuv/pull/1987
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-11 15:55:24 +01:00
cjihrig
598a49b942
Now working on version 1.26.1
Fixes: https://github.com/libuv/libuv/issues/2180
2019-02-10 11:46:28 -05:00
cjihrig
0c3ce4b316
Add SHA to ChangeLog 2019-02-10 11:44:48 -05:00
cjihrig
8669d8d3e9
2019.02.11, Version 1.26.0 (Stable)
Changes since version 1.25.0:

* doc: fix uv_get_free_memory doc (Stephen Belanger)

* unix: fix epoll cpu 100% issue (yeyuanfeng)

* openbsd,tcp: special handling of EINVAL on connect (ptlomholt)

* win: simplify registry closing in uv_cpu_info() (cjihrig)

* src,include: define UV_MAXHOSTNAMESIZE (cjihrig)

* win: return product name in uv_os_uname() version (cjihrig)

* thread: allow specifying stack size for new thread (Anna Henningsen)

* win: fix duplicate tty vt100 fn key (erw7)

* unix: don't attempt to invalidate invalid fd (Ben Noordhuis)
2019-02-10 11:44:47 -05:00
Ben Noordhuis
1ce6393a57
unix: don't attempt to invalidate invalid fd
Add a missing check in uv__io_close() where it called
uv__platform_invalidate_fd() without checking that the
watcher actually has a valid file descriptor assigned.

Fixes: https://github.com/libuv/libuv/issues/2181
PR-URL: https://github.com/libuv/libuv/pull/2182
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-10 10:11:19 -05:00
erw7
7ed1eced31
win: fix duplicate tty vt100 fn key
Refs: https://github.com/libuv/libuv/pull/2114
Refs: https://github.com/nodejs/node/issues/25875
Refs: https://github.com/nodejs/node/issues/26013
Fixes: https://github.com/libuv/libuv/issues/2168
PR-URL: https://github.com/libuv/libuv/pull/2160
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-10 10:04:18 -05:00
Anna Henningsen
0eca049a9b
thread: allow specifying stack size for new thread
PR-URL: https://github.com/libuv/libuv/pull/2179
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-02-08 21:15:01 +01:00
cjihrig
3908af563c
win: return product name in uv_os_uname() version
Currently, on Windows the uv_utsname_t's version field can
be an empty string if no service packs are installed. This isn't
very helpful, and a lot more information is available in the
Windows registry. This commit prepends the full product name
to the existing service pack information.

Refs: https://github.com/nodejs/node/issues/25843
Refs: https://github.com/libuv/libuv/pull/2128#issuecomment-452109129
PR-URL: https://github.com/libuv/libuv/pull/2170
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-02-07 15:18:09 -05:00
cjihrig
8865e72e25
src,include: define UV_MAXHOSTNAMESIZE
This commit adds UV_MAXHOSTNAMESIZE for working with
uv_os_gethostname(). Prior to this commit, this logic was
duplicated in several places across libuv and Node.js alone.

PR-URL: https://github.com/libuv/libuv/pull/2175
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-02-05 08:46:28 -05:00
cjihrig
e2baa87b59
win: simplify registry closing in uv_cpu_info()
RegCloseKey() is the first thing executed in both the success
and error case, so combine the calls.

PR-URL: https://github.com/libuv/libuv/pull/2171
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-02-05 08:40:43 -05:00
ptlomholt
110eb817bd
openbsd,tcp: special handling of EINVAL on connect
Map `EINVAL` to `ECONNREFUSED` and return error on the next tick.

Fixes: https://github.com/libuv/libuv/issues/2155
PR-URL: https://github.com/libuv/libuv/pull/2154
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-05 08:50:05 +01:00
yeyuanfeng
f66eda7cba
unix: fix epoll cpu 100% issue
Fixes: https://github.com/libuv/libuv/issues/2162
PR-URL: https://github.com/libuv/libuv/pull/2166
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Li YuBei <leeight@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-05 08:33:26 +01:00
Stephen Belanger
43744c3708
doc: fix uv_get_free_memory doc
There was a formatting error that prevented the uv_get_free_memory
function from appearing on the page.

PR-URL: https://github.com/libuv/libuv/pull/2163
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-02-05 08:30:01 +01:00
cjihrig
a9e6cc7b99
Now working on version 1.25.1
Fixes: https://github.com/libuv/libuv/issues/2134
2019-01-18 13:32:48 -05:00
cjihrig
01dd4b59a8
Add SHA to ChangeLog 2019-01-18 13:27:41 -05:00
cjihrig
4a10a9d425
2019.01.19, Version 1.25.0 (Stable)
Changes since version 1.24.1:

* Revert "win,fs: retry if uv_fs_rename fails" (Ben Noordhuis)

* aix: manually trigger fs event monitoring (Gireesh Punathil)

* unix: rename WRITE_RETRY_ON_ERROR macro (Ben Noordhuis)

* darwin: DRY platform-specific error check (Ben Noordhuis)

* unix: refactor uv__write() (Ben Noordhuis)

* unix: don't send handle twice on partial write (Ben Noordhuis)

* tty,win: fix Alt+key under WSL (Bartosz Sosnowski)

* build: support running tests in out-of-tree builds (Jameson Nash)

* fsevents: really watch files with fsevents on macos 10.7+ (Jameson
  Nash)

* thread,mingw64: need intrin.h header for SSE2 MemoryBarrier (Jameson
  Nash)

* win: fix sizeof-pointer-div warning (cjihrig)

* unix,win: add uv_os_uname() (cjihrig)

* win, tty: fix CreateFileW() return value check (Bartosz Sosnowski)

* unix: enable IPv6 tests on OpenBSD (ptlomholt)

* test: fix test-ipc spawn_helper exit_cb (Santiago Gimeno)

* test: fix test-ipc tests (Santiago Gimeno)

* unix: better handling of unsupported F_FULLFSYNC (Victor Costan)

* win,test: de-flake fs_event_watch_dir_short_path (Refael Ackermann)

* win: fix msvc warning (sid)

* openbsd: switch to libuv's barrier implementation (ptlomholt)

* unix,stream: fix zero byte writes (Santiago Gimeno)

* ibmi: return EISDIR on read from directory fd (Kevin Adler)

* build: wrap long lines in Makefile.am (cjihrig)
2019-01-18 13:27:40 -05:00
cjihrig
a44f41349b
Revert "ibmi: add support for IBM i to cmake build"
This reverts commit 8d62d933ef.
The corresponding autotools update broke the CI. This commit
is reverted for consistency.

Refs: https://github.com/libuv/libuv/pull/2148
PR-URL: https://github.com/libuv/libuv/pull/2156
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-01-18 10:05:13 -05:00
cjihrig
778553569f
Revert "ibmi: add support for IBM i to autotools build"
This reverts commit ca02c36c6d.
This broke SmartOS compilation in the CI.

Refs: https://github.com/libuv/libuv/pull/2148
PR-URL: https://github.com/libuv/libuv/pull/2156
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-01-18 10:04:14 -05:00
cjihrig
636acdda62
build: wrap long lines in Makefile.am
PR-URL: https://github.com/libuv/libuv/pull/2151
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-17 11:37:04 -05:00
Kevin Adler
ca02c36c6d
ibmi: add support for IBM i to autotools build
PR-URL: https://github.com/libuv/libuv/pull/2148
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-17 11:11:08 -05:00
Kevin Adler
8d62d933ef
ibmi: add support for IBM i to cmake build
PR-URL: https://github.com/libuv/libuv/pull/2148
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-17 11:10:38 -05:00
Kevin Adler
91ca6788bb
ibmi: return EISDIR on read from directory fd
On IBM i PASE, EOPNOTSUPP is returned when reading a directory instead
of EISDIR, like (seemingly) every other platform which doesn't support
reading directories. To ensure compatibility with software expecting
EISDIR, we map the EOPNOTSUPP to EISDIR when the fd passed in was a
directory.

This is a partial revert of 25a3894, but scoped to PASE and the fstat
call is moved to the end so it's out of the fast path.

Refs: https://github.com/nodejs/node/issues/25433
Fixes: https://github.com/libuv/libuv/issues/2147
PR-URL: https://github.com/libuv/libuv/pull/2148
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-17 11:08:07 -05:00
Santiago Gimeno
6140507ba7
unix,stream: fix zero byte writes
Fixes a regression where a write request to write a zero byte buffer
would never complete.

Refs: https://github.com/libuv/libuv/pull/2097
Refs: https://github.com/libuv/libuv/issues/2134
PR-URL: https://github.com/libuv/libuv/pull/2149
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-17 10:07:14 +01:00
Poul T Lomholt
176db21733 openbsd: switch to libuv's barrier implementation
On OpenBSD 6.4 x86_64 the barrier_serial_thread test fails due to
OpenBSD's pthread_barrier_wait() implementation returning
PTHREAD_BARRIER_SERIAL_THREAD from the first thread that releases the
wait. Switch to libuv's internal implementation to address the issue.

Fixes: https://github.com/libuv/libuv/issues/2145
PR-URL: https://github.com/libuv/libuv/pull/2144
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-16 22:25:38 +01:00
sid
f84c5e693b
win: fix msvc warning
PR-URL: https://github.com/libuv/libuv/pull/2091
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2019-01-15 10:42:13 -05:00
Refael Ackermann
37da57b695
win,test: de-flake fs_event_watch_dir_short_path
New versions of Windows ship with 8.3 short-names disabled.
This commit adds 8.3 detection logic in the
fs_event_watch_dir_short_path test.

PR-URL: https://github.com/libuv/libuv/pull/2103
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-15 10:25:18 -05:00
Victor Costan
6fc797c3fe
unix: better handling of unsupported F_FULLFSYNC
Apple's released source code at https://opensource.apple.com/ shows at
least three different error codes being returned when a filesystem does
not support F_FULLFSYNC.

fcntl() is implemented in xnu-4903.221.2 in bsd/kern/kern_descrip.c,
where it delegates to fcntl_nocancel(). The documentation for
fcntl_nocancel() mentions error codes for some operations, but does not
include F_FULLFSYNC.  The F_FULLSYNC branch in fcntl_nocancel() calls
VNOP_IOCTL(_, F_FULLSYNC, NULL, 0, _), whose return value sets the error
code.

VNOP_IOCTL() is implemented in bsd/vfs/kpi_vfs.c and calls the ioctl
function in the vnode's operation vector. The filesystem-level function
names follow the pattern _vnop_ioctl() for all the instances in
opensource code -- {hfs,msdosfs,nfs,ntfs,smbfs,webdav,zfs}_vnop_ioctl().

hfs-407.30.1, msdosfs-229.200.3, and nfs in xnu-4903.221.2 handle
F_FULLFSYNC. ntfs-94.200.1 and smb-759.40.1 do not handle F_FULLFSYNC,
and the default branch returns ENOSUP. webdav-380.200.1 also does not
handle F_FULLFSYNC, but the default branch returns EINVAL. zfs-59 also
does not handle F_FULLSYNC, and its default branch returns ENOTTY.

From a different angle, Apple's ntfs-94.200.1 includes utility code that
uses fcntl(F_FULLFSYNC) and falls back to fsync() just like this patch
does, supporting the hypothesis that there is no good way to detect lack
of F_FULLFSYNC support.

PR-URL: https://github.com/libuv/libuv/pull/2135
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Joran Dirk Greef <joran@ronomon.com>
2019-01-15 09:54:47 +01:00
Santiago Gimeno
1698be7205
test: fix test-ipc tests
A couple of ipc tests failures where undercover by the previous commit.

- In `ipc-heavy-traffic-deadlock-bug`, `uv_shutdown` can fail with
  `UV_ENOTCONN`. Allow it.
- `ipc_closed_handle` was failing consistently on `Centos6` because the
  first large write was completed in just one syscall. Also, there were
  issues with the lifetime of the `uv_write_t` requests. Refactor the
  test so it passes consistently on `Centos6` while fixing the
  `uv_write_t` issues.

PR-URL: https://github.com/libuv/libuv/pull/2108
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-15 09:49:33 +01:00
Santiago Gimeno
0c9586a63f
test: fix test-ipc spawn_helper exit_cb
Make sure an ipc test fails if `term_signal` is not zero. This can
happen on failing assertions in the child process.

PR-URL: https://github.com/libuv/libuv/pull/2108
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-15 09:49:02 +01:00
ptlomholt
8570005440
unix: enable IPv6 tests on OpenBSD
Refs: https://github.com/libuv/libuv/pull/1576
PR-URL: https://github.com/libuv/libuv/pull/2136
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-14 11:24:42 -05:00
Bartosz Sosnowski
ec10a78771
win, tty: fix CreateFileW() return value check
CreateFileW() returns INVALID_HANDLE_VALUE on failure, not NULL.

Fixes: https://github.com/libuv/libuv/issues/2141
PR-URL: https://github.com/libuv/libuv/pull/2142
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-14 11:20:22 -05:00
cjihrig
d4288bbeab
unix,win: add uv_os_uname()
Fixes: https://github.com/libuv/libuv/issues/2126
PR-URL: https://github.com/libuv/libuv/pull/2128
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-14 10:47:20 -05:00
cjihrig
d39959c80d
win: fix sizeof-pointer-div warning
short_path's type changed from WCHAR array to WCHAR*
in https://github.com/libuv/libuv/pull/1267, leading
to a sizeof-pointer-div warning.

Fixes: https://github.com/libuv/libuv/issues/2138
PR-URL: https://github.com/libuv/libuv/pull/2139
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-01-11 15:19:30 -05:00
Jameson Nash
ee48e6e4dc thread,mingw64: need intrin.h header for SSE2 MemoryBarrier
Needed for compile with `-msse2` (such as implied by `-march=pentium4`)
for the i686-w64-mingw64 target triple. This seems like a header mistake, but
we can work-around it here by including the header explicitly.

Refs: https://sourceforge.net/p/mingw-w64/bugs/712
PR-URL: https://github.com/libuv/libuv/pull/2083
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-01-04 16:15:06 -05:00
Jameson Nash
2d2af382ce fsevents: really watch files with fsevents on macos 10.7+
In the original PR, the ifdef conditional was reversed,
leading to the old code-path still being used.
This also reduces some of the redundancy in the conditional checks,
by factoring out the common test.
And fixes a divergence in functionality kFSEventsRenamed =>
kFSEventStreamEventFlagItemRenamed
And actually includes the part of the original PR to kqueue that enabled
watching files with fsevents!

Fixes: https://github.com/libuv/libuv/pull/387
PR-URL: https://github.com/libuv/libuv/pull/2082
Refs: https://github.com/libuv/libuv/pull/1572
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-04 13:14:10 -05:00
Jameson Nash
3be96bb723 build: support running tests in out-of-tree builds
PR-URL: https://github.com/libuv/libuv/pull/2099
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-04 12:04:32 -05:00
Bartosz Sosnowski
d2e59bb600 tty,win: fix Alt+key under WSL
When releasing key with Alt pressed, the reported event has
LEFT_ALT_PRESSED state flag set. This confuses libuv, making it think
that Alt+numpad combination is used. This fixes this issue by removing
the check for state flag. Checking if VirtuakKeyCode is set to VK_MENU
is enough to detect the Alt+numpad case.

Fixes: https://github.com/libuv/libuv/issues/2111
PR-URL: https://github.com/libuv/libuv/pull/2114
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-01-03 12:30:57 +01:00
Ben Noordhuis
c560cf931c unix: don't send handle twice on partial write
Guard against sending the handle over the UNIX domain socket twice
when the first sendmsg() didn't write all bytes.

The changes to src/win partially undo changes made earlier this year,
see the referenced pull request for details.

Libuv never made promises about the value of `req->send_handle` at
different points in time so this should be a safe, non-breaking change.

No tests because this particular condition is hard to hit reliably
across platforms. I spent a lot of time trying to write one but it
turned out hideously complex, and worse, flaky.

Fixes: https://github.com/libuv/libuv/issues/2086
PR-URL: https://github.com/libuv/libuv/pull/2097
Refs: https://github.com/libuv/libuv/pull/1843
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-12-30 20:13:48 +01:00
Ben Noordhuis
639cc46f2c unix: refactor uv__write()
Refactor uv__write() to make an upcoming fix easier to implement.

PR-URL: https://github.com/libuv/libuv/pull/2097
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-12-30 20:13:46 +01:00
Ben Noordhuis
a27b9922b7 darwin: DRY platform-specific error check
PR-URL: https://github.com/libuv/libuv/pull/2097
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-12-30 20:13:45 +01:00
Ben Noordhuis
7eca15d17a unix: rename WRITE_RETRY_ON_ERROR macro
PR-URL: https://github.com/libuv/libuv/pull/2097
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-12-30 20:13:21 +01:00
Gireesh Punathil
dce03d58f4 aix: manually trigger fs event monitoring
In AIX, fs watch feature leverages AHAFS function.
According to AHAFS, monitoring of events does not
begin until the monitoring application issues a select()
or a blocking read() call. In edge cases where the watch
request as well as fs event both occurs in single event
loop cycle, we miss the event, as the event monitors are
created but not yet registered in the current cycle,
instead only enqueued into the poll structure, that will
be taken up with the OS on the loop edge only.

Trigger a select call in-line on the monitoring fd, that
tells AHAFS to kick-start the moitoring.

Fixes: https://github.com/libuv/libuv/issues/2118
PR-URL: https://github.com/libuv/libuv/pull/2123
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-12-30 19:30:16 +01:00
Ben Noordhuis
3233ccf169 Revert "win,fs: retry if uv_fs_rename fails"
This reverts commit e94c184c7c.

Concerns were raised about the suitability of this policy and I, for
one, agree with them.

Fixes: https://github.com/libuv/libuv/issues/2098
PR-URL: https://github.com/libuv/libuv/pull/2122
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-12-27 08:19:30 +01:00
cjihrig
3585e135c5
Now working on version 1.24.2
Fixes: https://github.com/libuv/libuv/issues/2109
2018-12-16 14:12:36 -05:00
cjihrig
704887e849
Add SHA to ChangeLog 2018-12-16 14:11:04 -05:00
cjihrig
274f2bd3b7
2018.12.17, Version 1.24.1 (Stable)
Changes since version 1.24.0:

* test: fix platform_output test on cygwin (damon-kwok)

* gitignore: ignore build/ directory (Damon Kwok)

* unix: zero epoll_event before use (Ashe Connor)

* darwin: use runtime check for file cloning (Ben Noordhuis)

* doc: replace deprecated build command on macOS (Rick)

* warnings: fix code that emits compiler warnings (Jameson Nash)

* doc: clarify expected memory management strategy (Ivan Krylov)

* test: add uv_inet_ntop(AF_INET) coverage (Ben Noordhuis)

* unix: harden string copying, introduce strscpy() (Ben Noordhuis)

* linux: get rid of strncpy() call (Ben Noordhuis)

* aix: get rid of strcat() calls (Ben Noordhuis)

* aix: fix data race in uv_fs_event_start() (Ben Noordhuis)

* win: fs: fix `FILE_FLAG_NO_BUFFERING` for writes (Joran Dirk Greef)

* build: don't link against -lpthread on Android (Michael Meier)
2018-12-16 14:11:04 -05:00
Michael Meier
67e771fe53
build: don't link against -lpthread on Android
On Android, pthread is part of the C standard library. Hence, there is
no need to specify -lpthread when building for Android.

PR-URL: https://github.com/libuv/libuv/pull/2110
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-12-14 17:21:04 -05:00
Joran Dirk Greef
7a2c889fa8 win: fs: fix FILE_FLAG_NO_BUFFERING for writes
On Windows, `fs__open()` maps `UV_FS_O_DIRECT` to
`FILE_FLAG_NO_BUFFERING`.

When `access` is only `FILE_GENERIC_READ` this succeeds, but when
`access` is `FILE_GENERIC_WRITE` this returns an error:

```
0x00000057, ERROR_INVALID_PARAMETER, The parameter is incorrect.
```

The reason is that `FILE_GENERIC_WRITE` includes `FILE_APPEND_DATA`,
but `FILE_APPEND_DATA` and `FILE_FLAG_NO_BUFFERING` are mutually
exclusive:

```
FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE |
                     FILE_WRITE_DATA |
                     FILE_WRITE_ATTRIBUTES |
                     FILE_WRITE_EA |
                     FILE_APPEND_DATA |
                     SYNCHRONIZE
```

This incompatibility between access and attribute flags does not appear
to be documented by Microsoft for `FILE_FLAG_NO_BUFFERING` but it is
indirectly documented under [NtCreateFile](https://bit.ly/2rm5wRT):

```
FILE_NO_INTERMEDIATE_BUFFERING
The file cannot be cached or buffered in a driver's internal buffers.
This flag is incompatible with the DesiredAccess FILE_APPEND_DATA flag.
```

The solution is to remove `FILE_APPEND_DATA` from the access flags when
`FILE_FLAG_NO_BUFFERING` is set. Note that this does not prevent
appends, since `FILE_GENERIC_WRITE` also includes `FILE_WRITE_DATA`,
which in turn allows appends.

PR-URL: https://github.com/libuv/libuv/pull/2102
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-12-11 13:42:32 +01:00
Ben Noordhuis
f4feea331a aix: fix data race in uv_fs_event_start()
Don't use a buffer with static lifetime to store intermediate results,
use a stack-allocated one.

PR-URL: https://github.com/libuv/libuv/pull/2065
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-12-04 17:08:27 +01:00
Ben Noordhuis
bc50d106ac aix: get rid of strcat() calls
Insecure and unnecessary. Replace them with a call to snprintf().

PR-URL: https://github.com/libuv/libuv/pull/2065
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-12-04 17:08:25 +01:00
Ben Noordhuis
3909e7f6c6 linux: get rid of strncpy() call
While correctly used, it looks suspect and is slightly less efficient
because the string is scanned twice for its terminating nul byte.

PR-URL: https://github.com/libuv/libuv/pull/2065
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-12-04 17:08:20 +01:00
Ben Noordhuis
8972e65bf5 unix: harden string copying, introduce strscpy()
Replace calls to strcpy() and strncpy() with the newly introduced
uv__strscpy() function that is meticulous about zero-terminating
the destination buffer.

PR-URL: https://github.com/libuv/libuv/pull/2065
Refs: https://www.kernel.org/doc/htmldocs/kernel-api/API-strscpy.html
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-12-04 17:08:09 +01:00
Ben Noordhuis
fe77e34cff test: add uv_inet_ntop(AF_INET) coverage
Libuv had coverage for the AF_INET6 path but not the AF_INET path.
Now it does.

PR-URL: https://github.com/libuv/libuv/pull/2065
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-12-04 17:07:19 +01:00
Ivan Krylov
5b64cc60b9 doc: clarify expected memory management strategy
Right now, docs don't make it clear when exactly does it become okay to
free memory belonging to `uv_handle_t`. It's only stated that
`uv_close` must be called before freeing the memory, which is a source
of confusion for new users: they call `uv_close(handle, NULL)`, then
free the memory (see e.g. #2078, https://stackoverflow.com/q/25615340).

PR-URL: https://github.com/libuv/libuv/pull/2087
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-12-02 15:50:39 +01:00
Jameson Nash
c5593b51dc warnings: fix code that emits compiler warnings
PR-URL: https://github.com/libuv/libuv/pull/2066
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-11-29 11:21:44 -05:00
Rick
f1981d74ba doc: replace deprecated build command on macOS
Origin README about build command is not suited for current code.

1. gyp_uv.py generated uv.xcodeproj file in directory 'out' instead of
   repository root directory

2. xcode build target params use '-alltargets' instead of '-target All'.

PR-URL: https://github.com/libuv/libuv/pull/2095
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-11-27 16:38:10 +01:00
Ben Noordhuis
77c30f24f6 darwin: use runtime check for file cloning
Using #ifdef guards is not reliable because libuv may have been compiled
on a newer system than what it runs on, or vice versa.

Fixes: https://github.com/libuv/libuv/issues/2088
Fixes: https://github.com/nodejs/node/issues/24521
PR-URL: https://github.com/libuv/libuv/pull/2092
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-11-25 23:09:24 +01:00
Ashe Connor
0813f5b97a
unix: zero epoll_event before use
Valgrind will emit the following error on a system where `int` is 32
bits:

==21616== Syscall param epoll_ctl(event) points to uninitialised byte(s)
==21616==    at 0x693E06A: epoll_ctl (syscall-template.S:84)
==21616==    by 0x529F35B: uv__io_poll (in .../libuv/libuv.so)
==21616==    by 0x528AE62: uv_run (in .../libuv/libuv.so)
[...]
==21616==  Address 0x1ffeffc8ec is on thread 1's stack
==21616==  in frame #1, created by uv__io_poll (???:)

We only initialise e.events and e.data.fd, meaning half of
e.data (the 32 bits not covered by the 4-byte `fd`) is
uninitialised.

PR-URL: https://github.com/libuv/libuv/pull/1996
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-11-20 22:01:35 -05:00
Damon Kwok
a24e8a17e5
gitignore: ignore build/ directory
PR-URL: https://github.com/libuv/libuv/pull/2081
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-20 21:17:28 -05:00
damon-kwok
2749d0c30d
test: fix platform_output test on cygwin
Fixes: https://github.com/libuv/libuv/issues/2077
PR-URL: https://github.com/libuv/libuv/pull/2081
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-20 21:16:18 -05:00
cjihrig
32cccbc9f0
Now working on version 1.24.1
Fixes: https://github.com/libuv/libuv/issues/2070
2018-11-12 23:57:04 -05:00
cjihrig
63615c422c
Add SHA to ChangeLog 2018-11-12 23:55:23 -05:00
cjihrig
2d427ee008
2018.11.14, Version 1.24.0 (Stable)
Changes since version 1.23.2:

* unix: do not require PATH_MAX to be defined (Brad King)

* win,doc: path encoding in uv_fs_XX is UTF-8 (hitesh)

* unix: add missing link dependency on kFreeBSD (Svante Signell)

* unix: add support for GNU/Hurd (Samuel Thibault)

* test: avoid memory leak for test_output (Carlo Marcelo Arenas Belón)

* zos: avoid UB with NULL pointer arithmetic (Carlo Marcelo Arenas
  Belón)

* doc: add vtjnash to maintainers (Jameson Nash)

* unix: restore skipping of phys_addr copy (cjihrig)

* unix,win: make uv_interface_addresses() consistent (cjihrig)

* unix: remove unnecessary linebreaks (cjihrig)

* unix,win: handle zero-sized allocations uniformly (Ben Noordhuis)

* unix: remove unused uv__dup() function (Ben Noordhuis)

* core,bsd: refactor process_title functions (Santiago Gimeno)

* win: Redefine NSIG to consider SIGWINCH (Jeremy Studer)

* test: make sure that reading a directory fails (Sakthipriyan
  Vairamani)

* win, tty: remove zero-size read callbacks (Bartosz Sosnowski)

* test: fix test runner getenv async-signal-safety (Ben Noordhuis)

* test: fix test runner execvp async-signal-safety (Ben Noordhuis)

* test,unix: fix race in test runner (Ben Noordhuis)

* unix,win: support IDNA 2008 in uv_getaddrinfo() (Ben Noordhuis)

* win, tcp: avoid starving the loop (Bartosz Sosnowski)

* win, dl: proper error messages on some systems (Bartosz Sosnowski)

* win,fs: retry if uv_fs_rename fails (Bartosz Sosnowski)

* darwin: speed up uv_set_process_title() (Ben Noordhuis)

* aix: fix race in uv_get_process_title() (Gireesh Punathil)

* win: support more fine-grained windows hiding (Bartosz Sosnowski)
2018-11-12 23:55:22 -05:00
Bartosz Sosnowski
4c2dcca27b
win: support more fine-grained windows hiding
Added UV_PROCESS_WINDOWS_HIDE_CONSOLE and
UV_PROCESS_WINDOWS_HIDE_GUI for specifying if console or GUI
subprocess windows are to be hidden.

Refs: https://github.com/nodejs/node/pull/24034
PR-URL: https://github.com/libuv/libuv/pull/2073
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-10 14:43:23 -05:00
Gireesh Punathil
e0bc951ff2
aix: fix race in uv_get_process_title()
The length calculation of the title string was
performed outside of the mutex, causing data corruption
in heavily contended scenarios. Move the length
computation to within the mutex block

Fixes: https://github.com/libuv/libuv/issues/2063
PR-URL: https://github.com/libuv/libuv/pull/2069
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-10 14:36:49 -05:00
Ben Noordhuis
00c6b1649d darwin: speed up uv_set_process_title()
Libuv loaded and unloaded the Core Services and Application Services for
every call to uv_set_process_title().

Change that to load them on the first call to uv_set_process_title() and
delay unloading until libuv is unloaded.

Speeds up process_title_threadsafe by about 10x on my system.

PR-URL: https://github.com/libuv/libuv/pull/2064
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-11-04 18:37:56 +01:00
Bartosz Sosnowski
e94c184c7c win,fs: retry if uv_fs_rename fails
On Windows rename operation can fail randomly in presence of antivirus
or indexing software. Make `uv_fs_rename` retry up to four times with
250ms delay between attempts before giving up.

PR-URL: https://github.com/libuv/libuv/pull/1981
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-01 11:46:00 +01:00
Bartosz Sosnowski
ebb818bbf0 win, dl: proper error messages on some systems
On some localized Windows 10 machines FormatMessage can fail with
ERROR_RESOURCE_TYPE_NOT_FOUND when trying to generate dlopen error
message. This adds support for this corner case.

PR-URL: https://github.com/libuv/libuv/pull/2052
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-01 11:40:32 +01:00
Bartosz Sosnowski
8a647d436f win, tcp: avoid starving the loop
Limit the time a TCP read callback can be called on a single loop
iteration to 32.

Ref: 738b31eb3a
Fixes: https://github.com/libuv/libuv/issues/2027
PR-URL: https://github.com/libuv/libuv/pull/2049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-01 11:10:03 +01:00
Ben Noordhuis
6dd44caa35 unix,win: support IDNA 2008 in uv_getaddrinfo()
Encode domain names before passing them on to the libc resolver.
Some getaddrinfo() implementations support IDNA 2008, some only
IDNA 2003 and some don't support i18n domain names at all.

This is a potential security issue because it means a domain name
might resolve differently depending on the system that libuv is
running on.

Fixes: https://github.com/libuv/libuv/issues/2028
PR-URL: https://github.com/libuv/libuv/pull/2046
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-30 20:50:23 +01:00
Ben Noordhuis
143da93e2d test,unix: fix race in test runner
The test runner inserted a 250 ms delay to give helper processes time to
settle. That's intrinsically race-y and caused tests to intermittently
fail on platforms like AIX.

Instead of a fixed delay, pass a file descriptor to the helper process
and wait until it closes the descriptor. That way we know for sure the
process has started.

Incidentally, this change reduces the running time of the test suite
from 112 to 26 seconds on my machine.

Fixes: https://github.com/libuv/libuv/issues/2041
PR-URL: https://github.com/libuv/libuv/pull/2056
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-30 20:44:16 +01:00
Ben Noordhuis
7da435aeb7 test: fix test runner execvp async-signal-safety
execvp() is not async-signal-safe, execve() is.

PR-URL: https://github.com/libuv/libuv/pull/2056
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-30 20:44:06 +01:00
Ben Noordhuis
c3cbab991b test: fix test runner getenv async-signal-safety
getenv() and atoi() are not safe to call between fork() and execve()
so call them before forking.

PR-URL: https://github.com/libuv/libuv/pull/2056
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-30 20:43:25 +01:00
Bartosz Sosnowski
b901e2620c win, tty: remove zero-size read callbacks
In some situations console read callback would return 0 bytes read.
According to documentation this means EAGAIN or EWOULDBLOCK, which is
not the case in any of the situations that currently happen.

This removes those zero-size callbacks.

Fixes: https://github.com/libuv/libuv/issues/2012
PR-URL: https://github.com/libuv/libuv/pull/2014
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-10-23 16:18:34 +02:00
Sakthipriyan Vairamani (thefourtheye)
1dfa88f35b
test: make sure that reading a directory fails
Fixes: https://github.com/libuv/libuv/issues/2026
PR-URL: https://github.com/libuv/libuv/pull/2029
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-18 10:17:44 +02:00
Jeremy Studer
20f2351886
win: Redefine NSIG to consider SIGWINCH
Since SIGWINCH is being defined with a value above the existing NSIG,
redefine NSIG on WIN32.

PR-URL: https://github.com/libuv/libuv/pull/2032
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-10-18 10:15:26 +02:00
Santiago Gimeno
d0b15844dd
core,bsd: refactor process_title functions
Use `setproctitle()` in `FreeBSD` as in the other `BSD` flavours.
Move `uv_setup_args()`, `uv_set_process_title()` and `uv_get_process_title()` to
`bsd-proctitle.c` so it's used by the supported BSDs.

PR-URL: https://github.com/libuv/libuv/pull/2042
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-10-18 10:11:40 +02:00
Ben Noordhuis
fab6e64b39 unix: remove unused uv__dup() function
It was introduced in commit abdc3efffe ("unix: add uv__dup()") from
January 2012 to break ground for commit e34dc13496 ("unix: implement
uv_import() and uv_export()").

Those APIs were removed not much later but I forgot to remove the
helper function as well. Better late than never, eh?

PR-URL: https://github.com/libuv/libuv/pull/2043
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-17 20:26:03 +02:00
Ben Noordhuis
ba7802315d unix,win: handle zero-sized allocations uniformly
`malloc(0)` and `realloc(p, 0)` can either return NULL or a unique
pointer. Make our custom allocator return NULL for consistency across
platforms and libcs.

PR-URL: https://github.com/libuv/libuv/pull/2038
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-17 00:14:50 +02:00
cjihrig
6e23a36603
unix: remove unnecessary linebreaks
As a requested style nit, remove two unnecessary line breaks.

PR-URL: https://github.com/libuv/libuv/pull/2039
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-10-15 14:51:11 -04:00
cjihrig
5fb9517200
unix,win: make uv_interface_addresses() consistent
This commit does a few things to make the function more
consistent across platforms:

- Initialize the output parameters before everything else.
- Return early if there are no interfaces instead of performing
  zero-sized allocations.
- Add a missing memory deallocation.

Refs: https://github.com/libuv/libuv/pull/2035
PR-URL: https://github.com/libuv/libuv/pull/2039
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-10-15 14:49:13 -04:00
cjihrig
69e4af1577
unix: restore skipping of phys_addr copy
Prior to https://github.com/libuv/libuv/pull/1999,
uv_interface_addresses() did not populate the phys_addr field on
Cygwin or MinGW. This commit restores that behavior, which was
mistakenly changed.

Fixes: https://github.com/libuv/libuv/issues/2034
PR-URL: https://github.com/libuv/libuv/pull/2035
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-15 14:33:34 -04:00
Jameson Nash
4b7f368627 doc: add vtjnash to maintainers
PR-URL: https://github.com/libuv/libuv/pull/2015
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-10-15 13:10:29 -04:00
Carlo Marcelo Arenas Belón
1cead826cb
zos: avoid UB with NULL pointer arithmetic
PR-URL: https://github.com/libuv/libuv/pull/2017
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: John Barboza <jbarboza@ca.ibm.com>
2018-10-11 12:21:09 +02:00
Carlo Marcelo Arenas Belón
dc2476cd69
test: avoid memory leak for test_output
PR-URL: https://github.com/libuv/libuv/pull/2017
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: John Barboza <jbarboza@ca.ibm.com>
2018-10-11 12:21:04 +02:00
Samuel Thibault
1d1969adcc
unix: add support for GNU/Hurd
PR-URL: https://github.com/libuv/libuv/pull/2008
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

Bug-Debian: https://bugs.debian.org/881882
2018-10-11 12:14:36 +02:00
Svante Signell
c5d2bf12f7
unix: add missing link dependency on kFreeBSD
Link to `freebsd-glue` to get `bsd_sendfile`.

PR-URL: https://github.com/libuv/libuv/pull/2008
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

Bug-Debian: https://bugs.debian.org/904503
2018-10-11 12:14:17 +02:00
hitesh
4772d44087
win,doc: path encoding in uv_fs_XX is UTF-8
Fixes: https://github.com/libuv/libuv/issues/1554
PR-URL: https://github.com/libuv/libuv/pull/1943
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-10-11 12:11:55 +02:00
Brad King
b56d279b17 unix: do not require PATH_MAX to be defined
Some platforms (e.g. GNU/Hurd) do not define PATH_MAX.  Add a few other
variants and a fallback constant.  Also use alternatives where possible:

* For readlink(), use lstat() to read the length of the link first.
  If it is not a symlink, report EINVAL before trying to allocate.
  If the size reports as zero, fall back one of the PATH_MAX variants.

* For realpath(), POSIX 2008 allows us to pass a NULL buffer
  to tell it to malloc() internally.

This patch was inspired by downstream patches in Debian packaging.

PR-URL: https://github.com/libuv/libuv/pull/2008
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>

Bug-Debian: https://bugs.debian.org/897061
Bug-Debian: https://bugs.debian.org/909011
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1792647
Inspired-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Inspired-by: Samuel Thibault <sthibault@debian.org>
2018-10-09 20:58:06 +02:00
cjihrig
0c2b3de331
Now working on version 1.23.3
Fixes: https://github.com/libuv/libuv/issues/2024
2018-10-08 12:53:48 -04:00
cjihrig
0d8ec6e95a
Add SHA to ChangeLog 2018-10-08 12:52:31 -04:00
cjihrig
34c12788d2
2018.10.09, Version 1.23.2 (Stable)
Changes since version 1.23.1:

* unix: return 0 retrieving rss on cygwin (cjihrig)

* unix: initialize uv_interface_address_t.phys_addr (cjihrig)

* test: handle uv_os_setpriority() windows edge case (cjihrig)

* tty, win: fix read stop for raw mode (Bartosz Sosnowski)

* Revert "Revert "unix,fs: fix for potential partial reads/writes""
  (Jameson Nash)

* unix,readv: always permit partial reads to return (Jameson Nash)

* win,tty: fix uv_tty_close() (Bartosz Sosnowski)

* doc: remove extraneous "on" (Ben Noordhuis)

* unix,win: fix threadpool race condition (Anna Henningsen)

* unix: rework thread barrier implementation (Ben Noordhuis)

* aix: switch to libuv's own thread barrier impl (Ben Noordhuis)

* unix: signal done to last thread barrier waiter (Ben Noordhuis)

* test: add uv_barrier_wait serial thread test (Ali Ijaz Sheikh)

* unix: optimize uv_fs_readlink() memory allocation (Ben Noordhuis)

* win: remove req.c and other cleanup (Carlo Marcelo Arenas Belón)

* aix: don't EISDIR on read from directory fd (Ben Noordhuis)
2018-10-08 12:52:30 -04:00
Ben Noordhuis
25a3894c8d
aix: don't EISDIR on read from directory fd
Remove the artificial EISDIR that was generated when trying to
uv_fs_read() from a file descriptor that refers to a directory.

We don't do that on the BSDs either (where reading from a directory
is allowed) and it introduces an extra stat() call for every read.

Refs: https://github.com/libuv/libuv/pull/2023#issuecomment-427759265
PR-URL: https://github.com/libuv/libuv/pull/2025
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-10-08 11:11:50 -04:00
Carlo Marcelo Arenas Belón
672b96fab4
win: remove req.c and other cleanup
PR-URL: https://github.com/libuv/libuv/pull/2018
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-10-08 11:06:15 -04:00
Ben Noordhuis
5ecc97ee7d unix: optimize uv_fs_readlink() memory allocation
Libuv was allocating PATH_MAX+1 bytes to reserve space for the trailing
nul byte.

On platforms like Linux, where PATH_MAX is fixed at 4096, that meant we
were allocating two pages (as the page size is normally also 4096), even
though the second page was almost never used.

Change that to allocate PATH_MAX bytes and only resize when readlink()
actually writes that many bytes, which is practically never.

PR-URL: https://github.com/libuv/libuv/pull/2009
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-08 11:51:27 +02:00
Ali Ijaz Sheikh
3af6f17241 test: add uv_barrier_wait serial thread test
Ensure that uv_barrier_wait returns positive only after all threads have
exited the barrier. If this value is returned too early and the barrier
is destroyed prematurely, then this test may see a crash.

PR-URL: https://github.com/libuv/libuv/pull/2019
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-08 11:14:41 +02:00
Ben Noordhuis
49b8a9f181 unix: signal done to last thread barrier waiter
Libuv's own thread barrier implementation signaled completion to the
first waiter that saw the threshold being reached, contrary to what
some native pthreads barrier implementations do, which is to signal
it to the _last_ waiter.

Libuv's behavior is not strictly non-conforming but it's inconvenient
because it means this snippet (that appears in the libuv documentation)
has a race condition in it:

    if (uv_barrier_wait(&barrier) > 0)
      uv_barrier_destroy(&barrier);  // can still have waiters

This issue was discovered and fixed by Ali Ijaz Sheikh, a.k.a @ofrobots,
but some refactoring introduced conflicts in his pull request and I
didn't have the heart to ask him to redo it from scratch. :-)

PR-URL: https://github.com/libuv/libuv/pull/2019
Refs: https://github.com/libuv/libuv/pull/2003
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-08 11:14:41 +02:00
Ben Noordhuis
a3a601c5da aix: switch to libuv's own thread barrier impl
It was pointed out that pthread_barrier_wait() behaves slightly
different from other platforms. Switch to libuv's own thread barrier
for uniformity of behavior. Perhaps we'll do that for more platforms
in the future.

PR-URL: https://github.com/libuv/libuv/pull/2019
Refs: https://github.com/libuv/libuv/pull/2003#issuecomment-426471646
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-08 11:14:41 +02:00
Ben Noordhuis
56702e08bf unix: rework thread barrier implementation
* dissolve include/uv/pthread-barrier.h

* use libuv mutexes and condition variables, not pthreads's

* drive-by cleanup and simplification enabled by the first two items

PR-URL: https://github.com/libuv/libuv/pull/2019
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-08 11:14:41 +02:00
Anna Henningsen
daf04e83cb
unix,win: fix threadpool race condition
90891b4232 introduced a race
condition when accessing `slow_io_work_running` – it is being
increased and later decreased as part of the worker thread loop,
but was accessed with different mutexes during these operations.

This fixes the race condition by making sure both accesses
are protected through the global `mutex` of `threadpool.c`.

This fixes a number of flaky Node.js tests.

Refs: https://github.com/libuv/libuv/pull/1845
Refs: https://github.com/nodejs/reliability/issues/18
Refs: https://github.com/nodejs/node/issues/23089
Refs: https://github.com/nodejs/node/issues/23067
Refs: https://github.com/nodejs/node/issues/23066
Refs: https://github.com/nodejs/node/issues/23219
PR-URL: https://github.com/libuv/libuv/pull/2021
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-10-07 15:50:57 -07:00
Ben Noordhuis
6781db5c78 doc: remove extraneous "on"
Fixes: https://github.com/libuv/libuv/issues/2000
PR-URL: https://github.com/libuv/libuv/pull/2010
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jamie Davis <davisjam@vt.edu>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-02 12:58:39 +02:00
Bartosz Sosnowski
ee87f34474
win,tty: fix uv_tty_close()
Under some condition, uv_tty_close() would not stop console reads.
This fixes that issue by first stopping read, then closing the
handle.

Fixes: https://github.com/nodejs/node/issues/22999
PR-URL: https://github.com/libuv/libuv/pull/2005
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-09-30 13:02:11 -04:00
Jameson Nash
60abdbaed6 unix,readv: always permit partial reads to return
For simplicity and predictability (since the user must handle the retry
anyways), always emit exactly one readv/pread/preadv syscall and return
that result to the user.

By contrast, write needs to preserve order, so it needs to keep retrying
the operation until it finishes before retiring the req from the queue.

Fixes: https://github.com/nodejs/node/issues/16601
PR-URL: https://github.com/libuv/libuv/pull/1742
Refs: https://github.com/libuv/libuv/pull/640
Refs: https://github.com/libuv/libuv/issues/1720
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-28 21:47:07 +02:00
Jameson Nash
19a3419195 Revert "Revert "unix,fs: fix for potential partial reads/writes""
This reverts commit b0f3310bb1.
(but not the test deletion)

Fixes: https://github.com/nodejs/node/issues/16601
PR-URL: https://github.com/libuv/libuv/pull/1742
Refs: https://github.com/libuv/libuv/pull/640
Refs: https://github.com/libuv/libuv/issues/1720
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-28 21:46:47 +02:00
Bartosz Sosnowski
b9a0840307
tty, win: fix read stop for raw mode
New Windows version requires `EventType` to be set to something
meaningful, otherwise WriteConsoleInputW() will fail with
`ERROR_INVALID_PARAMETER`. This sets it to `FOCUS_EVENT` which
is ignored by `uv_process_tty_read_raw_req()`.

Fixes: https://github.com/nodejs/node/issues/21773
PR-URL: https://github.com/libuv/libuv/pull/1989
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2018-09-26 13:46:25 -04:00
cjihrig
4bd01873eb
test: handle uv_os_setpriority() windows edge case
Refs: https://github.com/nodejs/node/pull/22817
Refs: https://github.com/libuv/help/issues/64
PR-URL: https://github.com/libuv/libuv/pull/2002
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2018-09-25 20:56:37 -04:00
cjihrig
3dc0f53965
unix: initialize uv_interface_address_t.phys_addr
This commit ensures that the memory of the phys_addr field is
initialized on all platforms.

Fixes: https://github.com/nodejs/node/issues/23043
PR-URL: https://github.com/libuv/libuv/pull/1999
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-09-25 09:40:22 -04:00
cjihrig
95b5df7ae9
unix: return 0 retrieving rss on cygwin
Refs: https://github.com/libuv/libuv/pull/1939
PR-URL: https://github.com/libuv/libuv/pull/1992
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-21 10:51:38 -04:00
cjihrig
deb2226909
Now working on version 1.23.2
Fixes: https://github.com/libuv/libuv/issues/1993
2018-09-21 10:10:01 -04:00
cjihrig
56b028bb79
Add SHA to ChangeLog 2018-09-21 10:08:30 -04:00
cjihrig
d2282b3d67
2018.09.22, Version 1.23.1 (Stable)
Changes since version 1.23.0:

* unix,win: limit concurrent DNS calls to nthreads/2 (Anna Henningsen)

* doc: add addaleax to maintainers (Anna Henningsen)

* doc: add missing slash in stream.rst (Emil Bay)

* unix,fs: use utimes & friends for uv_fs_utime (Jeremiah Senkpiel)

* unix,fs: remove linux fallback from utimesat() (Jeremiah Senkpiel)

* unix,fs: remove uv__utimesat() syscall fallback (Jeremiah Senkpiel)

* doc: fix argument name in tcp.rts (Emil Bay)

* doc: notes on running tests, benchmarks, tools (Jamie Davis)

* linux: remove epoll syscall wrappers (Ben Noordhuis)

* linux: drop code path for epoll_pwait-less kernels (Ben Noordhuis)

* Partially revert "win,code: remove GetQueuedCompletionStatus-based
  poller" (Jameson Nash)

* build: add compile for android arm64/x86/x86-64 (Andy Zhang)

* doc: clarify that some remarks apply to windows (Bert Belder)

* test: fix compiler warnings (Jamie Davis)

* ibmi: return 0 from uv_resident_set_memory() (dmabupt)

* win: fix uv_udp_recv_start() error translation (Ryan Liptak)

* win,doc: improve uv_os_setpriority() documentation (Bartosz Sosnowski)

* test: increase upper bound in condvar_5 (Jamie Davis)

* win,tty: remove deadcode (Jameson Nash)

* stream: autodetect direction (Jameson Nash)
2018-09-21 10:08:29 -04:00
Jameson Nash
40498795ab stream: autodetect direction
Previously, we required the user to specify the expected read/write
flags for a pipe or tty. But we've already been asking the OS to tell us
what they actually are (fcntl F_GETFL), so we can hopefully just use
that information directly.

Fixes: https://github.com/libuv/libuv/issues/1936
PR-URL: https://github.com/libuv/libuv/pull/1964
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-19 18:19:28 +02:00
Jameson Nash
956bf6b71a win,tty: remove deadcode
Not used anywhere or exported. Most of this code also cares which
direction handle is open too (Input or Output), so it's not particularly
useful.

PR-URL: https://github.com/libuv/libuv/pull/1964
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-19 18:19:28 +02:00
Jamie Davis
bb1a49e9f2
test: increase upper bound in condvar_5
Problem:
Upper bound on thread wakeup was set to 1.5 * (requested timeout).
On MacOS wakeup delay factors of 1.75 have been reported.

Solution:
Increase the bound to 5 * (requested timeout).

Refs: https://github.com/libuv/libuv/issues/1910
PR-URL: https://github.com/libuv/libuv/pull/1990
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-19 09:27:24 -04:00
Bartosz Sosnowski
b721891ad4
win,doc: improve uv_os_setpriority() documentation
Refs: https://github.com/nodejs/node/pull/22817
PR-URL: https://github.com/libuv/libuv/pull/1985
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-18 12:13:01 -04:00
Ryan Liptak
57b3363e23
win: fix uv_udp_recv_start() error translation
PR-URL: https://github.com/libuv/libuv/pull/1979
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-09-18 12:02:40 -04:00
dmabupt
8813dca388
ibmi: return 0 from uv_resident_set_memory()
PR-URL: https://github.com/libuv/libuv/pull/1939
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-09-18 11:54:27 -04:00
Jamie Davis
abe9e01cfb
test: fix compiler warnings
Problem:
libuv is compiled with -Wunused-result.
In two tests, read() is used for ordering and the
rc is ignored because it doesn't matter.
But -Wunused-result causes warnings in these cases.

Fix:
Provide a (very generous) check on the rc of read()
in these cases.

PR-URL: https://github.com/libuv/libuv/pull/1956
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-09-18 11:49:58 -04:00
Bert Belder
baa621c85e
doc: clarify that some remarks apply to windows
PR-URL: https://github.com/libuv/libuv/pull/1988
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-09-18 10:05:06 -04:00
Andy Zhang
baa81465ad build: add compile for android arm64/x86/x86-64
Add compile options for Android arm64/x86/x86-64 and update the
instructions in README.md.

PR-URL: https://github.com/libuv/libuv/pull/1934
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-09-17 12:47:13 +02:00
Jameson Nash
153ea114ff
Partially revert "win,code: remove GetQueuedCompletionStatus-based poller"
This reverts commit fd8d212a80,
and thereby restores partial support for using libuv under Wine
(which does not implement GetQueuedCompletionStatusEx).

PR-URL: https://github.com/libuv/libuv/pull/1963
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2018-09-10 07:59:00 +02:00
Ben Noordhuis
f43c663433 linux: drop code path for epoll_pwait-less kernels
Remove the support for kernels that don't support epoll_pwait()
now that the minimum requirements are kernel 2.6.32 + glibc 2.12.

PR-URL: https://github.com/libuv/libuv/pull/1372
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-06 13:07:42 +02:00
Ben Noordhuis
9208df0c93 linux: remove epoll syscall wrappers
Remove the syscalls wrappers now that the minimum requirements are
kernel 2.6.32 + glibc 2.12.

This commit should fix the epoll_pwait()-related issues that have
been reported against mips/mipsel builds.

Fixes: https://github.com/libuv/libuv/issues/335
PR-URL: https://github.com/libuv/libuv/pull/1372
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-06 13:07:13 +02:00
Jamie Davis
c0c672e1a0
doc: notes on running tests, benchmarks, tools
PR-URL: https://github.com/libuv/libuv/pull/1971
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-03 14:55:10 +02:00
Emil Bay
89a9ea672b
doc: fix argument name in tcp.rts
PR-URL: https://github.com/libuv/libuv/pull/1974
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-03 14:46:35 +02:00
Jeremiah Senkpiel
fa5c1d9296
unix,fs: remove uv__utimesat() syscall fallback
This is now unnecessary as of the previous commit.

PR-URL: https://github.com/libuv/libuv/pull/1940
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-09-03 14:34:07 +02:00
Jeremiah Senkpiel
a519c8b206
unix,fs: remove linux fallback from utimesat()
Previously both uv_fs_utimes and uv_fs_futimes would fall back to utimes() if untimesat() wasn't supported.

Since utimesat() has been supported since linux kernel 2.6.22, and libuv supports at minimum 2.6.32, this code can be removed.

PR-URL: https://github.com/libuv/libuv/pull/1940
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-09-03 14:33:56 +02:00
Jeremiah Senkpiel
3646624e5e
unix,fs: use utimes & friends for uv_fs_utime
This should improve uv_fs_utime resolution and reliability, as
utime(2)'s precision is left more to the implementing platform than the
newer but well supported alternatives.

Related to https://github.com/nodejs/node/issues/22070
PR-URL: https://github.com/libuv/libuv/pull/1940
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-09-03 14:33:51 +02:00
Emil Bay
ff45b0d789
doc: add missing slash in stream.rst
PR-URL: https://github.com/libuv/libuv/pull/1973
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-09-01 13:01:10 +02:00
Anna Henningsen
1391a3d9d0
doc: add addaleax to maintainers
PR-URL: https://github.com/libuv/libuv/pull/1961
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-08-28 21:08:49 +02:00
Anna Henningsen
90891b4232
unix,win: limit concurrent DNS calls to nthreads/2
If `nthreads / 2` (rounded up) DNS calls are outstanding,
queue more work of that kind instead of letting it take over
more positions in the thread pool, blocking other work
such as the (usually much faster) file system I/O or
user-scheduled work.

Fixes: https://github.com/nodejs/node/issues/8436
PR-URL: https://github.com/libuv/libuv/pull/1845
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-08-21 10:48:24 +02:00
cjihrig
69c43d987b
Now working on version 1.23.1
Fixes: https://github.com/libuv/libuv/issues/1942
2018-08-16 22:07:33 -04:00
cjihrig
489ce32a7b
Add SHA to ChangeLog 2018-08-16 22:05:35 -04:00
432 changed files with 46608 additions and 21288 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
test/fixtures/lorem_ipsum.txt text eol=lf

View File

@ -2,7 +2,10 @@
If you want to report a bug, you are in the right place!
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
running the test as root.
Please include code that demonstrates the bug and keep it short and simple.
-->

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"

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

13
.gitignore vendored
View File

@ -7,9 +7,11 @@
*.sdf
*.suo
.vs/
.vscode/
*.VC.db
*.VC.opendb
core
.cache
vgcore.*
.buildstamp
.dirstamp
@ -37,12 +39,7 @@ vgcore.*
Makefile
Makefile.in
# Generated by gyp for android
*.target.mk
/android-toolchain
/out/
/build/gyp
/build/
/test/.libs/
/test/run-tests
@ -51,6 +48,7 @@ Makefile.in
/test/run-benchmarks
/test/run-benchmarks.exe
/test/run-benchmarks.dSYM
test_file_*
*.sln
*.sln.cache
@ -71,9 +69,12 @@ ipch
# Clion / IntelliJ project files
/.idea/
cmake-build-debug/
*.xcodeproj
*.xcworkspace
# make dist output
libuv-*.tar.*
/dist.libuv.org/
/libuv-release-tool/

View File

@ -1,7 +1,10 @@
A. Hauptmann <andreashauptmann@t-online.de>
AJ Heller <aj@drfloob.com> <hork@google.com>
Aaron Bieber <qbit@deftly.net> <deftly@gmail.com>
Alan Gutierrez <alan@prettyrobots.com> <alan@blogometer.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> <info@2bs.nl>
Bert Belder <bertbelder@gmail.com> <user@ChrUbuntu.(none)>
@ -10,26 +13,36 @@ Brian White <mscdex@mscdex.net>
Brian White <mscdex@mscdex.net> <mscdex@gmail.com>
Caleb James DeLisle <cjd@hyperboria.ca> <cjd@cjdns.fr>
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>
Fedor Indutny <fedor.indutny@gmail.com> <fedor@indutny.com>
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>
Isaac Z. Schlueter <i@izs.me>
Jason Williams <necmon@yahoo.com>
Jesse Gorzinski <jgorzinski@gmail.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>
Keno Fischer <kenof@stanford.edu> <kfischer+github@college.harvard.edu>
Keno Fischer <kenof@stanford.edu> <kfischer@college.harvard.edu>
Leith Bade <leith@leithalweapon.geek.nz> <leith@mapbox.com>
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>
Marc Schlaich <marc.schlaich@googlemail.com> <marc.schlaich@gmail.com>
Michael <michael_dawson@ca.ibm.com>
Michael Neumann <mneumann@think.localnet> <mneumann@ntecs.de>
Michael Penick <michael.penick@datastax.com> <mpenick@users.noreply.github.com>
Nicholas Vavilov <vvnicholas@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> <ruysch@outlook.com>
Richard Lau <rlau@redhat.com> <riclau@uk.ibm.com>
Robert Mustacchi <rm@joyent.com> <rm@fingolfin.org>
Ryan Dahl <ryan@joyent.com> <ry@tinyclouds.org>
Ryan Emery <seebees@gmail.com>
@ -37,11 +50,22 @@ Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Sam Roberts <vieuxtech@gmail.com> <sam@strongloop.com>
San-Tai Hsu <vanilla@fatpipi.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>
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>
Yasuhiro Matsumoto <mattn.jp@gmail.com>
Yazhong Liu <yorkiefixer@gmail.com>
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> <jbarz@users.noreply.github.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>

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

252
AUTHORS
View File

@ -114,7 +114,6 @@ Dylan Cali <calid1984@gmail.com>
Austin Foxley <austinf@cetoncorp.com>
Benjamin Saunders <ben.e.saunders@gmail.com>
Geoffry Song <goffrie@gmail.com>
Rasmus Christian Pedersen <ruysch@outlook.com>
William Light <wrl@illest.net>
Oleg Efimov <o.efimov@corp.badoo.com>
Lars Gierth <larsg@systemli.org>
@ -123,7 +122,6 @@ Justin Venus <justin.venus@gmail.com>
Kristian Evensen <kristian.evensen@gmail.com>
Linus Mårtensson <linus.martensson@sonymobile.com>
Navaneeth Kedaram Nambiathan <navaneethkn@gmail.com>
Yorkie <yorkiefixer@gmail.com>
StarWing <weasley.wx@gmail.com>
thierry-FreeBSD <thierry@FreeBSD.org>
Isaiah Norton <isaiah.norton@gmail.com>
@ -212,7 +210,7 @@ guworks <ground.up.works@gmail.com>
RossBencina <rossb@audiomulch.com>
Roger A. Light <roger@atchoo.org>
chenttuuvv <chenttuuvv@yahoo.com>
Richard Lau <riclau@uk.ibm.com>
Richard Lau <rlau@redhat.com>
ronkorving <rkorving@wizcorp.jp>
Corbin Simpson <MostAwesomeDude@gmail.com>
Zachary Hamm <zsh@imipolexg.org>
@ -346,3 +344,251 @@ Paolo Greppi <paolo.greppi@libpf.com>
Shelley Vohr <shelley.vohr@gmail.com>
Ujjwal Sharma <usharma1998@gmail.com>
Michał Kozakiewicz <michalkozakiewicz3@gmail.com>
Emil Bay <github@tixz.dk>
Jeremiah Senkpiel <fishrock123@rocketmail.com>
Andy Zhang <zhangyong232@gmail.com>
dmabupt <dmabupt@gmail.com>
Ryan Liptak <squeek502@hotmail.com>
Ali Ijaz Sheikh <ofrobots@google.com>
hitesh <sainihitesh.scientist@gmail.com>
Svante Signell <svante.signell@gmail.com>
Samuel Thibault <sthibault@debian.org>
Jeremy Studer <studerj1.mail@gmail.com>
damon-kwok <563066990@qq.com>
Damon Kwok <MedusaIDE@outlook.com>
Ashe Connor <ashe@kivikakk.ee>
Rick <lcw0622@163.com>
Ivan Krylov <krylov.r00t@gmail.com>
Michael Meier <michael.meier@leica-geosystems.com>
ptlomholt <pt@lomholt.com>
Victor Costan <pwnall@chromium.org>
sid <sidyhe@hotmail.com>
Kevin Adler <kadler@us.ibm.com>
Stephen Belanger <admin@stephenbelanger.com>
yeyuanfeng <yeyuanfeng@bytedance.com>
erw7 <erw7.github@gmail.com>
Thomas Karl Pietrowski <thopiekar@gmail.com>
evgley <evgley@gmail.com>
Andreas Rohner <andreas.rohner@gmx.net>
Rich Trott <rtrott@gmail.com>
Milad Farazmand <miladfar@ca.ibm.com>
zlargon <zlargon1988@gmail.com>
Yury Selivanov <yury@magic.io>
Oscar Waddell <owaddell@beckman.com>
FX Coudert <fxcoudert@gmail.com>
George Zhao <zhaozg@gmail.com>
Kyle Edwards <kyle.edwards@kitware.com>
ken-cunningham-webuse <ken.cunningham.webuse@gmail.com>
Kelvin Jin <kelvinjin@google.com>
Leorize <leorize+oss@disroot.org>
Vlad A <vladmore@gmail.com>
Niels Lohmann <mail@nlohmann.me>
Jenil Christo <jenilchristo5@gmail.com>
Evgeny Ermakov <evgeny.v.ermakov@gmail.com>
gengjiawen <technicalcute@gmail.com>
Leo Chung <gewalalb@gmail.com>
Javier Blazquez <jblazquez@riotgames.com>
Mustafa M <mus-m@outlook.com>
Zach Bjornson <zbbjornson@gmail.com>
Nan Xiao <nan@chinadtrace.org>
Ben Davies <kaiepi@outlook.com>
Nhan Khong <knhana7@gmail.com>
Crunkle <justcrunkle@hotmail.co.uk>
Tomas Krizek <tomas.krizek@nic.cz>
Konstantin Podsvirov <konstantin@podsvirov.pro>
seny <arseny.vakhrushev@gmail.com>
Vladimir Karnushin <v.karnushin@mail.ru>
MaYuming <maym@appexnetworks.com>
Eneas U de Queiroz <cotequeiroz@gmail.com>
Daniel Hahler <git@thequod.de>
Yang Yu <yang.yu@disigma.org>
David Carlier <devnexen@gmail.com>
Calvin Hill <calvin@hakobaito.co.uk>
Isabella Muerte <63051+slurps-mad-rips@users.noreply.github.com>
Ouyang Yadong <oyydoibh@gmail.com>
ZYSzys <zyszys98@gmail.com>
Carl Lei <xecycle@gmail.com>
Stefan Bender <stefan.bender@ntnu.no>
nia <nia@NetBSD.org>
virtualyw <virtualyw@gmail.com>
Witold Kręcicki <wpk@isc.org>
Dominique Dumont <dod@debian.org>
Manuel BACHMANN <tarnyko@tarnyko.net>
Marek Vavrusa <marek@vavrusa.com>
TK-one <tk5641@naver.com>
Irek Fakhrutdinov <ifakhrutdinov@rocketsoftware.com>
Lin Zhang <linroid@gmail.com>
毛毛 <srayuws@users.noreply.github.com>
Sk Sajidul Kadir <sheikh.sajid522@gmail.com>
twosee <twose@qq.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>

File diff suppressed because it is too large Load Diff

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.
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
frustrating than seeing your hard work go to waste because your vision
does not align with that of a project maintainers.
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 does not
align with that of the [project maintainers].
### BRANCH
@ -48,11 +48,11 @@ the [Google C/C++ style guide]. Some of the key points, as well as some
additional guidelines, are enumerated below.
* Code that is specific to unix-y platforms should be placed in `src/unix`, and
declarations go into `include/uv-unix.h`.
declarations go into `include/uv/unix.h`.
* Source code that is Windows-specific goes into `src/win`, and related
publicly exported types, functions and macro declarations should generally
be declared in `include/uv-win.h`.
be declared in `include/uv/win.h`.
* Names should be descriptive and concise.
@ -142,7 +142,6 @@ Bug fixes and features should come with tests. Add your tests in the
If you add a new test file, it needs to be registered in three places:
- `CMakeLists.txt`: add the file's name to the `uv_test_sources` list.
- `Makefile.am`: add the file's name to the `test_run_tests_SOURCES` list.
- `uv.gyp`: add the file's name to the `sources` list in the `run-tests` target.
Look at other tests to see how they should be structured (license boilerplate,
the way entry points are declared, etc.).
@ -167,6 +166,6 @@ not send out notifications when you add commits.
[issue tracker]: https://github.com/libuv/libuv/issues
[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
[project maintainers]: https://github.com/libuv/libuv/blob/master/MAINTAINERS.md

2650
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.
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
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
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,24 +1,36 @@
# Project Maintainers
libuv is currently managed by the following individuals:
* **Bartosz Sosnowski** ([@bzoz](https://github.com/bzoz))
* **Ben Noordhuis** ([@bnoordhuis](https://github.com/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))
- 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)
* **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)
* **John Barboza** ([@jbarz](https://github.com/jbarz))
* **Jameson Nash** ([@vtjnash](https://github.com/vtjnash))
- 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))
- GPG Key: 5804 F999 8A92 2AFB A398 47A0 7183 5090 6134 887F (pubkey-erw7)
* **Richard Lau** ([@richardlau](https://github.com/richardlau))
- GPG key: C82F A3AE 1CBE DC6B E46B 9360 C43C EC45 C17A B93C (pubkey-richardlau)
* **Santiago Gimeno** ([@santigimeno](https://github.com/santigimeno))
- GPG key: 612F 0EAD 9401 6223 79DF 4402 F28C 3C8D A33C 03BE (pubkey-santigimeno)
* **Saúl Ibarra Corretgé** ([@saghul](https://github.com/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

View File

@ -20,23 +20,33 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \
include_HEADERS=include/uv.h
uvincludedir = $(includedir)/uv
uvinclude_HEADERS=include/uv/errno.h include/uv/threadpool.h include/uv/version.h
uvinclude_HEADERS = include/uv/errno.h \
include/uv/threadpool.h \
include/uv/version.h
CLEANFILES =
lib_LTLIBRARIES = libuv.la
libuv_la_CFLAGS = @CFLAGS@
libuv_la_LDFLAGS = -no-undefined -version-info 1:0:0
libuv_la_CFLAGS = $(AM_CFLAGS)
libuv_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 1:0:0
libuv_la_SOURCES = src/fs-poll.c \
src/heap-inl.h \
src/idna.c \
src/idna.h \
src/inet.c \
src/queue.h \
src/random.c \
src/strscpy.c \
src/strscpy.h \
src/thread-common.c \
src/threadpool.c \
src/timer.c \
src/uv-data-getter-setters.c \
src/uv-common.c \
src/uv-common.h \
src/version.c
src/version.c \
src/strtok.c \
src/strtok.h
if SUNOS
# Can't be turned into a CC_CHECK_CFLAGS in configure.ac, it makes compilers
@ -49,7 +59,7 @@ if WINNT
uvinclude_HEADERS += include/uv/win.h include/uv/tree.h
AM_CPPFLAGS += -I$(top_srcdir)/src/win \
-DWIN32_LEAN_AND_MEAN \
-D_WIN32_WINNT=0x0600
-D_WIN32_WINNT=0x0A00
libuv_la_SOURCES += src/win/async.c \
src/win/atomicops-inl.h \
src/win/core.c \
@ -68,7 +78,6 @@ libuv_la_SOURCES += src/win/async.c \
src/win/poll.c \
src/win/process-stdio.c \
src/win/process.c \
src/win/req.c \
src/win/req-inl.h \
src/win/signal.c \
src/win/stream.c \
@ -88,7 +97,6 @@ else # WINNT
uvinclude_HEADERS += include/uv/unix.h
AM_CPPFLAGS += -I$(top_srcdir)/src/unix
libuv_la_SOURCES += src/unix/async.c \
src/unix/atomic-ops.h \
src/unix/core.c \
src/unix/dl.c \
src/unix/fs.c \
@ -100,8 +108,8 @@ libuv_la_SOURCES += src/unix/async.c \
src/unix/pipe.c \
src/unix/poll.c \
src/unix/process.c \
src/unix/random-devurandom.c \
src/unix/signal.c \
src/unix/spinlock.h \
src/unix/stream.c \
src/unix/tcp.c \
src/unix/thread.c \
@ -112,29 +120,26 @@ endif # WINNT
EXTRA_DIST = test/fixtures/empty_file \
test/fixtures/load_error.node \
test/fixtures/lorem_ipsum.txt \
test/fixtures/one_file/one_file \
include \
test \
docs \
img \
samples \
android-configure \
CONTRIBUTING.md \
LICENSE \
README.md \
checksparse.sh \
vcbuild.bat \
common.gypi \
gyp_uv.py \
uv.gyp
LICENSE-extra \
README.md
TESTS = test/run-tests
check_PROGRAMS = test/run-tests
if OS390
test_run_tests_CFLAGS =
else
test_run_tests_CFLAGS = -Wno-long-long
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
@ -143,9 +148,8 @@ if SUNOS
test_run_tests_CFLAGS += -pthreads
endif
test_run_tests_LDFLAGS =
test_run_tests_LDFLAGS = $(AM_LDFLAGS)
test_run_tests_SOURCES = test/blackhole-server.c \
test/dns-server.c \
test/echo-server.c \
test/run-tests.c \
test/runner.c \
@ -155,7 +159,6 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-async.c \
test/test-async-null-cb.c \
test/test-barrier.c \
test/test-callback-order.c \
test/test-callback-stack.c \
test/test-close-fd.c \
test/test-close-order.c \
@ -176,6 +179,9 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-fs-event.c \
test/test-fs-poll.c \
test/test-fs.c \
test/test-fs-readdir.c \
test/test-fs-fd-hash.c \
test/test-fs-open-flags.c \
test/test-fork.c \
test/test-getters-setters.c \
test/test-get-currentexe.c \
@ -186,12 +192,16 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-gethostname.c \
test/test-getnameinfo.c \
test/test-getsockname.c \
test/test-gettimeofday.c \
test/test-handle-fileno.c \
test/test-homedir.c \
test/test-hrtime.c \
test/test-idle.c \
test/test-idna.c \
test/test-iouring-pollhup.c \
test/test-ip4-addr.c \
test/test-ip6-addr.c \
test/test-ip-name.c \
test/test-ipc-heavy-traffic-deadlock-bug.c \
test/test-ipc-send-recv.c \
test/test-ipc.c \
@ -202,8 +212,11 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-loop-stop.c \
test/test-loop-time.c \
test/test-loop-configure.c \
test/test-metrics.c \
test/test-multiple-listen.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-pass-always.c \
test/test-ping-pong.c \
@ -223,29 +236,38 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-poll-close.c \
test/test-poll-close-doesnt-corrupt-stack.c \
test/test-poll-closesocket.c \
test/test-poll-multiple-handles.c \
test/test-poll-oob.c \
test/test-process-priority.c \
test/test-process-title.c \
test/test-process-title-threadsafe.c \
test/test-queue-foreach-delete.c \
test/test-random.c \
test/test-readable-on-eof.c \
test/test-ref.c \
test/test-run-nowait.c \
test/test-run-once.c \
test/test-semaphore.c \
test/test-shutdown-close.c \
test/test-shutdown-eof.c \
test/test-shutdown-simultaneous.c \
test/test-shutdown-twice.c \
test/test-signal-multiple-loops.c \
test/test-signal-pending-on-close.c \
test/test-signal.c \
test/test-socket-buffer-size.c \
test/test-spawn.c \
test/test-stdio-over-pipes.c \
test/test-strscpy.c \
test/test-strtok.c \
test/test-tcp-alloc-cb-fail.c \
test/test-tcp-bind-error.c \
test/test-tcp-bind6-error.c \
test/test-tcp-close-accept.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-reset.c \
test/test-tcp-create-socket-early.c \
test/test-tcp-connect-error-after-write.c \
test/test-tcp-connect-error.c \
@ -254,6 +276,9 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-tcp-flags.c \
test/test-tcp-open.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-unexpected-read.c \
test/test-tcp-oob.c \
@ -262,21 +287,32 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-tcp-writealot.c \
test/test-tcp-write-fail.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-write-queue-order.c \
test/test-test-macros.c \
test/test-thread-equal.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.c \
test/test-timer-again.c \
test/test-timer-from-check.c \
test/test-timer.c \
test/test-tmpdir.c \
test/test-tty-duplicate-key.c \
test/test-tty-escape-sequence-processing.c \
test/test-tty.c \
test/test-udp-alloc-cb-fail.c \
test/test-udp-bind.c \
test/test-udp-connect.c \
test/test-udp-connect6.c \
test/test-udp-create-socket-early.c \
test/test-udp-dgram-too-big.c \
test/test-udp-ipv6.c \
test/test-udp-mmsg.c \
test/test-udp-multicast-interface.c \
test/test-udp-multicast-interface6.c \
test/test-udp-multicast-join.c \
@ -287,8 +323,12 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-udp-send-and-recv.c \
test/test-udp-send-hang-loop.c \
test/test-udp-send-immediate.c \
test/test-udp-sendmmsg-error.c \
test/test-udp-send-unreachable.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-walk-handles.c \
test/test-watcher-cross-stop.c
test_run_tests_LDADD = libuv.la
@ -302,7 +342,19 @@ test_run_tests_SOURCES += test/runner-unix.c \
endif
if AIX
test_run_tests_CFLAGS += -D_ALL_SOURCE -D_XOPEN_SOURCE=500 -D_LINUX_SOURCE_COMPAT
test_run_tests_CFLAGS += -D_ALL_SOURCE \
-D_XOPEN_SOURCE=500 \
-D_LINUX_SOURCE_COMPAT
endif
if OS400
test_run_tests_CFLAGS += -D_ALL_SOURCE \
-D_XOPEN_SOURCE=500 \
-D_LINUX_SOURCE_COMPAT
endif
if HAIKU
test_run_tests_CFLAGS += -D_BSD_SOURCE
endif
if LINUX
@ -310,11 +362,14 @@ test_run_tests_CFLAGS += -D_GNU_SOURCE
endif
if SUNOS
test_run_tests_CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
test_run_tests_CFLAGS += -D__EXTENSIONS__ \
-D_XOPEN_SOURCE=500 \
-D_REENTRANT
endif
if OS390
test_run_tests_CFLAGS += -D_UNIX03_THREADS \
test_run_tests_CFLAGS += -D_ISOC99_SOURCE \
-D_UNIX03_THREADS \
-D_UNIX03_SOURCE \
-D_OPEN_SYS_IF_EXT=1 \
-D_OPEN_SYS_SOCK_IPV6 \
@ -339,11 +394,20 @@ uvinclude_HEADERS += include/uv/aix.h
libuv_la_SOURCES += src/unix/aix.c src/unix/aix-common.c
endif
if OS400
libuv_la_CFLAGS += -D_ALL_SOURCE \
-D_XOPEN_SOURCE=500 \
-D_LINUX_SOURCE_COMPAT \
-D_THREAD_SAFE
uvinclude_HEADERS += include/uv/posix.h
libuv_la_SOURCES += src/unix/aix-common.c \
src/unix/ibmi.c \
src/unix/posix-poll.c \
src/unix/no-fsevents.c
endif
if ANDROID
uvinclude_HEADERS += include/uv/android-ifaddrs.h \
include/uv/pthread-barrier.h
libuv_la_SOURCES += src/unix/android-ifaddrs.c \
src/unix/pthread-fixes.c
libuv_la_CFLAGS += -D_GNU_SOURCE
endif
if CYGWIN
@ -361,22 +425,25 @@ libuv_la_SOURCES += src/unix/cygwin.c \
endif
if DARWIN
uvinclude_HEADERS += include/uv/darwin.h \
include/uv/pthread-barrier.h
uvinclude_HEADERS += include/uv/darwin.h
libuv_la_CFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
libuv_la_CFLAGS += -D_DARWIN_UNLIMITED_SELECT=1
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
src/unix/darwin.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/kqueue.c \
src/unix/proctitle.c
src/unix/proctitle.c \
src/unix/random-getentropy.c
test_run_tests_LDFLAGS += -lutil
endif
if DRAGONFLY
uvinclude_HEADERS += include/uv/bsd.h
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
src/unix/bsd-proctitle.c \
src/unix/freebsd.c \
src/unix/kqueue.c \
src/unix/posix-hrtime.c
@ -386,23 +453,43 @@ endif
if FREEBSD
uvinclude_HEADERS += include/uv/bsd.h
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
src/unix/bsd-proctitle.c \
src/unix/freebsd.c \
src/unix/kqueue.c \
src/unix/posix-hrtime.c
src/unix/posix-hrtime.c \
src/unix/random-getrandom.c
test_run_tests_LDFLAGS += -lutil
endif
if HAIKU
uvinclude_HEADERS += include/uv/posix.h
libuv_la_CFLAGS += -D_BSD_SOURCE
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
src/unix/haiku.c \
src/unix/no-fsevents.c \
src/unix/no-proctitle.c \
src/unix/posix-hrtime.c \
src/unix/posix-poll.c
endif
if HURD
uvinclude_HEADERS += include/uv/posix.h
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-poll.c \
src/unix/hurd.c
endif
if LINUX
uvinclude_HEADERS += include/uv/linux.h
libuv_la_CFLAGS += -D_GNU_SOURCE
libuv_la_SOURCES += src/unix/linux-core.c \
src/unix/linux-inotify.c \
src/unix/linux-syscalls.c \
src/unix/linux-syscalls.h \
libuv_la_SOURCES += src/unix/linux.c \
src/unix/procfs-exepath.c \
src/unix/proctitle.c \
src/unix/sysinfo-loadavg.c \
src/unix/sysinfo-memory.c
src/unix/random-getrandom.c \
src/unix/random-sysctl-linux.c
test_run_tests_LDFLAGS += -lutil
endif
@ -422,6 +509,7 @@ endif
if NETBSD
uvinclude_HEADERS += include/uv/bsd.h
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
src/unix/bsd-proctitle.c \
src/unix/kqueue.c \
src/unix/netbsd.c \
src/unix/posix-hrtime.c
@ -431,21 +519,24 @@ endif
if OPENBSD
uvinclude_HEADERS += include/uv/bsd.h
libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \
src/unix/bsd-proctitle.c \
src/unix/kqueue.c \
src/unix/openbsd.c \
src/unix/posix-hrtime.c
src/unix/posix-hrtime.c \
src/unix/random-getentropy.c
test_run_tests_LDFLAGS += -lutil
endif
if SUNOS
uvinclude_HEADERS += include/uv/sunos.h
libuv_la_CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
libuv_la_CFLAGS += -D__EXTENSIONS__ \
-D_XOPEN_SOURCE=500 \
-D_REENTRANT
libuv_la_SOURCES += src/unix/no-proctitle.c \
src/unix/sunos.c
endif
if OS390
uvinclude_HEADERS += include/uv/pthread-barrier.h
libuv_la_CFLAGS += -D_UNIX03_THREADS \
-D_UNIX03_SOURCE \
-D_OPEN_SYS_IF_EXT=1 \
@ -453,6 +544,7 @@ libuv_la_CFLAGS += -D_UNIX03_THREADS \
-D_XOPEN_SOURCE_EXTENDED \
-D_ALL_SOURCE \
-D_LARGE_TIME_API \
-D_OPEN_SYS_SOCK_EXT3 \
-D_OPEN_SYS_SOCK_IPV6 \
-D_OPEN_SYS_FILE_EXT \
-DUV_PLATFORM_SEM_T=int \
@ -461,8 +553,7 @@ libuv_la_CFLAGS += -D_UNIX03_THREADS \
-qXPLINK \
-qFLOAT=IEEE
libuv_la_LDFLAGS += -qXPLINK
libuv_la_SOURCES += src/unix/pthread-fixes.c \
src/unix/os390.c \
libuv_la_SOURCES += src/unix/os390.c \
src/unix/os390-syscalls.c \
src/unix/proctitle.c
endif

244
README.md
View File

@ -5,7 +5,7 @@
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](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
@ -43,14 +43,16 @@ The ABI/API changes can be tracked [here](http://abi-laboratory.pro/tracker/time
## Licensing
libuv is licensed under the MIT license. Check the [LICENSE file](LICENSE).
The documentation is licensed under the CC BY 4.0 license. Check the [LICENSE-docs file](LICENSE-docs).
libuv is licensed under the MIT license. Check the [LICENSE](LICENSE) and
[LICENSE-extra](LICENSE-extra) files.
The documentation is licensed under the CC BY 4.0 license. Check the
[LICENSE-docs file](LICENSE-docs).
## Community
* [Support](https://github.com/libuv/help)
* [Support](https://github.com/libuv/libuv/discussions)
* [Mailing list](http://groups.google.com/group/libuv)
* [IRC chatroom (#libuv@irc.freenode.org)](http://webchat.freenode.net?channels=libuv&uio=d4)
## Documentation
@ -116,9 +118,6 @@ libuv can be downloaded either from the
[GitHub repository](https://github.com/libuv/libuv)
or from the [downloads site](http://dist.libuv.org/dist/).
Starting with libuv 1.7.0, binaries for Windows are also provided. This is to
be considered EXPERIMENTAL.
Before verifying the git tags or signature files, importing the relevant keys
is necessary. Key IDs are listed in the
[MAINTAINERS](https://github.com/libuv/libuv/blob/master/MAINTAINERS.md)
@ -155,44 +154,14 @@ $ gpg --verify libuv-1.7.0.tar.gz.sign
## Build Instructions
For GCC there are two build methods: via autotools or via [GYP][].
GYP is a meta-build system which can generate MSVS, Makefile, and XCode
backends. It is best used for integration into other projects.
For UNIX-like platforms, including macOS, there are two build methods:
autotools or [CMake][].
To build with autotools:
For Windows, [CMake][] is the only supported build method and has the
following prerequisites:
```bash
$ sh autogen.sh
$ ./configure
$ make
$ make check
$ make install
```
<details>
To build with [CMake](https://cmake.org/):
```bash
$ mkdir -p out/cmake ; cd out/cmake ; cmake -DBUILD_TESTING=ON ../..
$ make all test
# Or manually:
$ ./uv_run_tests # shared library build
$ ./uv_run_tests_a # static library build
```
To build with GYP, first run:
```bash
$ git clone https://chromium.googlesource.com/external/gyp build/gyp
```
### Windows
Prerequisites:
* [Python 2.6 or 2.7][] as it is required
by [GYP][].
If python is not in your path, set the environment variable `PYTHON` to its
location. For example: `set PYTHON=C:\Python27\python.exe`
* One of:
* [Visual C++ Build Tools][]
* [Visual Studio 2015 Update 3][], all editions
@ -205,68 +174,44 @@ Prerequisites:
[Git for Windows][] includes Git Bash
and tools which can be included in the global `PATH`.
To build, launch a git shell (e.g. Cmd or PowerShell), run `vcbuild.bat`
(to build with VS2017 you need to explicitly add a `vs2017` argument),
which will checkout the GYP code into `build/gyp`, generate `uv.sln`
as well as the necesery related project files, and start building.
</details>
```console
> vcbuild
```
Or:
```console
> vcbuild vs2017
```
To run the tests:
```console
> vcbuild test
```
To see all the options that could passed to `vcbuild`:
```console
> vcbuild help
vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [vs2017] [x86/x64] [static/shared]
Examples:
vcbuild.bat : builds debug build
vcbuild.bat test : builds debug build and runs tests
vcbuild.bat release bench: builds release build and runs benchmarks
```
### Unix
For Debug builds (recommended) run:
To build with autotools:
```bash
$ ./gyp_uv.py -f make
$ make -C out
$ sh autogen.sh
$ ./configure
$ make
$ make check
$ make install
```
For Release builds run:
To build with [CMake][]:
```bash
$ ./gyp_uv.py -f make
$ BUILDTYPE=Release make -C out
$ mkdir -p build
$ (cd build && cmake .. -DBUILD_TESTING=ON) # generate project with tests
$ cmake --build build # add `-j <n>` with cmake >= 3.12
# Run tests:
$ (cd build && ctest -C Debug --output-on-failure)
# Or manually run tests:
$ build/uv_run_tests # shared library build
$ build/uv_run_tests_a # static library build
```
Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries.
### OS X
Run:
To cross-compile with [CMake][] (unsupported but generally works):
```bash
$ ./gyp_uv.py -f xcode
$ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \
-configuration Release -target All
$ cmake ../.. \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_SYSTEM_VERSION=6.1 \
-DCMAKE_C_COMPILER=i686-w64-mingw32-gcc
```
Using Homebrew:
### Install with Homebrew
```bash
$ brew install --HEAD libuv
@ -278,62 +223,121 @@ 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
(e.g. "x86_64 i386").
### Android
Run:
### Install with vcpkg
```bash
$ source ./android-configure NDK_PATH gyp [API_LEVEL]
$ make -C out
$ git clone https://github.com/microsoft/vcpkg.git
$ ./bootstrap-vcpkg.bat # for powershell
$ ./bootstrap-vcpkg.sh # for bash
$ ./vcpkg install libuv
```
The default API level is 24, but a different one can be selected as follows:
### 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
$ source ./android-configure ~/android-ndk-r15b gyp 21
$ make -C out
conan install --requires="libuv/[*]" --build=missing
```
Note for UNIX users: compile your project with `-D_LARGEFILE_SOURCE` and
`-D_FILE_OFFSET_BITS=64`. GYP builds take care of that automatically.
### Using Ninja
To use ninja for build on ninja supported platforms, run:
```bash
$ ./gyp_uv.py -f ninja
$ ninja -C out/Debug #for debug build OR
$ ninja -C out/Release
```
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
Run:
Some tests are timing sensitive. Relaxing test timeouts may be necessary
on slow or overloaded machines:
```bash
$ ./gyp_uv.py -f make
$ make -C out
$ ./out/Debug/run-tests
$ env UV_TEST_TIMEOUT_MULTIPLIER=2 build/uv_run_tests # 10s instead of 5s
```
#### Run one test
The list of all tests is in `test/test-list.h`.
This invocation will cause the test driver to fork and execute `TEST_NAME` in
a child process:
```bash
$ build/uv_run_tests_a TEST_NAME
```
This invocation will cause the test driver to execute the test in
the same process:
```bash
$ build/uv_run_tests_a TEST_NAME TEST_NAME
```
#### Debugging tools
When running the test from within the test driver process
(`build/uv_run_tests_a TEST_NAME TEST_NAME`), tools like gdb and valgrind
work normally.
When running the test from a child of the test driver process
(`build/uv_run_tests_a TEST_NAME`), use these tools in a fork-aware manner.
##### Fork-aware gdb
Use the [follow-fork-mode](https://sourceware.org/gdb/onlinedocs/gdb/Forks.html) setting:
```
$ gdb --args build/uv_run_tests_a TEST_NAME
(gdb) set follow-fork-mode child
...
```
##### Fork-aware valgrind
Use the `--trace-children=yes` parameter:
```bash
$ valgrind --trace-children=yes -v --tool=memcheck --leak-check=full --track-origins=yes --leak-resolution=high --show-reachable=yes --log-file=memcheck-%p.log build/uv_run_tests_a TEST_NAME
```
### Running benchmarks
See the section on running tests.
The benchmark driver is `./uv_run_benchmarks_a` and the benchmarks are
listed in `test/benchmark-list.h`.
## Supported Platforms
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 compilation using IBM XL C/C++ requires version 12.1 or greater.
AIX support for filesystem events requires the non-default IBM `bos.ahafs`
package to be installed. This package provides the AIX Event Infrastructure
that is detected by `autoconf`.
[IBM documentation](http://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/)
describes the package in more detail.
AIX support for filesystem events is not compiled when building with `gyp`.
### 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
after the process terminates unless the event loop is closed.
@ -343,12 +347,10 @@ Use the `ipcrm` command to manually clear up System V resources.
See the [guidelines for contributing][].
[CMake]: https://cmake.org/
[node.js]: http://nodejs.org/
[GYP]: http://code.google.com/p/gyp/
[guidelines for contributing]: https://github.com/libuv/libuv/blob/master/CONTRIBUTING.md
[libuv_banner]: https://raw.githubusercontent.com/libuv/libuv/master/img/banner.png
[x32]: https://en.wikipedia.org/wiki/X32_ABI
[Python 2.6 or 2.7]: https://www.python.org/downloads/
[Visual C++ Build Tools]: https://visualstudio.microsoft.com/visual-cpp-build-tools/
[Visual Studio 2015 Update 3]: https://www.visualstudio.com/vs/older-downloads/
[Visual Studio 2017]: https://www.visualstudio.com/downloads/

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,25 +2,19 @@
| System | Support type | Supported versions | Notes |
|---|---|---|---|
| GNU/Linux | Tier 1 | Linux >= 2.6.32 with glibc >= 2.12 | |
| macOS | Tier 1 | macOS >= 10.7 | |
| Windows | Tier 1 | >= Windows 7 | MSVC 2008 and later are supported |
| FreeBSD | Tier 1 | >= 9 (see note) | |
| GNU/Linux | Tier 1 | Linux >= 3.10 with glibc >= 2.17 | |
| macOS | Tier 1 | macOS >= 11 | Currently supported macOS releases |
| Windows | Tier 1 | >= Windows 10 | VS 2015 and later are supported |
| FreeBSD | Tier 2 | >= 12 | |
| 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 |
| Linux with musl | Tier 2 | musl >= 1.0 | |
| SmartOS | Tier 2 | >= 14.4 | Maintainers: @libuv/smartos |
| Android | Tier 3 | NDK >= r15b | |
| IBM i | Tier 3 | >= IBM i 7.2 | Maintainers: @libuv/ibmi |
| MinGW | Tier 3 | MinGW32 and MinGW-w64 | |
| Android | Tier 3 | NDK >= r15b | Android 7.0, `-DANDROID_PLATFORM=android-24` |
| MinGW | Tier 3 | MinGW-w64 | |
| SunOS | Tier 3 | Solaris 121 and later | |
| Other | Tier 3 | N/A | |
#### Note on FreeBSD 9
While FreeBSD is supported as Tier 1, FreeBSD 9 will get Tier 2 support until
it reaches end of life, in December 2016.
## Support types
* **Tier 1**: Officially supported and tested with CI. Any contributed patch
@ -52,8 +46,9 @@ All functionality related to the new platform must be implemented in its own
file inside ``src/unix/`` unless it's already done in a common file, in which
case adding an `ifdef` is fine.
Two build systems are supported: autotools and GYP. Ideally both need to be
supported, but if GYP does not support the new platform it can be left out.
Two build systems are supported: autotools and cmake. Ideally both need to be
supported, but if one of the two does not support the new platform it can be
left out.
### Windows

View File

@ -1,23 +0,0 @@
#!/bin/bash
export TOOLCHAIN=$PWD/android-toolchain
mkdir -p $TOOLCHAIN
API=${3:-24}
$1/build/tools/make-standalone-toolchain.sh \
--toolchain=arm-linux-androideabi-4.9 \
--arch=arm \
--install-dir=$TOOLCHAIN \
--platform=android-$API \
--force
export PATH=$TOOLCHAIN/bin:$PATH
export AR=arm-linux-androideabi-ar
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++
export LINK=arm-linux-androideabi-g++
export PLATFORM=android
export CFLAGS="-D__ANDROID_API__=$API"
if [[ $2 == 'gyp' ]]
then
./gyp_uv.py -Dtarget_arch=arm -DOS=android -f make-android
fi

View File

@ -1,32 +0,0 @@
version: v1.18.0.build{build}
init:
- git config --global core.autocrlf true
install:
- cinst -y nsis
matrix:
fast_finish: true
allow_failures:
- platform: x86
configuration: Release
- platform: x64
configuration: Release
platform:
- x86
- x64
configuration:
- Release
build_script:
# Fixed tag version number if using a tag.
- cmd: if "%APPVEYOR_REPO_TAG%" == "true" set APPVEYOR_BUILD_VERSION=%APPVEYOR_REPO_TAG_NAME%
# vcbuild overwrites the platform variable.
- cmd: set ARCH=%platform%
- cmd: vcbuild.bat release %ARCH% shared
cache:
- C:\projects\libuv\build\gyp

View File

@ -14,9 +14,16 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
set -eu
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
fi
@ -25,9 +32,17 @@ AUTOCONF=${AUTOCONF:-autoconf}
AUTOMAKE=${AUTOMAKE:-automake}
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_major=`echo "$automake_version" | cut -d. -f1`
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=
if test "$automake_version_major" -gt 1 || \
@ -39,8 +54,22 @@ fi
echo "m4_define([UV_EXTRA_AUTOMAKE_FLAGS], [$UV_EXTRA_AUTOMAKE_FLAGS])" \
> m4/libuv-extra-automake-flags.m4
set -ex
"$LIBTOOLIZE" --copy
(set -x
"$LIBTOOLIZE" --copy --force
"$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"
"$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

@ -1,212 +0,0 @@
{
'variables': {
'target_arch%': 'ia32', # set v8's target architecture
'host_arch%': 'ia32', # set v8's host architecture
'uv_library%': 'static_library', # allow override to 'shared_library' for DLL/.so builds
'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way
},
'target_defaults': {
'default_configuration': 'Debug',
'configurations': {
'Debug': {
'defines': [ 'DEBUG', '_DEBUG' ],
'cflags': [ '-g' ],
'msvs_settings': {
'VCCLCompilerTool': {
'target_conditions': [
['uv_library=="static_library"', {
'RuntimeLibrary': 1, # /MTd static debug
}, {
'RuntimeLibrary': 3, # /MDd DLL debug
}],
],
'Optimization': 0, # /Od, no optimization
'MinimalRebuild': 'false',
'OmitFramePointers': 'false',
'BasicRuntimeChecks': 3, # /RTC1
},
'VCLinkerTool': {
'LinkIncremental': 2, # enable incremental linking
},
},
'xcode_settings': {
'GCC_OPTIMIZATION_LEVEL': '0',
},
'conditions': [
['OS != "zos"', {
'cflags': [ '-O0', '-fwrapv' ]
}],
['OS == "android"', {
'cflags': [ '-fPIE' ],
'ldflags': [ '-fPIE', '-pie' ]
}]
]
},
'Release': {
'defines': [ 'NDEBUG' ],
'cflags': [
'-O3',
],
'msvs_settings': {
'VCCLCompilerTool': {
'target_conditions': [
['uv_library=="static_library"', {
'RuntimeLibrary': 0, # /MT static release
}, {
'RuntimeLibrary': 2, # /MD DLL release
}],
],
'Optimization': 3, # /Ox, full optimization
'FavorSizeOrSpeed': 1, # /Ot, favour speed over size
'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
'WholeProgramOptimization': 'true', # /GL, whole program optimization, needed for LTCG
'OmitFramePointers': 'true',
'EnableFunctionLevelLinking': 'true',
'EnableIntrinsicFunctions': 'true',
},
'VCLibrarianTool': {
'AdditionalOptions': [
'/LTCG', # link time code generation
],
},
'VCLinkerTool': {
'LinkTimeCodeGeneration': 1, # link-time code generation
'OptimizeReferences': 2, # /OPT:REF
'EnableCOMDATFolding': 2, # /OPT:ICF
'LinkIncremental': 1, # disable incremental linking
},
},
'conditions': [
['OS != "zos"', {
'cflags': [
'-fomit-frame-pointer',
'-fdata-sections',
'-ffunction-sections',
],
}],
]
}
},
'msvs_settings': {
'VCCLCompilerTool': {
'StringPooling': 'true', # pool string literals
'DebugInformationFormat': 3, # Generate a PDB
'WarningLevel': 3,
'BufferSecurityCheck': 'true',
'ExceptionHandling': 1, # /EHsc
'SuppressStartupBanner': 'true',
'WarnAsError': 'false',
'AdditionalOptions': [
'/MP', # compile across multiple CPUs
],
},
'VCLibrarianTool': {
},
'VCLinkerTool': {
'GenerateDebugInformation': 'true',
'RandomizedBaseAddress': 2, # enable ASLR
'DataExecutionPrevention': 2, # enable DEP
'AllowIsolation': 'true',
'SuppressStartupBanner': 'true',
'target_conditions': [
['_type=="executable"', {
'SubSystem': 1, # console executable
}],
],
},
},
'conditions': [
['OS == "win"', {
'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
'defines': [
'WIN32',
# we don't really want VC++ warning us about
# how dangerous C functions are...
'_CRT_SECURE_NO_DEPRECATE',
# ... or that C implementations shouldn't use
# POSIX names
'_CRT_NONSTDC_NO_DEPRECATE',
],
'target_conditions': [
['target_arch=="x64"', {
'msvs_configuration_platform': 'x64'
}]
]
}],
['OS in "freebsd dragonflybsd linux openbsd solaris android aix"', {
'cflags': [ '-Wall' ],
'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
'target_conditions': [
['_type=="static_library"', {
'standalone_static_library': 1, # disable thin archive which needs binutils >= 2.19
}],
],
'conditions': [
[ 'host_arch != target_arch and target_arch=="ia32"', {
'cflags': [ '-m32' ],
'ldflags': [ '-m32' ],
}],
[ 'target_arch=="x32"', {
'cflags': [ '-mx32' ],
'ldflags': [ '-mx32' ],
}],
[ 'OS=="linux"', {
'cflags': [ '-ansi' ],
}],
[ 'OS=="solaris"', {
'cflags': [ '-pthreads' ],
'ldflags': [ '-pthreads' ],
}],
[ 'OS not in "solaris android zos"', {
'cflags': [ '-pthread' ],
'ldflags': [ '-pthread' ],
}],
[ 'OS=="aix" and target_arch=="ppc64"', {
'cflags': [ '-maix64' ],
'ldflags': [ '-maix64' ],
}],
],
}],
['OS=="mac"', {
'xcode_settings': {
'ALWAYS_SEARCH_USER_PATHS': 'NO',
'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
# (Equivalent to -fPIC)
'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
'PREBINDING': 'NO', # No -Wl,-prebind
'USE_HEADERMAP': 'NO',
'WARNING_CFLAGS': [
'-Wall',
'-Wendif-labels',
'-W',
'-Wno-unused-parameter',
'-Wstrict-prototypes',
],
},
'conditions': [
['target_arch=="ia32"', {
'xcode_settings': {'ARCHS': ['i386']},
}],
['target_arch=="x64"', {
'xcode_settings': {'ARCHS': ['x86_64']},
}],
],
'target_conditions': [
['_type!="static_library"', {
'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
}],
],
}],
['OS=="solaris"', {
'cflags': [ '-fno-omit-frame-pointer' ],
# pull in V8's postmortem metadata
'ldflags': [ '-Wl,-z,allextract' ]
}],
],
},
}

View File

@ -13,25 +13,30 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AC_PREREQ(2.57)
AC_INIT([libuv], [1.23.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])
m4_include([m4/libuv-extra-automake-flags.m4])
m4_include([m4/as_case.m4])
m4_include([m4/libuv-check-flags.m4])
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_ENABLE_SHARED
AC_ENABLE_STATIC
AC_PROG_CC
AM_PROG_CC_C_O
AS_IF([AS_CASE([$host_os],[openedition*], [false], [true])], [
CC_CHECK_CFLAGS_APPEND([-pedantic])
CC_ATTRIBUTE_VISIBILITY([default], [
CC_FLAG_VISIBILITY([CFLAGS="${CFLAGS} -fvisibility=hidden"])
])
CC_FLAG_VISIBILITY #[-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([-std=gnu89])
CC_CHECK_CFLAGS_APPEND([-Wall])
CC_CHECK_CFLAGS_APPEND([-Wextra])
CC_CHECK_CFLAGS_APPEND([-Wno-long-long])
CC_CHECK_CFLAGS_APPEND([-Wno-unused-parameter])
CC_CHECK_CFLAGS_APPEND([-Wstrict-prototypes])
# AM_PROG_AR is not available in automake v0.11 but it's essential in v0.12.
@ -40,33 +45,48 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_LIBTOOL
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
LT_INIT
# TODO(bnoordhuis) Check for -pthread vs. -pthreads
AC_CHECK_LIB([dl], [dlopen])
AC_CHECK_LIB([kstat], [kstat_lookup])
AC_CHECK_LIB([nsl], [gethostbyname])
AC_CHECK_LIB([perfstat], [perfstat_cpu])
AC_CHECK_LIB([pthread], [pthread_mutex_init])
AC_CHECK_LIB([rt], [clock_gettime])
AC_CHECK_LIB([sendfile], [sendfile])
AC_CHECK_LIB([socket], [socket])
AX_PTHREAD([
LIBS="$LIBS $PTHREAD_LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
])
AC_SEARCH_LIBS([dlopen], [dl])
AC_SEARCH_LIBS([kstat_lookup], [kstat])
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([perfstat_cpu], [perfstat])
AC_SEARCH_LIBS([clock_gettime], [rt])
AC_SEARCH_LIBS([sendfile], [sendfile])
AC_SEARCH_LIBS([socket], [socket])
AC_SYS_LARGEFILE
AM_CONDITIONAL([AIX], [AS_CASE([$host_os],[aix*], [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([DARWIN], [AS_CASE([$host_os],[darwin*], [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([HURD], [AS_CASE([$host_os],[gnu*], [true], [false])])
AM_CONDITIONAL([LINUX], [AS_CASE([$host_os],[linux*], [true], [false])])
AM_CONDITIONAL([MSYS], [AS_CASE([$host_os],[msys*], [true], [false])])
AM_CONDITIONAL([NETBSD], [AS_CASE([$host_os],[netbsd*], [true], [false])])
AM_CONDITIONAL([OPENBSD], [AS_CASE([$host_os],[openbsd*], [true], [false])])
AM_CONDITIONAL([OS390], [AS_CASE([$host_os],[openedition*], [true], [false])])
AM_CONDITIONAL([OS400], [AS_CASE([$host_os],[os400], [true], [false])])
AM_CONDITIONAL([SUNOS], [AS_CASE([$host_os],[solaris*], [true], [false])])
AM_CONDITIONAL([WINNT], [AS_CASE([$host_os],[mingw*], [true], [false])])
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], [haiku], [
LIBS="$LIBS -lnetwork"
])
AC_CHECK_HEADERS([sys/ahafs_evProds.h])
AC_CONFIG_FILES([Makefile libuv.pc])
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/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

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) {
size_t size = 500;
char path[size];
char path[500];
size_t size = sizeof(path);
uv_exepath(path, &size);
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;
uv_getaddrinfo_t resolver;
fprintf(stderr, "irc.freenode.net is... ");
int r = uv_getaddrinfo(loop, &resolver, on_resolved, "irc.freenode.net", "6667", &hints);
fprintf(stderr, "irc.libera.chat is... ");
int r = uv_getaddrinfo(loop, &resolver, on_resolved, "irc.libera.chat", "6667", &hints);
if (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);
while (i--) {
uv_interface_address_t interface = info[i];
uv_interface_address_t interface_a = info[i];
printf("Name: %s\n", interface.name);
printf("Internal? %s\n", interface.is_internal ? "Yes" : "No");
printf("Name: %s\n", interface_a.name);
printf("Internal? %s\n", interface_a.is_internal ? "Yes" : "No");
if (interface.address.address4.sin_family == AF_INET) {
uv_ip4_name(&interface.address.address4, buf, sizeof(buf));
if (interface_a.address.address4.sin_family == AF_INET) {
uv_ip4_name(&interface_a.address.address4, buf, sizeof(buf));
printf("IPv4 address: %s\n", buf);
}
else if (interface.address.address4.sin_family == AF_INET6) {
uv_ip6_name(&interface.address.address6, buf, sizeof(buf));
else if (interface_a.address.address4.sin_family == AF_INET6) {
uv_ip6_name(&interface_a.address.address6, buf, sizeof(buf));
printf("IPv6 address: %s\n", buf);
}

View File

@ -70,7 +70,7 @@ void setup_workers() {
child_worker_count = cpu_count;
workers = calloc(sizeof(struct child_worker), cpu_count);
workers = calloc(cpu_count, sizeof(struct child_worker));
while (cpu_count--) {
struct child_worker *worker = &workers[cpu_count];
uv_pipe_init(loop, &worker->pipe, 1);

View File

@ -1,5 +1,4 @@
#include <stdio.h>
#include <unistd.h>
#include <uv.h>
@ -7,7 +6,7 @@ void hare(void *arg) {
int tracklen = *((int *) arg);
while (tracklen) {
tracklen--;
sleep(1);
uv_sleep(1000);
fprintf(stderr, "Hare ran another step\n");
}
fprintf(stderr, "Hare done running!\n");
@ -18,7 +17,7 @@ void tortoise(void *arg) {
while (tracklen) {
tracklen--;
fprintf(stderr, "Tortoise ran another step\n");
sleep(3);
uv_sleep(3000);
}
fprintf(stderr, "Tortoise done running!\n");
}

View File

@ -32,7 +32,7 @@ void update(uv_timer_t *req) {
int main() {
loop = uv_default_loop();
uv_tty_init(loop, &tty, 1, 0);
uv_tty_init(loop, &tty, STDOUT_FILENO, 0);
uv_tty_set_mode(&tty, 0);
if (uv_tty_get_winsize(&tty, &width, &height)) {

View File

@ -5,25 +5,27 @@
uv_loop_t *loop;
uv_tty_t tty;
int main() {
loop = uv_default_loop();
uv_tty_init(loop, &tty, 1, 0);
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_set_mode(&tty, UV_TTY_MODE_NORMAL);
if (uv_guess_handle(1) == UV_TTY) {
uv_write_t req;
uv_buf_t buf;
buf.base = "\033[41;37m";
buf.len = strlen(buf.base);
uv_write(&req, (uv_stream_t*) &tty, &buf, 1, NULL);
buf1.base = "\033[41;37m";
buf1.len = strlen(buf1.base);
uv_write(&req1, (uv_stream_t*) &tty, &buf1, 1, NULL);
}
uv_write_t req;
uv_buf_t buf;
buf.base = "Hello TTY\n";
buf.len = strlen(buf.base);
uv_write(&req, (uv_stream_t*) &tty, &buf, 1, NULL);
uv_tty_reset_mode();
return uv_run(loop, UV_RUN_DEFAULT);
}

View File

@ -53,7 +53,8 @@ uv_buf_t make_discover_msg() {
// HOPS
buffer.base[3] = 0x0;
// XID 4 bytes
buffer.base[4] = (unsigned int) random();
if (uv_random(NULL, NULL, &buffer.base[4], 4, 0, NULL))
abort();
// SECS
buffer.base[8] = 0x0;
// FLAGS

View File

@ -1,7 +1,6 @@
#include <assert.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <uv.h>
void on_read(uv_fs_t *req);

View File

@ -1,6 +1,5 @@
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.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
threading
misc
metrics

View File

@ -50,6 +50,10 @@ API
It's safe to call this function from any thread. The callback will be called on the
loop thread.
.. note::
: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.
.. warning::
libuv will coalesce calls to :c:func:`uv_async_send`, that is, not every call to it will
yield an execution of the callback. For example: if :c:func:`uv_async_send` is called 5

View File

@ -33,14 +33,22 @@ API
.. 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)
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)
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.

View File

@ -118,7 +118,7 @@ pygments_style = 'sphinx'
# The theme to use for HTML and HTML Help pages. See the documentation for
# 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
# further. For a list of options available for each theme, see the

View File

@ -4,9 +4,11 @@
Design overview
===============
libuv is cross-platform support library which was originally written for NodeJS. It's designed
libuv is cross-platform support library which was originally written for `Node.js`_. It's designed
around the event-driven asynchronous I/O model.
.. _Node.js: https://nodejs.org
The library provides much more than a simple abstraction over different I/O polling mechanisms:
'handles' and 'streams' provide a high level abstraction for sockets and other entities;
cross-platform file I/O and threading functionality is also provided, amongst other things.
@ -58,16 +60,15 @@ stages of a loop iteration:
:align: center
#. The loop concept of 'now' is updated. The event loop caches the current time at the start of
the event loop tick in order to reduce the number of time-related system calls.
#. The loop concept of 'now' is initially set.
#. 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,
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*.
#. 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
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.
@ -99,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
get the close callback called.
#. Special case in case the loop was run with ``UV_RUN_ONCE``, as it implies forward progress.
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.
#. The loop concept of 'now' is updated.
#. 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 and :c:func:`uv_run` will return. If the loop was run with ``UV_RUN_DEFAULT``
@ -123,10 +126,10 @@ File I/O
Unlike network I/O, there are no platform-specific file I/O primitives libuv could rely on,
so the current approach is to run blocking file I/O operations in a thread pool.
For a thorough explanation of the cross-platform file I/O landscape, checkout
`this post <http://blog.libtorrent.org/2012/10/asynchronous-disk-io/>`_.
For a thorough explanation of the cross-platform file I/O landscape, check out
`this post <https://blog.libtorrent.org/2012/10/asynchronous-disk-io/>`_.
libuv currently uses a global thread pool on which all loops can queue work on. 3 types of
libuv currently uses a global thread pool on which all loops can queue work. 3 types of
operations are currently run on this pool:
* File system operations

View File

@ -251,6 +251,10 @@ Error constants
operation not supported on socket
.. c:macro:: UV_EOVERFLOW
value too large for defined data type
.. c:macro:: UV_EPERM
operation not permitted
@ -319,11 +323,30 @@ Error constants
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
---
.. 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
each of the error constants above. `iter_macro` is invoked with two

View File

@ -12,6 +12,17 @@ otherwise it will be performed asynchronously.
All file operations are run on the threadpool. See :ref:`threadpool` for information
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::
On Windows `uv_fs_*` functions use utf-8 encoding.
Data types
----------
@ -22,7 +33,8 @@ Data types
.. 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.
::
@ -56,7 +68,7 @@ Data types
uv_timespec_t st_birthtim;
} uv_stat_t;
.. c:type:: uv_fs_type
.. c:enum:: uv_fs_type
File system request type.
@ -94,13 +106,35 @@ Data types
UV_FS_FCHOWN,
UV_FS_REALPATH,
UV_FS_COPYFILE,
UV_FS_LCHOWN
UV_FS_LCHOWN,
UV_FS_OPENDIR,
UV_FS_READDIR,
UV_FS_CLOSEDIR,
UV_FS_MKSTEMP,
UV_FS_LUTIME
} uv_fs_type;
.. c:type:: uv_dirent_t
.. c:type:: uv_statfs_t
Cross platform (reduced) equivalent of ``struct dirent``.
Used in :c:func:`uv_fs_scandir_next`.
Reduced cross platform equivalent of ``struct statfs``.
Used in :c:func:`uv_fs_statfs`.
::
typedef struct uv_statfs_s {
uint64_t f_type;
uint64_t f_bsize;
uint64_t f_blocks;
uint64_t f_bfree;
uint64_t f_bavail;
uint64_t f_files;
uint64_t f_ffree;
uint64_t f_spare[4];
} uv_statfs_t;
.. c:enum:: uv_dirent_type_t
Type of dirent.
::
@ -115,11 +149,38 @@ Data types
UV_DIRENT_BLOCK
} 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 {
const char* name;
uv_dirent_type_t type;
} uv_dirent_t;
.. c:type:: uv_dir_t
Data type used for streaming directory iteration.
Used by :c:func:`uv_fs_opendir()`, :c:func:`uv_fs_readdir()`, and
:c:func:`uv_fs_closedir()`. `dirents` represents a user provided array of
`uv_dirent_t`s used to hold results. `nentries` is the user provided maximum
array size of `dirents`.
::
typedef struct uv_dir_s {
uv_dirent_t* dirents;
size_t nentries;
} uv_dir_t;
.. c:type:: void (*uv_fs_cb)(uv_fs_t* req)
Callback called when a request is completed asynchronously.
Public members
^^^^^^^^^^^^^^
@ -178,7 +239,13 @@ 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)
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::
On Windows, under non-MSVC environments (e.g. when GCC or Clang is used
to build libuv), files opened using ``UV_FS_O_FILEMAP`` may cause a fatal
crash if the memory mapped read operation fails.
.. c:function:: int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
@ -186,7 +253,13 @@ 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)
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::
On Windows, under non-MSVC environments (e.g. when GCC or Clang is used
to build libuv), files opened using ``UV_FS_O_FILEMAP`` may cause a fatal
crash if the memory mapped write operation fails.
.. c:function:: int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb)
@ -197,15 +270,63 @@ API
.. c:function:: int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb)
Equivalent to :man:`mkdtemp(3)`.
Equivalent to :man:`mkdtemp(3)`. The result can be found as a null terminated string at `req->path`.
.. note::
The result can be found as a null terminated string at `req->path`.
.. c:function:: int uv_fs_mkstemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb)
Equivalent to :man:`mkstemp(3)`. The created file path can be found as a null terminated string at `req->path`.
The file descriptor can be found as an integer at `req->result`.
.. versionadded:: 1.34.0
.. c:function:: int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
Equivalent to :man:`rmdir(2)`.
.. c:function:: int uv_fs_opendir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
Opens `path` as a directory stream. On success, a `uv_dir_t` is allocated
and returned via `req->ptr`. This memory is not freed by
`uv_fs_req_cleanup()`, although `req->ptr` is set to `NULL`. The allocated
memory must be freed by calling `uv_fs_closedir()`. On failure, no memory
is allocated.
The contents of the directory can be iterated over by passing the resulting
`uv_dir_t` to `uv_fs_readdir()`.
.. versionadded:: 1.28.0
.. c:function:: int uv_fs_closedir(uv_loop_t* loop, uv_fs_t* req, uv_dir_t* dir, uv_fs_cb cb)
Closes the directory stream represented by `dir` and frees the memory
allocated by `uv_fs_opendir()`.
.. versionadded:: 1.28.0
.. c:function:: int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, uv_dir_t* dir, uv_fs_cb cb)
Iterates over the directory stream, `dir`, returned by a successful
`uv_fs_opendir()` call. Prior to invoking `uv_fs_readdir()`, the caller
must set `dir->dirents` and `dir->nentries`, representing the array of
:c:type:`uv_dirent_t` elements used to hold the read directory entries and
its size.
On success, the result is an integer >= 0 representing the number of entries
read from the stream.
.. versionadded:: 1.28.0
.. warning::
`uv_fs_readdir()` is not thread safe.
.. note::
This function does not return the "." and ".." entries.
.. note::
On success this function allocates memory that must be freed using
`uv_fs_req_cleanup()`. `uv_fs_req_cleanup()` must be called before
closing the directory with `uv_fs_closedir()`.
.. c:function:: int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_cb cb)
.. c:function:: int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent)
@ -227,6 +348,17 @@ API
Equivalent to :man:`stat(2)`, :man:`fstat(2)` and :man:`lstat(2)` respectively.
.. c:function:: int uv_fs_statfs(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
Equivalent to :man:`statfs(2)`. On success, a `uv_statfs_t` is allocated
and returned via `req->ptr`. This memory is freed by `uv_fs_req_cleanup()`.
.. note::
Any fields in the resulting `uv_statfs_t` that are not supported by the
underlying operating system are set to zero.
.. versionadded:: 1.31.0
.. c:function:: int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb)
Equivalent to :man:`rename(2)`.
@ -256,10 +388,13 @@ API
is to overwrite the destination if it exists.
- `UV_FS_COPYFILE_FICLONE`: If present, `uv_fs_copyfile()` will attempt to
create a copy-on-write reflink. If the underlying platform does not
support copy-on-write, then a fallback copy mechanism is used.
support copy-on-write, or an error occurs while attempting to use
copy-on-write, a fallback copy mechanism based on
:c:func:`uv_fs_sendfile()` is used.
- `UV_FS_COPYFILE_FICLONE_FORCE`: If present, `uv_fs_copyfile()` will
attempt to create a copy-on-write reflink. If the underlying platform does
not support copy-on-write, then an error is returned.
not support copy-on-write, or an error occurs while attempting to use
copy-on-write, then an error is returned.
.. warning::
If the destination path is created, but an error occurs while copying
@ -272,6 +407,10 @@ API
.. versionchanged:: 1.20.0 `UV_FS_COPYFILE_FICLONE` and
`UV_FS_COPYFILE_FICLONE_FORCE` are supported.
.. versionchanged:: 1.33.0 If an error occurs while using
`UV_FS_COPYFILE_FICLONE_FORCE`, that error is returned. Previously,
all errors were mapped to `UV_ENOTSUP`.
.. c:function:: int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, uv_file in_fd, int64_t in_offset, size_t length, uv_fs_cb cb)
Limited equivalent to :man:`sendfile(2)`.
@ -287,12 +426,23 @@ API
.. c:function:: int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb)
.. c:function:: int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb)
.. c:function:: int uv_fs_lutime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb)
Equivalent to :man:`utime(2)` and :man:`futime(2)` 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::
AIX: This function only works for AIX 7.1 and newer. It can still be called on older
versions but will return ``UV_ENOSYS``.
z/OS: `uv_fs_lutime()` is not implemented for z/OS. It can still be called but will return
``UV_ENOSYS``.
.. note::
AIX: `uv_fs_futime()` and `uv_fs_lutime()` functions only work for AIX 7.1 and newer.
They can still be called on older versions but will return ``UV_ENOSYS``.
.. versionchanged:: 1.10.0 sub-second precission is supported on Windows
@ -320,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)
Equivalent to :man:`realpath(3)` on Unix. Windows uses `GetFinalPathNameByHandle <https://msdn.microsoft.com/en-us/library/windows/desktop/aa364962(v=vs.85).aspx>`_.
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`.
.. warning::
@ -342,10 +492,6 @@ API
The background story and some more details on these issues can be checked
`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
.. 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)
@ -371,6 +517,13 @@ API
.. 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)
Returns `req->ptr`.
@ -397,7 +550,7 @@ Helper functions
.. c:function:: uv_os_fd_t uv_get_osfhandle(int fd)
For a file descriptor in the C runtime, get the OS-dependent handle.
On UNIX, returns the ``fd`` intact. On Windows, this calls `_get_osfhandle <https://msdn.microsoft.com/en-us/library/ks2530z6.aspx>`_.
On UNIX, returns the ``fd`` intact. On Windows, this calls `_get_osfhandle <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle?view=vs-2019>`_.
Note that the return value is still owned by the C runtime,
any attempts to close it or to use it after closing the fd may lead to malfunction.
@ -406,9 +559,9 @@ Helper functions
.. c:function:: int uv_open_osfhandle(uv_os_fd_t os_fd)
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://msdn.microsoft.com/en-us/library/bdts1c9x.aspx>`_.
Note that the return value is still owned by the CRT,
any attempts to close it or to use it after closing the handle may lead to malfunction.
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 this consumes the argument, any attempts to close it or to use it
after closing the return value may lead to malfunction.
.. versionadded:: 1.23.0
@ -432,7 +585,7 @@ File open constants
.. note::
`UV_FS_O_DIRECT` is supported on Linux, and on Windows via
`FILE_FLAG_NO_BUFFERING <https://msdn.microsoft.com/en-us/library/windows/desktop/cc644950.aspx>`_.
`FILE_FLAG_NO_BUFFERING <https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering>`_.
`UV_FS_O_DIRECT` is not supported on macOS.
.. c:macro:: UV_FS_O_DIRECTORY
@ -449,7 +602,7 @@ File open constants
.. note::
`UV_FS_O_DSYNC` is supported on Windows via
`FILE_FLAG_WRITE_THROUGH <https://msdn.microsoft.com/en-us/library/windows/desktop/cc644950.aspx>`_.
`FILE_FLAG_WRITE_THROUGH <https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering>`_.
.. c:macro:: UV_FS_O_EXCL
@ -471,6 +624,14 @@ File open constants
.. versionchanged:: 1.17.0 support is added for Windows.
.. c:macro:: UV_FS_O_FILEMAP
Use a memory file mapping to access the file. When using this flag, the
file cannot be open multiple times concurrently.
.. note::
`UV_FS_O_FILEMAP` is only supported on Windows.
.. c:macro:: UV_FS_O_NOATIME
Do not update the file access time when the file is read.
@ -508,7 +669,7 @@ File open constants
.. note::
`UV_FS_O_RANDOM` is only supported on Windows via
`FILE_FLAG_RANDOM_ACCESS <https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx>`_.
`FILE_FLAG_RANDOM_ACCESS <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew>`_.
.. c:macro:: UV_FS_O_RDONLY
@ -525,7 +686,7 @@ File open constants
.. note::
`UV_FS_O_SEQUENTIAL` is only supported on Windows via
`FILE_FLAG_SEQUENTIAL_SCAN <https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx>`_.
`FILE_FLAG_SEQUENTIAL_SCAN <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew>`_.
.. c:macro:: UV_FS_O_SHORT_LIVED
@ -533,7 +694,7 @@ File open constants
.. note::
`UV_FS_O_SHORT_LIVED` is only supported on Windows via
`FILE_ATTRIBUTE_TEMPORARY <https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx>`_.
`FILE_ATTRIBUTE_TEMPORARY <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew>`_.
.. c:macro:: UV_FS_O_SYMLINK
@ -546,7 +707,7 @@ File open constants
.. note::
`UV_FS_O_SYNC` is supported on Windows via
`FILE_FLAG_WRITE_THROUGH <https://msdn.microsoft.com/en-us/library/windows/desktop/cc644950.aspx>`_.
`FILE_FLAG_WRITE_THROUGH <https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering>`_.
.. c:macro:: UV_FS_O_TEMPORARY
@ -554,7 +715,7 @@ File open constants
.. note::
`UV_FS_O_TEMPORARY` is only supported on Windows via
`FILE_ATTRIBUTE_TEMPORARY <https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx>`_.
`FILE_ATTRIBUTE_TEMPORARY <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew>`_.
.. c:macro:: UV_FS_O_TRUNC

View File

@ -23,7 +23,7 @@ the best backend for the job on each platform.
creation/deletion within a directory that is being monitored.
See the `IBM Knowledge centre`_ for more details.
.. _documentation: http://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/
.. _documentation: https://developer.ibm.com/articles/au-aix_event_infrastructure/
.. _`IBM Knowledge centre`: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.2.0/com.ibm.zos.v2r1.bpxb100/ioc.htm
@ -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)
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
`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.
after the handle is started.
.. 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.
@ -54,7 +63,7 @@ Data types
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
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)
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
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)

View File

@ -1,7 +1,7 @@
About
=====
`Nikhil Marathe <http://nikhilism.com>`_ started writing this book one
`Nikhil Marathe <https://nikhilism.com>`_ started writing this book one
afternoon (June 16, 2012) when he didn't feel like programming. He had recently
been stung by the lack of good documentation on libuv while working on
`node-taglib <https://github.com/nikhilm/node-taglib>`_. Although reference
@ -13,8 +13,8 @@ Nikhil is indebted to Marc Lehmann's comprehensive `man page
<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod>`_ about libev which
describes much of the semantics of the two libraries.
This book was made using `Sphinx <http://sphinx.pocoo.org/>`_ and `vim
<http://www.vim.org>`_.
This book was made using `Sphinx <https://www.sphinx-doc.org>`_ and `vim
<https://www.vim.org>`_.
.. note::
In 2017 the libuv project incorporated the Nikhil's work into the official

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
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.
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.
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
@ -82,11 +82,12 @@ libuv's event loop is explained in more detail in the `documentation
Hello World
-----------
With the basics out of the way, lets write our first libuv program. It does
With the basics out of the way, let's write our first libuv program. It does
nothing, except start a loop which will exit immediately.
.. rubric:: helloworld/main.c
.. literalinclude:: ../../code/helloworld/main.c
:language: c
:linenos:
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
loop.
.. rubric:: default-loop/main.c
.. literalinclude:: ../../code/default-loop/main.c
:language: c
:linenos:
.. note::
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`_.
.. _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
to get a ``const char *`` describing the error or the error name respectively.
@ -136,8 +142,49 @@ Handles are opaque structs named as ``uv_TYPE_t`` where type signifies what the
handle is used for.
.. rubric:: libuv watchers
.. literalinclude:: ../../../include/uv.h
:lines: 197-230
.. code-block:: c
/* Handle types. */
typedef struct uv_loop_s uv_loop_t;
typedef struct uv_handle_s uv_handle_t;
typedef struct uv_dir_s uv_dir_t;
typedef struct uv_stream_s uv_stream_t;
typedef struct uv_tcp_s uv_tcp_t;
typedef struct uv_udp_s uv_udp_t;
typedef struct uv_pipe_s uv_pipe_t;
typedef struct uv_tty_s uv_tty_t;
typedef struct uv_poll_s uv_poll_t;
typedef struct uv_timer_s uv_timer_t;
typedef struct uv_prepare_s uv_prepare_t;
typedef struct uv_check_s uv_check_t;
typedef struct uv_idle_s uv_idle_t;
typedef struct uv_async_s uv_async_t;
typedef struct uv_process_s uv_process_t;
typedef struct uv_fs_event_s uv_fs_event_t;
typedef struct uv_fs_poll_s uv_fs_poll_t;
typedef struct uv_signal_s uv_signal_t;
/* Request types. */
typedef struct uv_req_s uv_req_t;
typedef struct uv_getaddrinfo_s uv_getaddrinfo_t;
typedef struct uv_getnameinfo_s uv_getnameinfo_t;
typedef struct uv_shutdown_s uv_shutdown_t;
typedef struct uv_write_s uv_write_t;
typedef struct uv_connect_s uv_connect_t;
typedef struct uv_udp_send_s uv_udp_send_t;
typedef struct uv_fs_s uv_fs_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
identified using **requests**. A request is short-lived (usually used across
@ -171,6 +218,7 @@ event watchers are active.
.. rubric:: idle-basic/main.c
.. literalinclude:: ../../code/idle-basic/main.c
:language: c
:emphasize-lines: 6,10,14-17
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
.. literalinclude:: ../../../src/unix/core.c
:language: c
:linenos:
:lines: 304-324
:emphasize-lines: 10,19,21
@ -43,6 +44,7 @@ iteration of the loop still takes places.
.. rubric:: uvstop/main.c
.. literalinclude:: ../../code/uvstop/main.c
:language: c
:linenos:
: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
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*.
@ -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)
``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.
File descriptors are closed using
@ -54,6 +54,7 @@ a callback for when the file is opened:
.. rubric:: uvcat/main.c - opening a file
.. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos:
:lines: 41-53
: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
.. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos:
:lines: 26-40
:lines: 26-39
:emphasize-lines: 2,8,12
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
.. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos:
:lines: 16-24
:lines: 17-24
:emphasize-lines: 6
.. warning::
@ -100,6 +103,7 @@ We set the dominos rolling in ``main()``:
.. rubric:: uvcat/main.c
.. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos:
:lines: 55-
:emphasize-lines: 2
@ -118,8 +122,46 @@ same patterns as the read/write/open calls, returning the result in the
``uv_fs_t.result`` field. The full list:
.. rubric:: Filesystem operations
.. literalinclude:: ../../../include/uv.h
:lines: 1084-1195
.. code-block:: c
int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, 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);
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);
int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
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);
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_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_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_opendir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, uv_dir_t* dir, uv_fs_cb cb);
int uv_fs_closedir(uv_loop_t* loop, uv_fs_t* req, uv_dir_t* dir, uv_fs_cb cb);
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb);
int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb);
int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb);
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb);
int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, int64_t offset, uv_fs_cb cb);
int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, uv_file in_fd, int64_t in_offset, size_t length, uv_fs_cb cb);
int uv_fs_access(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_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_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_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode, 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_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:
@ -151,7 +193,7 @@ and freed by the application.
.. 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
local files [#]_. Here is a simple tee utility using libuv. Doing all operations
@ -168,8 +210,9 @@ opened as bidirectional by default.
.. rubric:: uvtee/main.c - read on pipes
.. literalinclude:: ../../code/uvtee/main.c
:language: c
:linenos:
:lines: 61-80
:lines: 62-80
:emphasize-lines: 4,5,15
The third argument of ``uv_pipe_init()`` should be set to 1 for IPC using named
@ -183,6 +226,7 @@ these buffers.
.. rubric:: uvtee/main.c - reading buffers
.. literalinclude:: ../../code/uvtee/main.c
:language: c
:linenos:
:lines: 19-22,44-60
@ -207,6 +251,7 @@ point there is nothing to be read. Most applications will just ignore this.
.. rubric:: uvtee/main.c - Write to pipe
.. literalinclude:: ../../code/uvtee/main.c
:language: c
:linenos:
:lines: 9-13,23-42
@ -243,10 +288,18 @@ a command whenever any of the watched files change::
./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()``:
.. rubric:: onchange/main.c - The setup
.. literalinclude:: ../../code/onchange/main.c
:language: c
:linenos:
:lines: 26-
:emphasize-lines: 15
@ -254,8 +307,16 @@ The file change notification is started using ``uv_fs_event_init()``:
The third argument is the actual file or directory to monitor. The last
argument, ``flags``, can be:
.. literalinclude:: ../../../include/uv.h
:lines: 1299, 1308, 1315
.. code-block:: c
/*
* Flags to be passed to uv_fs_event_start().
*/
enum uv_fs_event_flags {
UV_FS_EVENT_WATCH_ENTRY = 1,
UV_FS_EVENT_STAT = 2,
UV_FS_EVENT_RECURSIVE = 4
};
``UV_FS_EVENT_WATCH_ENTRY`` and ``UV_FS_EVENT_STAT`` don't do anything (yet).
``UV_FS_EVENT_RECURSIVE`` will start watching subdirectories as well on
@ -268,15 +329,16 @@ The callback will receive the following arguments:
#. ``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``
even on those platforms.
#. ``int flags`` - one of ``UV_RENAME`` or ``UV_CHANGE``, or a bitwise OR of
both.
#. ``int status`` - Currently 0.
#. ``int events`` - one of ``UV_RENAME`` or ``UV_CHANGE``, or a bitwise OR of
both.
#. ``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
``system()``.
.. rubric:: onchange/main.c - file change notification callback
.. literalinclude:: ../../code/onchange/main.c
:language: c
:linenos:
: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
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
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
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
----
All the code from this book is included as part of the source of the book on
Github. `Clone`_/`Download`_ the book, then build libuv::
All the example code and the source of the book is included as part of
the libuv_ project on GitHub.
Clone or Download libuv_, then build it::
cd libuv
./autogen.sh
sh autogen.sh
./configure
make
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
.. _Download: https://github.com/nikhilm/uvbook/downloads
.. _v1.3.0: https://github.com/libuv/libuv/tags
.. _V8: http://code.google.com/p/v8/
.. _v1.42.0: https://github.com/libuv/libuv/releases/tag/v1.42.0
.. _V8: https://v8.dev
.. _libev: http://software.schmorp.de/pkg/libev.html
.. _libuv: https://github.com/libuv/libuv
.. _node.js: http://www.nodejs.org
.. _node.js: https://www.nodejs.org
.. _libev was removed: https://github.com/joyent/libuv/issues/485
.. _Rust: http://rust-lang.org
.. _variety: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv
.. _Rust: https://www.rust-lang.org
.. _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
.. literalinclude:: ../../code/tcp-echo-server/main.c
:language: c
:linenos:
:lines: 68-
: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
.. literalinclude:: ../../code/tcp-echo-server/main.c
:language: c
:linenos:
:lines: 51-66
: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
.. literalinclude:: ../../code/udp-dhcp/main.c
:language: c
:linenos:
:lines: 7-11,104-
: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
.. literalinclude:: ../../code/udp-dhcp/main.c
:language: c
:linenos:
:lines: 17-40
:emphasize-lines: 1,23
@ -160,21 +164,22 @@ IPv6 stack only
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
``uv_udp_bind`` [#]_.
``uv_udp_bind``.
Multicast
~~~~~~~~~
A socket can (un)subscribe to a multicast group using:
.. literalinclude:: ../../../include/uv.h
:lines: 594-597
.. code::block:: c
int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr, const char* interface_addr, uv_membership membership);
where ``membership`` is ``UV_JOIN_GROUP`` or ``UV_LEAVE_GROUP``.
The concepts of multicasting are nicely explained in `this guide`_.
.. _this guide: http://www.tldp.org/HOWTO/Multicast-HOWTO-2.html
.. _this guide: https://www.tldp.org/HOWTO/Multicast-HOWTO-2.html
Local loopback of multicast packets is enabled by default [#]_, use
``uv_udp_set_multicast_loop`` to switch it off.
@ -188,10 +193,11 @@ Querying DNS
libuv provides asynchronous DNS resolution. For this it provides its own
``getaddrinfo`` replacement [#]_. In the callback you can
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
.. literalinclude:: ../../code/dns/main.c
:language: c
:linenos:
:lines: 61-
:emphasize-lines: 12
@ -199,7 +205,7 @@ Freenode to see an example of DNS resolution.
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
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.
In the resolver callback, you can pick any IP from the linked list of ``struct
@ -208,6 +214,7 @@ call ``uv_freeaddrinfo`` in the callback.
.. rubric:: dns/main.c
.. literalinclude:: ../../code/dns/main.c
:language: c
:linenos:
:lines: 42-60
:emphasize-lines: 8,16
@ -226,6 +233,7 @@ useful to allow your service to bind to IP addresses when it starts.
.. rubric:: interfaces/main.c
.. literalinclude:: ../../code/interfaces/main.c
:language: c
:linenos:
:emphasize-lines: 9,17
@ -233,17 +241,16 @@ useful to allow your service to bind to IP addresses when it starts.
interface has multiple IPv4/IPv6 addresses, the name will be reported multiple
times, with each address being reported once.
.. _c-ares: http://c-ares.haxx.se
.. _getaddrinfo: http://www.kernel.org/doc/man-pages/online/pages/man3/getaddrinfo.3.html
.. _c-ares: https://c-ares.haxx.se
.. _getaddrinfo: https://man7.org/linux/man-pages/man3/getaddrinfo.3.html
.. _User Datagram Protocol: http://en.wikipedia.org/wiki/User_Datagram_Protocol
.. _DHCP: http://tools.ietf.org/html/rfc2131
.. _User Datagram Protocol: https://en.wikipedia.org/wiki/User_Datagram_Protocol
.. _DHCP: https://tools.ietf.org/html/rfc2131
----
.. [#] http://beej.us/guide/bgnet/output/html/multipage/advanced.html#broadcast
.. [#] on Windows only supported on Windows Vista and later.
.. [#] http://www.tldp.org/HOWTO/Multicast-HOWTO-6.html#ss6.1
.. [#] https://beej.us/guide/bgnet/html/#broadcast-packetshello-world
.. [#] https://www.tldp.org/HOWTO/Multicast-HOWTO-6.html#ss6.1
.. [#] 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
removed in v0.9.0.

View File

@ -27,6 +27,7 @@ exits. This is achieved using ``uv_spawn``.
.. rubric:: spawn/main.c
.. literalinclude:: ../../code/spawn/main.c
:language: c
:linenos:
:lines: 6-8,15-
:emphasize-lines: 11,13-17
@ -42,20 +43,21 @@ exits. This is achieved using ``uv_spawn``.
The ``uv_process_t`` struct only acts as the handle, all options are set via
``uv_process_options_t``. To simply launch a process, you need to set only the
``file`` and ``args`` fields. ``file`` is the program to execute. Since
``uv_spawn`` uses execvp_ internally, there is no need to supply the full
``uv_spawn`` uses :man:`execvp(3)` internally, there is no need to supply the full
path. Finally as per underlying conventions, **the arguments array has to be
one larger than the number of arguments, with the last element being NULL**.
.. _execvp: http://www.kernel.org/doc/man-pages/online/pages/man3/exec.3.html
After the call to ``uv_spawn``, ``uv_process_t.pid`` will contain the process
ID of the child process.
The exit callback will be invoked with the *exit status* and the type of *signal*
which caused the exit.
Note that it is important **not** to call ``uv_close`` before the exit callback.
.. rubric:: spawn/main.c
.. literalinclude:: ../../code/spawn/main.c
:language: c
:linenos:
:lines: 9-12
:emphasize-lines: 3
@ -106,6 +108,7 @@ does not affect it.
.. rubric:: detach/main.c
.. literalinclude:: ../../code/detach/main.c
:language: c
:linenos:
:lines: 9-30
:emphasize-lines: 12,19
@ -125,7 +128,8 @@ of ``uv_kill`` is::
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
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
-------
@ -142,6 +146,7 @@ stop watching. Here is a small example demonstrating the various possibilities:
.. rubric:: signal/main.c
.. literalinclude:: ../../code/signal/main.c
:language: c
:linenos:
:emphasize-lines: 17-18,27-28
@ -174,6 +179,7 @@ which is:
.. rubric:: proc-streams/test.c
.. literalinclude:: ../../code/proc-streams/test.c
:language: c
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
@ -181,8 +187,16 @@ The file descriptors of the child process are set using the ``stdio`` field in
file descriptors being set. ``uv_process_options_t.stdio`` is an array of
``uv_stdio_container_t``, which is:
.. literalinclude:: ../../../include/uv.h
:lines: 826-834
.. code-block:: c
typedef struct uv_stdio_container_s {
uv_stdio_flags flags;
union {
uv_stream_t* stream;
int fd;
} data;
} uv_stdio_container_t;
where flags can have several values. Use ``UV_IGNORE`` if it isn't going to be
used. If the first three ``stdio`` fields are marked as ``UV_IGNORE`` they'll
@ -193,6 +207,7 @@ Then we set the ``fd`` to ``stderr``.
.. rubric:: proc-streams/main.c
.. literalinclude:: ../../code/proc-streams/main.c
:language: c
:linenos:
:lines: 15-17,27-
:emphasize-lines: 6,10,11,12
@ -205,18 +220,20 @@ to ``UV_INHERIT_STREAM`` and setting ``data.stream`` to the stream in the
parent process, the child process can treat that stream as standard I/O. This
can be used to implement something like CGI_.
.. _CGI: http://en.wikipedia.org/wiki/Common_Gateway_Interface
.. _CGI: https://en.wikipedia.org/wiki/Common_Gateway_Interface
A sample CGI script/executable is:
.. rubric:: cgi/tick.c
.. literalinclude:: ../../code/cgi/tick.c
:language: c
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.
.. rubric:: cgi/main.c
.. literalinclude:: ../../code/cgi/main.c
:language: c
:linenos:
:lines: 49-63
:emphasize-lines: 10
@ -226,6 +243,7 @@ Here we simply accept the TCP connection and pass on the socket (*stream*) to
.. rubric:: cgi/main.c
.. literalinclude:: ../../code/cgi/main.c
:language: c
:linenos:
:lines: 16, 25-45
:emphasize-lines: 8-9,18,20
@ -237,26 +255,35 @@ is great. Just be warned that creating processes is a costly task.
.. _pipes:
Pipes
-----
libuv's ``uv_pipe_t`` structure is slightly confusing to Unix programmers,
because it immediately conjures up ``|`` and `pipe(7)`_. But ``uv_pipe_t`` is
not related to anonymous pipes, rather it is an IPC mechanism. ``uv_pipe_t``
can be backed by a `Unix Domain Socket`_ or `Windows Named Pipe`_ to allow
multiple processes to communicate. This is discussed below.
.. _pipe(7): http://www.kernel.org/doc/man-pages/online/pages/man7/pipe.7.html
.. _Unix Domain Socket: http://www.kernel.org/doc/man-pages/online/pages/man7/unix.7.html
.. _Windows Named Pipe: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365590(v=vs.85).aspx
Parent-child IPC
++++++++++++++++
----------------
A parent and child can have one or two way communication over a pipe created by
settings ``uv_stdio_container_t.flags`` to a bit-wise combination of
``UV_CREATE_PIPE`` and ``UV_READABLE_PIPE`` or ``UV_WRITABLE_PIPE``. The
read/write flag is from the perspective of the child process.
read/write flag is from the perspective of the child process. In this case,
the ``uv_stream_t* stream`` field must be set to point to an initialized,
unopened ``uv_pipe_t`` instance.
New stdio Pipes
+++++++++++++++
The ``uv_pipe_t`` structure represents more than just `pipe(7)`_ (or ``|``),
but supports any streaming file-like objects. On Windows, the only object of
that description is the `Named Pipe`_. On Unix, this could be any of `Unix
Domain Socket`_, or derived from `mkfifo(1)`_, or it could actually be a
`pipe(7)`_. When ``uv_spawn`` initializes a ``uv_pipe_t`` due to the
`UV_CREATE_PIPE` flag, it opts for creating a `socketpair(2)`_.
This is intended for the purpose of allowing multiple libuv processes to
communicate with IPC. This is discussed below.
.. _pipe(7): https://man7.org/linux/man-pages/man7/pipe.7.html
.. _mkfifo(1): https://man7.org/linux/man-pages/man1/mkfifo.1.html
.. _socketpair(2): https://man7.org/linux/man-pages/man2/socketpair.2.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
Arbitrary process IPC
+++++++++++++++++++++
@ -268,7 +295,7 @@ notification. Various applications can then react when a contact comes online
or new hardware is detected. The MySQL server also runs a domain socket on
which clients can interact with it.
.. _D-BUS: http://www.freedesktop.org/wiki/Software/dbus
.. _D-BUS: https://www.freedesktop.org/wiki/Software/dbus
When using domain sockets, a client-server pattern is usually followed with the
creator/owner of the socket acting as the server. After the initial setup,
@ -276,6 +303,7 @@ messaging is no different from TCP, so we'll re-use the echo server example.
.. rubric:: pipe-echo-server/main.c
.. literalinclude:: ../../code/pipe-echo-server/main.c
:language: c
:linenos:
:lines: 70-
:emphasize-lines: 5,10,14
@ -305,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
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
involved, and while only snippets are included in the book, it is recommended
to read the full code to really understand it.
@ -315,6 +343,7 @@ it by the master.
.. rubric:: multi-echo-server/worker.c
.. literalinclude:: ../../code/multi-echo-server/worker.c
:language: c
:linenos:
:lines: 7-9,81-
:emphasize-lines: 6-8
@ -328,6 +357,7 @@ standard input of the worker, we connect the pipe to ``stdin`` using
.. rubric:: multi-echo-server/worker.c
.. literalinclude:: ../../code/multi-echo-server/worker.c
:language: c
:linenos:
:lines: 51-79
:emphasize-lines: 10,15,20
@ -346,6 +376,7 @@ allow load balancing.
.. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c
:language: c
:linenos:
:lines: 9-13
@ -354,6 +385,7 @@ master and the individual process.
.. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c
:language: c
:linenos:
:lines: 51,61-95
:emphasize-lines: 17,20-21
@ -372,6 +404,7 @@ worker in the round-robin.
.. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c
:language: c
:linenos:
:lines: 31-49
:emphasize-lines: 9,12-13

View File

@ -12,7 +12,7 @@ asynchronously that is actually blocking, by spawning a thread and collecting
the result when it is done.
Today there are two predominant thread libraries: the Windows threads
implementation and POSIX's `pthreads`_. libuv's thread API is analogous to
implementation and POSIX's :man:`pthreads(7)`. libuv's thread API is analogous to
the pthreads API and often has similar semantics.
A notable aspect of libuv's thread facilities is that it is a self contained
@ -39,6 +39,7 @@ wait for it to close using ``uv_thread_join()``.
.. rubric:: thread-create/main.c
.. literalinclude:: ../../code/thread-create/main.c
:language: c
:linenos:
:lines: 26-36
:emphasize-lines: 3-7
@ -55,6 +56,7 @@ thread, scheduled pre-emptively by the operating system:
.. rubric:: thread-create/main.c
.. literalinclude:: ../../code/thread-create/main.c
:language: c
:linenos:
:lines: 6-14
:emphasize-lines: 2
@ -68,7 +70,7 @@ Synchronization Primitives
This section is purposely spartan. This book is not about threads, so I only
catalogue any surprises in the libuv APIs here. For the rest you can look at
the pthreads `man pages <pthreads>`_.
the :man:`pthreads(7)` man pages.
Mutexes
~~~~~~~
@ -76,8 +78,14 @@ Mutexes
The mutex functions are a **direct** map to the pthread equivalents.
.. rubric:: libuv mutex functions
.. literalinclude:: ../../../include/uv.h
:lines: 1355-1360
.. code-block:: c
int uv_mutex_init(uv_mutex_t* handle);
int uv_mutex_init_recursive(uv_mutex_t* handle);
void uv_mutex_destroy(uv_mutex_t* handle);
void uv_mutex_lock(uv_mutex_t* handle);
int uv_mutex_trylock(uv_mutex_t* handle);
void uv_mutex_unlock(uv_mutex_t* handle);
The ``uv_mutex_init()``, ``uv_mutex_init_recursive()`` and ``uv_mutex_trylock()``
functions will return 0 on success, and an error code otherwise.
@ -118,6 +126,7 @@ example.
.. rubric:: locks/main.c - simple rwlocks
.. literalinclude:: ../../code/locks/main.c
:language: c
:linenos:
:emphasize-lines: 13,16,27,31,42,55
@ -135,9 +144,9 @@ Others
libuv also supports semaphores_, `condition variables`_ and barriers_ with APIs
very similar to their pthread counterparts.
.. _semaphores: http://en.wikipedia.org/wiki/Semaphore_(programming)
.. _condition variables: http://en.wikipedia.org/wiki/Condition_variable#Waiting_and_signaling
.. _barriers: http://en.wikipedia.org/wiki/Barrier_(computer_science)
.. _semaphores: https://en.wikipedia.org/wiki/Semaphore_(programming)
.. _condition variables: https://en.wikipedia.org/wiki/Monitor_(synchronization)#Condition_variables_2
.. _barriers: https://en.wikipedia.org/wiki/Barrier_(computer_science)
In addition, libuv provides a convenience function ``uv_once()``. Multiple
threads can attempt to call ``uv_once()`` with a given guard and a function
@ -202,6 +211,7 @@ event loop from performing other activities.
.. rubric:: queue-work/main.c - lazy fibonacci
.. literalinclude:: ../../code/queue-work/main.c
:language: c
:linenos:
:lines: 17-29
@ -215,6 +225,7 @@ The trigger is ``uv_queue_work``:
.. rubric:: queue-work/main.c
.. literalinclude:: ../../code/queue-work/main.c
:language: c
:linenos:
:lines: 31-44
:emphasize-lines: 10
@ -242,6 +253,7 @@ up a signal handler for termination.
.. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c
:language: c
:linenos:
:lines: 43-
@ -250,6 +262,7 @@ When the user triggers the signal by pressing ``Ctrl+C`` we send
.. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c
:language: c
:linenos:
:lines: 33-41
:emphasize-lines: 6
@ -259,6 +272,7 @@ with ``status`` set to ``UV_ECANCELED``.
.. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c
:language: c
:linenos:
:lines: 28-31
:emphasize-lines: 2
@ -286,8 +300,9 @@ informing the user of the status of running downloads.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
:language: c
:linenos:
:lines: 7-8,34-
:lines: 7-8,35-
:emphasize-lines: 2,11
The async thread communication works *on loops* so although any thread can be
@ -311,8 +326,9 @@ with the async watcher whenever it receives a message.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
:language: c
:linenos:
:lines: 10-23
:lines: 10-24
:emphasize-lines: 7-8
In the download function, we modify the progress indicator and queue the message
@ -321,8 +337,9 @@ non-blocking and will return immediately.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
:language: c
:linenos:
:lines: 30-33
:lines: 31-34
The callback is a standard libuv pattern, extracting the data from the watcher.
@ -330,8 +347,9 @@ Finally it is important to remember to clean up the watcher.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
:language: c
:linenos:
:lines: 25-28
:lines: 26-29
:emphasize-lines: 3
After this example, which showed the abuse of the ``data`` field, bnoordhuis_
@ -373,9 +391,7 @@ which binds a third party library. It may go something like this:
4. The async callback, invoked in the main loop thread, which is the v8 thread,
then interacts with v8 to invoke the JavaScript callback.
.. _pthreads: http://man7.org/linux/man-pages/man7/pthreads.7.html
----
.. _node.js is cancer: http://teddziuba.github.io/2011/10/node-js-is-cancer.html
.. _node.js is cancer: http://widgetsandshit.com/teddziuba/2011/10/node-js-is-cancer.html
.. _bnoordhuis: https://github.com/bnoordhuis

View File

@ -87,6 +87,7 @@ JS object and can be ref/unrefed.
.. rubric:: ref-timer/main.c
.. literalinclude:: ../../code/ref-timer/main.c
:language: c
:linenos:
:lines: 5-8, 17-
:emphasize-lines: 9
@ -111,6 +112,7 @@ idle watcher to keep the UI operational.
.. rubric:: idle-compute/main.c
.. literalinclude:: ../../code/idle-compute/main.c
:language: c
:linenos:
:lines: 5-9, 34-
:emphasize-lines: 13
@ -123,6 +125,7 @@ keep calling the idle callback again.
.. rubric:: idle-compute/main.c
.. literalinclude:: ../../code/idle-compute/main.c
:language: c
:linenos:
:lines: 10-19
@ -196,7 +199,7 @@ to access the underlying file descriptors and provide functions that process
tasks in small increments as decided by your application. Some libraries though
will not allow such access, providing only a standard blocking function which
will perform the entire I/O transaction and only then return. It is unwise to
use these in the event loop thread, use the :ref:`libuv-work-queue` instead. Of
use these in the event loop thread, use the :ref:`threadpool` instead. Of
course, this will also mean losing granular control on the library.
The ``uv_poll`` section of libuv simply watches file descriptors using the
@ -210,13 +213,14 @@ download files. Rather than give all control to libcurl, we'll instead be
using the libuv event loop, and use the non-blocking, async multi_ interface to
progress with the download whenever libuv notifies of I/O readiness.
.. _libcurl: http://curl.haxx.se/libcurl/
.. _multi: http://curl.haxx.se/libcurl/c/libcurl-multi.html
.. _libcurl: https://curl.haxx.se/libcurl/
.. _multi: https://curl.haxx.se/libcurl/c/libcurl-multi.html
.. rubric:: uvwget/main.c - The setup
.. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos:
:lines: 1-9,140-
:lines: 1-9,142-
:emphasize-lines: 7,21,24-25
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] ...
So we add each argument as an URL
So we add each argument as a URL
.. rubric:: uvwget/main.c - Adding urls
.. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos:
:lines: 39-56
: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.
``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
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
@ -251,6 +256,7 @@ on sockets whenever ``handle_socket`` is called.
.. rubric:: uvwget/main.c - Setting up polling
.. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos:
:lines: 102-140
: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.
.. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos:
:lines: 81-95
:emphasize-lines: 2,6-7,12
@ -288,6 +295,7 @@ transfers are done.
.. rubric:: uvwget/main.c - Reading transfer status.
.. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos:
:lines: 58-79
: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
.. literalinclude:: ../../code/plugin/plugin.h
:language: c
:linenos:
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
.. literalinclude:: ../../code/plugin/hello.c
:language: c
:linenos:
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
.. literalinclude:: ../../code/plugin/main.c
:language: c
:linenos:
:lines: 7-
: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
function we are looking for in the application's plugins.
.. _shared libraries: http://en.wikipedia.org/wiki/Shared_library#Shared_libraries
.. _shared libraries: https://en.wikipedia.org/wiki/Shared_library
TTY
---
@ -365,14 +376,15 @@ implement the ANSI escape codes across all platforms. By this I mean that libuv
converts ANSI codes to the Windows equivalent, and provides functions to get
terminal information.
.. _pretty standardised: http://en.wikipedia.org/wiki/ANSI_escape_sequences
.. _pretty standardised: https://en.wikipedia.org/wiki/ANSI_escape_sequences
The first thing to do is to initialize a ``uv_tty_t`` with the file descriptor
it reads/writes from. This is achieved with::
int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable)
int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int unused)
Set ``readable`` to true if you plan to use ``uv_read_start()`` on the stream.
The ``unused`` parameter is now auto-detected and ignored. It previously needed
to be set to use ``uv_read_start()`` on the stream.
It is then best to use ``uv_tty_set_mode`` to set the mode to *normal*
which enables most TTY formatting, flow-control and other settings. Other_ modes
@ -392,6 +404,7 @@ Here is a simple example which prints white text on a red background:
.. rubric:: tty/main.c
.. literalinclude:: ../../code/tty/main.c
:language: c
:linenos:
:emphasize-lines: 11-12,14,17,27
@ -402,6 +415,7 @@ escape codes.
.. rubric:: tty-gravity/main.c
.. literalinclude:: ../../code/tty-gravity/main.c
:language: c
:linenos:
:emphasize-lines: 19,25,38
@ -421,13 +435,16 @@ As you can see this is very useful to produce nicely formatted output, or even
console based arcade games if that tickles your fancy. For fancier control you
can try `ncurses`_.
.. _ncurses: http://www.gnu.org/software/ncurses/ncurses.html
.. _ncurses: https://www.gnu.org/software/ncurses/ncurses.html
.. versionchanged:: 1.23.1: the `readable` parameter is now unused and ignored.
The appropriate value will now be auto-detected from the kernel.
----
.. [#] I was first introduced to the term baton in this context, in Konstantin
Käfer's excellent slides on writing node.js bindings --
http://kkaefer.github.com/node-cpp-modules/#baton
https://kkaefer.com/node-cpp-modules/#baton
.. [#] mfp is My Fancy Plugin
.. _libev man page: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#COMMON_OR_USEFUL_IDIOMS_OR_BOTH

View File

@ -20,7 +20,7 @@ Data types
The base libuv handle type.
.. c:type:: uv_handle_type
.. c:enum:: uv_handle_type
The kind of the libuv handle.
@ -60,6 +60,9 @@ Data types
a ``UV_ENOBUFS`` error will be triggered in the :c:type:`uv_udp_recv_cb` or the
:c:type:`uv_read_cb` callback.
Each buffer is used only once and the user is responsible for freeing it in the
:c:type:`uv_udp_recv_cb` or the :c:type:`uv_read_cb` callback.
A suggested size (65536 at the moment in most cases) is provided, but it's just an indication,
not related in any way to the pending data to be read. The user is free to allocate the amount
of memory they decide.
@ -87,11 +90,11 @@ Public members
.. c:member:: uv_loop_t* uv_handle_t.loop
Pointer to the :c:type:`uv_loop_t` where the handle is running on. Readonly.
Pointer to the :c:type:`uv_loop_t` the handle is running on. Readonly.
.. 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
@ -101,7 +104,7 @@ Public members
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
each of the handle types. `iter_macro` is invoked with two
@ -140,6 +143,8 @@ API
Request handle to be closed. `close_cb` will be called asynchronously after
this call. This MUST be called on each handle before memory is released.
Moreover, the memory can only be released in `close_cb` or after it has
returned.
Handles that wrap file descriptors are closed immediately but
`close_cb` will still be deferred to the next iteration of the event loop.
@ -148,6 +153,9 @@ API
In-progress requests, like uv_connect_t or uv_write_t, are cancelled and
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)
Reference the given handle. References are idempotent, that is, if a handle
@ -185,8 +193,11 @@ just for some handle types.
Gets or sets the size of the send buffer that the operating
system uses for the socket.
If `*value` == 0, it will return the current send buffer size,
otherwise it will use `*value` to set the new send buffer size.
If `*value` == 0, then it will set `*value` to the current send buffer size.
If `*value` > 0 then it will use `*value` to set the new send buffer size.
On success, zero is returned. On error, a negative result is
returned.
This function works for TCP, pipe and UDP handles on Unix and for TCP and
UDP handles on Windows.
@ -199,8 +210,11 @@ just for some handle types.
Gets or sets the size of the receive buffer that the operating
system uses for the socket.
If `*value` == 0, it will return the current receive buffer size,
otherwise it will use `*value` to set the new receive buffer size.
If `*value` == 0, then it will set `*value` to the current receive buffer size.
If `*value` > 0 then it will use `*value` to set the new receive buffer size.
On success, zero is returned. On error, a negative result is
returned.
This function works for TCP, pipe and UDP handles on Unix and for TCP and
UDP handles on Windows.
@ -234,7 +248,7 @@ just for some handle types.
.. 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`.

View File

@ -41,14 +41,22 @@ API
.. 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)
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)
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.

View File

@ -7,17 +7,17 @@ Overview
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`_,
`Julia`_, `pyuv`_, and `others`_.
`Julia`_, `uvloop`_, and `others`_.
.. note::
In case you find errors in this documentation you can help by sending
`pull requests <https://github.com/libuv/libuv>`_!
.. _Node.js: http://nodejs.org
.. _Luvit: http://luvit.io
.. _Julia: http://julialang.org
.. _pyuv: https://github.com/saghul/pyuv
.. _others: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv
.. _Node.js: https://nodejs.org
.. _Luvit: https://luvit.io
.. _Julia: https://julialang.org
.. _uvloop: https://github.com/MagicStack/uvloop
.. _others: https://github.com/libuv/libuv/blob/v1.x/LINKS.md
Features
@ -52,11 +52,11 @@ Documentation
Downloads
---------
libuv can be downloaded from `here <http://dist.libuv.org/dist/>`_.
libuv can be downloaded from `here <https://dist.libuv.org/dist/>`_.
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.
.. 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`.
@ -68,6 +81,18 @@ API
to suppress unnecessary wakeups when using a sampling profiler.
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)
Releases all internal loop resources. Call this function only when the loop
@ -107,6 +132,8 @@ API
or requests left), or non-zero if more callbacks are expected (meaning
you should run the event loop again sometime in the future).
:c:func:`uv_run` is not reentrant. It must not be called from a callback.
.. c:function:: int uv_loop_alive(const uv_loop_t* loop)
Returns non-zero if there are referenced active handles, active
@ -229,7 +256,7 @@ API
.. 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`.

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

@ -46,6 +46,12 @@ Data types
Replacement function for :man:`free(3)`.
See :c:func:`uv_replace_allocator`.
.. c:type:: void (*uv_random_cb)(uv_random_t* req, int status, void* buf, size_t buflen)
Callback passed to :c:func:`uv_random`. `status` is non-zero in case of
error. The `buf` pointer is the same pointer that was passed to
:c:func:`uv_random`.
.. c:type:: uv_file
Cross platform representation of a file handle.
@ -65,6 +71,51 @@ Data types
.. versionadded:: 1.16.0
.. c:type:: uv_timeval_t
Y2K38-unsafe data type for storing times with microsecond resolution.
Will be replaced with :c:type:`uv_timeval64_t` in libuv v2.0.
::
typedef struct {
long tv_sec;
long tv_usec;
} uv_timeval_t;
.. c:type:: uv_timeval64_t
Y2K38-safe data type for storing times with microsecond resolution.
::
typedef struct {
int64_t tv_sec;
int32_t tv_usec;
} 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
Data type for resource usage results.
@ -91,7 +142,10 @@ Data types
} uv_rusage_t;
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
@ -103,11 +157,11 @@ Data types
char* model;
int speed;
struct uv_cpu_times_s {
uint64_t user;
uint64_t nice;
uint64_t sys;
uint64_t idle;
uint64_t irq;
uint64_t user; /* milliseconds */
uint64_t nice; /* milliseconds */
uint64_t sys; /* milliseconds */
uint64_t idle; /* milliseconds */
uint64_t irq; /* milliseconds */
} cpu_times;
} uv_cpu_info_t;
@ -145,6 +199,45 @@ Data types
char* homedir;
} 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
Data type for operating system name and version information.
::
typedef struct uv_utsname_s {
char sysname[256];
char release[256];
char version[256];
char machine[256];
} uv_utsname_t;
.. c:type:: uv_env_item_t
Data type for environment variable storage.
::
typedef struct uv_env_item_s {
char* name;
char* value;
} uv_env_item_t;
.. c:type:: uv_random_t
Random data request type.
API
---
@ -156,7 +249,7 @@ API
type of the stdio streams.
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)
@ -170,14 +263,32 @@ API
after all resources have been freed and thus libuv doesn't reference
any allocated memory chunk.
On success, it returns 0, if any of the function pointers is NULL it
returns UV_EINVAL.
On success, it returns 0, if any of the function pointers is `NULL` it
returns `UV_EINVAL`.
.. warning:: There is no protection against changing the allocator multiple
times. If the user changes it they are responsible for making
sure the allocator is changed while no memory was allocated with
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)
Constructor for :c:type:`uv_buf_t`.
@ -188,34 +299,58 @@ API
.. 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
or the executable path. Libuv may take ownership of the memory that `argv`
points to. This function should be called exactly once, at program start-up.
Example:
::
argv = uv_setup_args(argc, argv); /* May return a copy of argv. */
.. 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`
before calling this function. If `buffer` is `NULL` or `size` is zero,
`UV_EINVAL` is returned. If `size` cannot accommodate the process title and
terminating `NULL` character, the function returns `UV_ENOBUFS`.
before calling this function on Unix and AIX systems. If `uv_setup_args`
has not been called on systems that require it, then `UV_ENOBUFS` is
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.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)
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
title the contents of `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`.
calling this function on Unix and AIX systems. If `uv_setup_args` has not
been called on systems that require it, then `UV_ENOBUFS` is returned. On
platforms with a fixed size buffer for the process title the contents of
`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.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)
Gets the resident set size (RSS) for the current process.
.. 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)
@ -225,6 +360,17 @@ API
On Windows not all fields are set, the unsupported fields are filled with zeroes.
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)
Returns the current process ID.
@ -237,15 +383,41 @@ API
.. 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)
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`.
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)
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)
Gets address information about the network interfaces on the system. An
@ -259,7 +431,7 @@ API
.. c:function:: void uv_loadavg(double avg[3])
Gets the load average. See: `<http://en.wikipedia.org/wiki/Load_(computing)>`_
Gets the load average. See: `<https://en.wikipedia.org/wiki/Load_(computing)>`_
.. note::
Returns [0,0,0] on Windows (i.e., it's not implemented).
@ -280,6 +452,10 @@ API
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_pton(int af, const char* src, void* dst)
@ -343,7 +519,8 @@ API
.. 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)
@ -412,20 +589,82 @@ API
.. 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)
Frees the `pwd` memory previously allocated with :c:func:`uv_os_get_passwd`.
.. versionadded:: 1.9.0
.. uint64_t uv_get_free_memory(void)
.. c:function:: uint64_t uv_get_free_memory(void)
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)
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)
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
is unknown, `0` is returned. If there is a constraining mechanism, but there
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::
This function currently only returns a non-zero value on Linux, based
on cgroups if it is present, and on z/OS based on RLIMIT_MEMLIMIT.
.. 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)
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
related to the time of day and therefore not subject to clock drift. The
primary use is for measuring performance between intervals.
@ -434,6 +673,19 @@ API
Not every platform can support nanosecond resolution; however, this value will always
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)
Prints all handles associated with the given `loop` to the given `stream`.
@ -472,6 +724,23 @@ API
.. versionadded:: 1.8.0
.. c:function:: int uv_os_environ(uv_env_item_t** envitems, int* count)
Retrieves all environment variables. This function will allocate memory
which must be freed by calling :c:func:`uv_os_free_environ`.
.. warning::
This function is not thread safe.
.. versionadded:: 1.31.0
.. c:function:: void uv_os_free_environ(uv_env_item_t* envitems, int count);
Frees the memory allocated for the environment variables by
:c:func:`uv_os_environ`.
.. versionadded:: 1.31.0
.. c:function:: int uv_os_getenv(const char* name, char* buffer, size_t* size)
Retrieves the environment variable specified by `name`, copies its value
@ -518,6 +787,10 @@ API
.. versionadded:: 1.12.0
.. versionchanged:: 1.26.0 `UV_MAXHOSTNAMESIZE` is available and represents
the maximum `buffer` size required to store a
hostname and terminating `nul` character.
.. c:function:: int uv_os_getpriority(uv_pid_t pid, int* priority)
Retrieves the scheduling priority of the process specified by `pid`. The
@ -544,4 +817,124 @@ API
process priority, the result will equal one of the `UV_PRIORITY`
constants, and not necessarily the exact value of `priority`.
.. note::
On Windows, setting `PRIORITY_HIGHEST` will only work for elevated user,
for others it will be silently reduced to `PRIORITY_HIGH`.
.. note::
On IBM i PASE, the highest process priority is -10. The constant
`UV_PRIORITY_HIGHEST` is -10, `UV_PRIORITY_HIGH` is -7,
`UV_PRIORITY_ABOVE_NORMAL` is -4, `UV_PRIORITY_NORMAL` is 0,
`UV_PRIORITY_BELOW_NORMAL` is 15 and `UV_PRIORITY_LOW` is 39.
.. note::
On IBM i PASE, you are not allowed to change your priority unless you
have the \*JOBCTL special authority (even to lower it).
.. versionadded:: 1.23.0
.. c:function:: int uv_os_uname(uv_utsname_t* buffer)
Retrieves system information in `buffer`. The populated data includes the
operating system name, release, version, and machine. On non-Windows
systems, `uv_os_uname()` is a thin wrapper around :man:`uname(2)`. Returns
zero on success, and a non-zero error value otherwise.
.. versionadded:: 1.25.0
.. c:function:: int uv_gettimeofday(uv_timeval64_t* tv)
Cross-platform implementation of :man:`gettimeofday(2)`. The timezone
argument to `gettimeofday()` is not supported, as it is considered obsolete.
.. versionadded:: 1.28.0
.. c:function:: int uv_random(uv_loop_t* loop, uv_random_t* req, void* buf, size_t buflen, unsigned int flags, uv_random_cb cb)
Fill `buf` with exactly `buflen` cryptographically strong random bytes
acquired from the system CSPRNG. `flags` is reserved for future extension
and must currently be 0.
Short reads are not possible. When less than `buflen` random bytes are
available, a non-zero error value is returned or passed to the callback.
The synchronous version may block indefinitely when not enough entropy
is available. The asynchronous version may not ever finish when the system
is low on entropy.
Sources of entropy:
- Windows: `RtlGenRandom <https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/nf-ntsecapi-rtlgenrandom>_`.
- Linux, Android: :man:`getrandom(2)` if available, or :man:`urandom(4)`
after reading from `/dev/random` once, or the `KERN_RANDOM`
:man:`sysctl(2)`.
- FreeBSD: `getrandom(2) <https://www.freebsd.org/cgi/man.cgi?query=getrandom&sektion=2>_`,
or `/dev/urandom` after reading from `/dev/random` once.
- NetBSD: `KERN_ARND` `sysctl(7) <https://man.netbsd.org/sysctl.7>_`
- macOS, OpenBSD: `getentropy(2) <https://man.openbsd.org/getentropy.2>_`
if available, or `/dev/urandom` after reading from `/dev/random` once.
- AIX: `/dev/random`.
- IBM i: `/dev/urandom`.
- Other UNIX: `/dev/urandom` after reading from `/dev/random` once.
:returns: 0 on success, or an error code < 0 on failure. The contents of
`buf` is undefined after an error.
.. note::
When using the synchronous version, both `loop` and `req` parameters
are not used and can be set to `NULL`.
.. versionadded:: 1.33.0
.. c:function:: void uv_sleep(unsigned int msec)
Causes the calling thread to sleep for `msec` milliseconds.
.. 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

@ -4,8 +4,8 @@
:c:type:`uv_pipe_t` --- Pipe handle
===================================
Pipe handles provide an abstraction over local domain sockets on Unix and named
pipes on Windows.
Pipe handles provide an abstraction over streaming files on Unix (including
local domain sockets, pipes, and FIFOs) and named pipes on Windows.
:c:type:`uv_pipe_t` is a 'subclass' of :c:type:`uv_stream_t`.
@ -24,6 +24,8 @@ Public members
.. c:member:: int uv_pipe_t.ipc
Whether this pipe is suitable for handle passing between processes.
Only a connected pipe that will be passing the handles should have this flag
set, not the listening pipe that uv_accept is called on.
.. seealso:: The :c:type:`uv_stream_t` members also apply.
@ -34,7 +36,10 @@ API
.. c:function:: int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc)
Initialize a pipe handle. The `ipc` argument is a boolean to indicate if
this pipe will be used for handle passing between processes.
this pipe will be used for handle passing between processes (which may
change the bytes on the wire). Only a connected pipe that will be
passing the handles should have this flag set, not the listening pipe
that uv_accept is called on.
.. c:function:: int uv_pipe_open(uv_pipe_t* handle, uv_file file)
@ -50,17 +55,61 @@ API
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::
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between
92 and 108 bytes.
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` 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)
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::
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between
92 and 108 bytes.
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` 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)
@ -113,3 +162,21 @@ API
function is blocking.
.. 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`.
.. c:type:: uv_poll_event
.. c:enum:: uv_poll_event
Poll event types
@ -86,36 +86,65 @@ API
.. 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
UV_READABLE, UV_WRITABLE, UV_PRIORITIZED and UV_DISCONNECT. As soon as an
event is detected the callback will be called with `status` set to 0, and the
detected events set on the `events` field.
`UV_READABLE`, `UV_WRITABLE`, `UV_PRIORITIZED` and `UV_DISCONNECT`. As soon
as an event is detected the callback will be called with `status` set to 0,
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
messages.
The `UV_PRIORITIZED` event is used to watch for sysfs interrupts or TCP
out-of-band messages.
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
path because an extra read or write call might be avoided.
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 path because an extra read or write call might be avoided.
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
anyway, the callback *may* be called reporting an error status, but this
is **not** guaranteed.
anyway, the callback *may* be called reporting an error status, but this is
**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::
Calling :c:func:`uv_poll_start` on a handle that is already active is fine. Doing so
will update the events mask that is being watched for.
Calling :c:func:`uv_poll_start` on a handle that is already active is
fine. Doing so will update the events mask that is being watched for.
.. note::
Though UV_DISCONNECT can be set, it is unsupported on AIX and as such will not be set
on the `events` field in the callback.
Though `UV_DISCONNECT` can be set, it is unsupported on AIX and as such
will not be set on the `events` field in the callback.
.. versionchanged:: 1.9.0 Added the UV_DISCONNECT event.
.. versionchanged:: 1.14.0 Added the UV_PRIORITIZED event.
.. note::
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)
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.

View File

@ -33,14 +33,22 @@ API
.. 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)
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)
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.

View File

@ -40,7 +40,7 @@ Data types
will indicate the exit status and the signal that caused the process to
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`.
@ -70,11 +70,29 @@ Data types
*/
UV_PROCESS_DETACHED = (1 << 3),
/*
* Hide the subprocess window that would normally be created. This option is
* only meaningful on Windows systems. On Unix it is silently ignored.
*/
UV_PROCESS_WINDOWS_HIDE = (1 << 4),
/*
* Hide the subprocess console window that would normally be created. This
* option is only meaningful on Windows systems. On Unix it is silently
* ignored.
*/
UV_PROCESS_WINDOWS_HIDE = (1 << 4)
UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5),
/*
* Hide the subprocess GUI window that would normally be created. This
* option is only meaningful on Windows systems. On Unix it is silently
* ignored.
*/
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
@ -91,72 +109,104 @@ Data types
} data;
} 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.
::
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,
/*
* 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,
/*
* The child process will be given a duplicate of the parent's
* file descriptor given by `data.fd`.
*/
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,
/*
* When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE
* determine the direction of flow, from the child process' perspective. Both
* flags may be specified to create a duplex data stream.
*/
UV_READABLE_PIPE = 0x10,
UV_WRITABLE_PIPE = 0x20
UV_WRITABLE_PIPE = 0x20,
/*
* Open the child pipe handle in overlapped mode on Windows.
* On Unix it is silently ignored.
*/
UV_OVERLAPPED_PIPE = 0x40
* When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the
* 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_NONBLOCK_PIPE = 0x40
} uv_stdio_flags;
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`.
.. note::
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.
.. c:member:: uv_process_options_t.file
.. c:member:: const char* uv_process_options_t.file
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
Windows this uses `CreateProcess` which concatenates the arguments into a
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.
.. c:member:: uv_process_options_t.cwd
.. c:member:: const char* uv_process_options_t.cwd
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
:c:type:`uv_process_flags`.
:c:enum:`uv_process_flags`.
.. c:member:: uv_process_options_t.stdio_count
.. c:member:: uv_process_options_t.stdio
.. c:member:: int uv_process_options_t.stdio_count
.. 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`
structs that describe the file descriptors that will be made available to
@ -167,8 +217,8 @@ Public members
On Windows file descriptors greater than 2 are available to the child process only if
the child processes uses the MSVCRT runtime.
.. c:member:: uv_process_options_t.uid
.. c:member:: uv_process_options_t.gid
.. c:member:: uv_uid_t uv_process_options_t.uid
.. c:member:: uv_gid_t uv_process_options_t.gid
Libuv can change the child process' user/group id. This happens only when
the appropriate bits are set in the flags fields.
@ -177,14 +227,13 @@ Public members
This is not supported on Windows, :c:func:`uv_spawn` will fail and set the error
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
:c:type:`uv_stdio_flags`.
Flags specifying how the stdio container should be passed to the child.
.. 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.
@ -217,6 +266,12 @@ API
setgid specified, or not having enough memory to allocate for the new
process.
.. versionchanged:: 1.24.0 Added `UV_PROCESS_WINDOWS_HIDE_CONSOLE` and
`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)
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.
.. c:enum:: 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
Indicated the type of request. Readonly.
The kind of the libuv request.
::
@ -50,10 +42,22 @@ Public members
} 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
---
.. 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
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.
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
currently supported.
:c:type:`uv_getnameinfo_t`, :c:type:`uv_random_t` and :c:type:`uv_work_t`
requests is currently supported.
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
@ -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_work_t`, :c:type:`uv_getaddrinfo_t` or c:type:`uv_getnameinfo_t`
request has its callback invoked with status == `UV_ECANCELED`.
* A :c:type:`uv_work_t`, :c:type:`uv_getaddrinfo_t`,
: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)
@ -94,7 +99,7 @@ API
.. 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`.

View File

@ -6,7 +6,10 @@
Signal handles implement Unix style signal handling on a per-event loop bases.
Reception of some signals is emulated on Windows:
Windows notes
-------------
Reception of some signals is emulated:
* SIGINT is normally delivered when the user presses CTRL+C. However, like
on Unix, it is not generated when terminal raw mode is enabled.
@ -17,19 +20,39 @@ Reception of some signals is emulated on Windows:
program is given approximately 10 seconds to perform cleanup. After that
Windows will unconditionally terminate it.
Watchers for other signals can be successfully created, but these signals
are never received. These signals are: `SIGILL`, `SIGABRT`, `SIGFPE`, `SIGSEGV`,
`SIGTERM` and `SIGKILL.`
* SIGWINCH is raised whenever libuv detects that the console has been
resized. When a libuv app is running under a console emulator, or when a
32-bit libuv app is running on 64-bit system, SIGWINCH will be emulated. In
such cases SIGWINCH signals may not always be delivered in a timely manner.
For a writable :c:type:`uv_tty_t` handle libuv will only detect size changes
when the cursor is moved. When a readable :c:type:`uv_tty_t` handle is used,
resizing of the console buffer will be detected only if the handle is in raw
mode and is being read.
Calls to raise() or abort() to programmatically raise a signal are
not detected by libuv; these will not trigger a signal watcher.
* Watchers for other signals can be successfully created, but these signals
are never received. These signals are: `SIGILL`, `SIGABRT`, `SIGFPE`, `SIGSEGV`,
`SIGTERM` and `SIGKILL.`
.. note::
On Linux SIGRT0 and SIGRT1 (signals 32 and 33) are used by the NPTL pthreads library to
manage threads. Installing watchers for those signals will lead to unpredictable behavior
and is strongly discouraged. Future versions of libuv may simply reject them.
* Calls to raise() or abort() to programmatically raise a signal are
not detected by libuv; these will not trigger a signal watcher.
.. versionchanged:: 1.15.0 SIGWINCH support on Windows was improved.
.. versionchanged:: 1.31.0 32-bit libuv SIGWINCH support on 64-bit Windows was
rolled back to old implementation.
Unix notes
----------
* SIGKILL and SIGSTOP are impossible to catch.
* Handling SIGBUS, SIGFPE, SIGILL or SIGSEGV via libuv results into undefined behavior.
* SIGABRT will not be caught by libuv if generated by `abort()`, e.g. through `assert()`.
* On Linux SIGRT0 and SIGRT1 (signals 32 and 33) are used by the NPTL pthreads library to
manage threads. Installing watchers for those signals will lead to unpredictable behavior
and is strongly discouraged. Future versions of libuv may simply reject them.
Data types
----------

View File

@ -18,7 +18,7 @@ from string import Template
def make_link_node(rawtext, app, name, manpage_num, options):
ref = app.config.man_url_regex
if not ref:
ref = "http://linux.die.net/man/%s/%s" % (manpage_num, name)
ref = "https://man7.org/linux/man-pages/man%s/%s.%s.html" %(manpage_num, name, manpage_num)
else:
s = Template(ref)
ref = s.substitute(num=manpage_num, topic=name)
@ -39,7 +39,6 @@ def man_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
def setup(app):
app.info('Initializing manpage plugin')
app.add_role('man', man_role)
app.add_config_value('man_url_regex', None, 'env')
return

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -45,13 +45,13 @@ Data types
`nread` might be 0, which does *not* indicate an error or EOF. This
is equivalent to ``EAGAIN`` or ``EWOULDBLOCK`` under ``read(2)``.
The callee is responsible for stopping closing the stream when an error happens
The callee is responsible for stopping/closing the stream when an error happens
by calling :c:func:`uv_read_stop` or :c:func:`uv_close`. Trying to read
from the stream again is undefined.
The callee is responsible for freeing the buffer, libuv does not reuse it.
The buffer may be a null buffer (where buf->base=NULL and buf->len=0) on
error.
The buffer may be a null buffer (where `buf->base` == NULL and `buf->len` == 0)
on error.
.. c:type:: void (*uv_write_cb)(uv_write_t* req, int status)
@ -139,6 +139,11 @@ API
be made several times until there is no more data to read or
: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*)
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 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)
Write data to stream. Buffers are written in order. Example:
@ -183,8 +193,9 @@ API
initialized with `ipc` == 1.
.. note::
`send_handle` must be a TCP socket or pipe, which is a server or a connection (listening
or connected state). Bound sockets or pipes will be assumed to be servers.
`send_handle` must be a TCP, pipe and UDP handle on Unix, or a TCP
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)
@ -197,6 +208,16 @@ API
* < 0: negative error code (``UV_EAGAIN`` is returned if no data can be sent
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)
Returns 1 if the stream is readable, 0 otherwise.

View File

@ -16,6 +16,28 @@ Data types
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
^^^^^^^^^^^^^^
@ -60,6 +82,15 @@ API
Enable / disable TCP keep-alive. `delay` is the initial delay in seconds,
ignored when `enable` is zero.
After `delay` has been reached, 10 successive probes, each spaced 1 second
from the previous one, will still happen. If the connection is still lost
at the end of this procedure, then the handle is destroyed with a
``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)
Enable / disable simultaneous asynchronous accept requests that are
@ -72,27 +103,44 @@ API
.. 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
initialized ``struct sockaddr_in`` or ``struct sockaddr_in6``.
Bind the handle to an address and port.
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
:c:func:`uv_tcp_connect`. That is, a successful call to this function does
not guarantee that the call to :c:func:`uv_listen` or :c:func:`uv_tcp_connect`
will succeed as well.
error from :c:func:`uv_listen` or :c:func:`uv_tcp_connect` unless you specify
``UV_TCP_REUSEPORT`` in `flags` for all the binding sockets. That is, a successful
call to this function does not guarantee that the call to :c:func:`uv_listen` or
:c:func:`uv_tcp_connect` will succeed as well.
`flags` can contain ``UV_TCP_IPV6ONLY``, in which case dual-stack support
is disabled and only IPv6 is used.
:param handle: TCP handle. It should have been initialized with :c:func:`uv_tcp_init`.
: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)
Get the current address to which the handle is bound. `addr` must point to
Get the current address to which the handle is bound. `name` must point to
a valid and big enough chunk of memory, ``struct sockaddr_storage`` is
recommended for IPv4 and IPv6 support.
.. c:function:: int uv_tcp_getpeername(const uv_tcp_t* handle, struct sockaddr* name, int* namelen)
Get the address of the peer connected to the handle. `addr` must point to
Get the address of the peer connected to the handle. `name` must point to
a valid and big enough chunk of memory, ``struct sockaddr_storage`` is
recommended for IPv4 and IPv6 support.
@ -113,3 +161,30 @@ API
mapping
.. seealso:: The :c:type:`uv_stream_t` API functions also apply.
.. c:function:: int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb)
Resets a TCP connection by sending a RST packet. This is accomplished by
setting the `SO_LINGER` socket option with a linger interval of zero and
then calling :c:func:`uv_close`.
Due to some platform inconsistencies, mixing of :c:func:`uv_shutdown` and
:c:func:`uv_tcp_close_reset` calls is not allowed.
.. 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

@ -55,14 +55,130 @@ API
Threads
^^^^^^^
.. c:type:: uv_thread_options_t
Options for spawning a new thread (passed to :c:func:`uv_thread_create_ex`).
::
typedef struct uv_thread_options_s {
enum {
UV_THREAD_NO_FLAGS = 0x00,
UV_THREAD_HAS_STACK_SIZE = 0x01
} flags;
size_t stack_size;
} uv_thread_options_t;
More fields may be added to this struct at any time, so its exact
layout and size should not be relied upon.
.. versionadded:: 1.26.0
.. c:function:: int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg)
.. 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)
Like :c:func:`uv_thread_create`, but additionally specifies options for creating a new thread.
If `UV_THREAD_HAS_STACK_SIZE` is set, `stack_size` specifies a stack size for the new thread.
`0` indicates that the default value should be used, i.e. behaves as if the flag was not set.
Other values will be rounded up to the nearest page boundary.
.. 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:: 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_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
^^^^^^^^^^^^^^^^^^^^

View File

@ -10,7 +10,14 @@ operations, as well as getaddrinfo and getnameinfo requests.
Its default size is 4, but it can be changed at startup time by setting the
``UV_THREADPOOL_SIZE`` environment variable to any value (the absolute maximum
is 128).
is 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
function makes use of the threadpool (i.e. when using :c:func:`uv_queue_work`)

View File

@ -6,6 +6,15 @@
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
----------
@ -64,11 +73,6 @@ API
duration, and will follow normal timer semantics in the case of a
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::
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,
@ -78,4 +82,11 @@ API
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.

View File

@ -16,7 +16,7 @@ Data types
TTY handle type.
.. c:type:: uv_tty_mode_t
.. c:enum:: uv_tty_mode_t
.. versionadded:: 1.2.0
@ -27,12 +27,35 @@ Data types
typedef enum {
/* Initial/normal terminal mode */
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,
/* 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;
.. c:enum:: uv_tty_vtermstate_t
Console virtual terminal mode type:
::
typedef enum {
/*
* The console supports handling of virtual terminal sequences
* (Windows10 new console, ConEmu)
*/
UV_TTY_SUPPORTED,
/* The console cannot process virtual terminal sequences. (Legacy
* console)
*/
UV_TTY_UNSUPPORTED
} uv_tty_vtermstate_t
Public members
@ -46,7 +69,7 @@ N/A
API
---
.. c:function:: int uv_tty_init(uv_loop_t* loop, uv_tty_t* handle, uv_file fd, int readable)
.. c:function:: int uv_tty_init(uv_loop_t* loop, uv_tty_t* handle, uv_file fd, int unused)
Initialize a new TTY stream with the given file descriptor. Usually the
file descriptor will be:
@ -55,9 +78,6 @@ API
* 1 = stdout
* 2 = stderr
`readable`, specifies if you plan on calling :c:func:`uv_read_start` with
this stream. stdin is readable, stdout is not.
On Unix this function will determine the path of the fd of the terminal
using :man:`ttyname_r(3)`, open it, and use it if the passed file descriptor
refers to a TTY. This lets libuv put the tty in non-blocking mode without
@ -67,8 +87,10 @@ API
ioctl TIOCGPTN or TIOCPTYGNAME, for instance OpenBSD and Solaris.
.. note::
If reopening the TTY fails, libuv falls back to blocking writes for
non-readable TTY streams.
If reopening the TTY fails, libuv falls back to blocking writes.
.. versionchanged:: 1.23.1: the `readable` parameter is now unused and ignored.
The correct value will now be auto-detected from the kernel.
.. versionchanged:: 1.9.0: the path of the TTY is determined by
:man:`ttyname_r(3)`. In earlier versions libuv opened
@ -81,7 +103,7 @@ API
.. 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
:c:type:`uv_tty_mode_t` value.
:c:enum:`uv_tty_mode_t` value.
Set the TTY using the specified terminal mode.
@ -99,3 +121,25 @@ API
Gets the current Window size. On success it returns 0.
.. seealso:: The :c:type:`uv_stream_t` API functions also apply.
.. c:function:: void uv_tty_set_vterm_state(uv_tty_vtermstate_t state)
Controls whether console virtual terminal sequences are processed by libuv
or console.
Useful in particular for enabling ConEmu support of ANSI X3.64 and Xterm
256 colors. Otherwise Windows10 consoles are usually detected automatically.
This function is only meaningful on Windows systems. On Unix it is silently
ignored.
.. versionadded:: 1.33.0
.. c:function:: int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state)
Get the current state of whether console virtual terminal sequences are
handled by libuv or the console.
This function is not implemented on Unix, where it returns ``UV_ENOTSUP``.
.. versionadded:: 1.33.0

View File

@ -18,7 +18,7 @@ Data types
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`..
@ -28,20 +28,57 @@ Data types
/* Disables dual stack mode. */
UV_UDP_IPV6ONLY = 1,
/*
* Indicates message was truncated because read buffer was too small. The
* remainder was discarded by the OS. Used in uv_udp_recv_cb.
*/
* Indicates message was truncated because read buffer was too small. The
* remainder was discarded by the OS. Used in uv_udp_recv_cb.
*/
UV_UDP_PARTIAL = 2,
/*
* Indicates if SO_REUSEADDR will be set when binding the handle in
* uv_udp_bind.
* This sets the SO_REUSEPORT socket flag on the BSDs and OS X. 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.
*/
UV_UDP_REUSEADDR = 4
* Indicates if SO_REUSEADDR will be set when binding the handle.
* This sets the SO_REUSEPORT socket flag on the BSDs (except for
* DragonFlyBSD), OS X, and other platforms where SO_REUSEPORTs don't
* have the capability of load balancing, as the opposite of what
* 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.
*/
UV_UDP_REUSEADDR = 4,
/*
* Indicates that the message was received by recvmmsg, so the buffer provided
* must not be freed by the recv_cb callback.
*/
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)
@ -56,22 +93,34 @@ Data types
* `handle`: UDP handle
* `nread`: Number of bytes that have been received.
0 if there is no more data to read. You may discard or repurpose
the read buffer. Note that 0 may also mean that an empty datagram
was received (in this case `addr` is not NULL). < 0 if a transmission
error was detected.
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
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.
* `addr`: ``struct sockaddr*`` containing the address of the sender.
Can be NULL. Valid for the duration of the callback only.
* `flags`: One or more or'ed UV_UDP_* constants. Right now only
``UV_UDP_PARTIAL`` is used.
* `flags`: One or more or'ed UV_UDP_* constants.
The callee is responsible for freeing the buffer, libuv does not reuse it.
The buffer may be a null buffer (where `buf->base` == NULL and `buf->len` == 0)
on error.
When using :man:`recvmmsg(2)`, chunks will have the `UV_UDP_MMSG_CHUNK` flag set,
those must not be freed. If no errors occur, there will be a final callback with
`nread` set to 0, `addr` set to NULL and the buffer pointing at the initially
allocated data with the `UV_UDP_MMSG_CHUNK` flag cleared and the `UV_UDP_MMSG_FREE`
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::
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
received.
.. c:type:: uv_membership
.. c:enum:: uv_membership
Membership type for a multicast address.
@ -112,12 +161,17 @@ API
.. 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
of the `flags` parameter are used as the socket domain. A socket will be created
for the given domain. If the specified domain is ``AF_UNSPEC`` no socket is created,
just like :c:func:`uv_udp_init`.
Initialize the handle with the specified flags. The lower 8 bits of the `flags`
parameter are used as the socket domain. A socket will be created for the given domain.
If the specified domain is ``AF_UNSPEC`` no socket is created, 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
.. 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)
@ -146,10 +200,62 @@ API
with the address and port to bind to.
: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.
.. 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)
Associate the UDP handle to a remote address and port, so every
message sent by this handle is automatically sent to that destination.
Calling this function with a `NULL` `addr` disconnects the handle.
Trying to call `uv_udp_connect()` on an already connected handle will result
in an `UV_EISCONN` error. Trying to disconnect a handle that is not
connected will return an `UV_ENOTCONN` error.
:param handle: UDP handle. Should have been initialized with
:c:func:`uv_udp_init`.
:param addr: `struct sockaddr_in` or `struct sockaddr_in6`
with the address and port to associate to.
:returns: 0 on success, or an error code < 0 on failure.
.. versionadded:: 1.27.0
.. c:function:: int uv_udp_getpeername(const uv_udp_t* handle, struct sockaddr* name, int* namelen)
Get the remote IP and port of the UDP handle on connected UDP handles.
On unconnected handles, it returns `UV_ENOTCONN`.
:param handle: UDP handle. Should have been initialized with
:c:func:`uv_udp_init` and bound.
:param name: Pointer to the structure to be filled with the address data.
In order to support IPv4 and IPv6 `struct sockaddr_storage` should be
used.
:param namelen: On input it indicates the data of the `name` field. On
output it indicates how much of it was filled.
:returns: 0 on success, or an error code < 0 on failure
.. versionadded:: 1.27.0
.. c:function:: int uv_udp_getsockname(const uv_udp_t* handle, struct sockaddr* name, int* namelen)
Get the local IP and port of the UDP handle.
@ -181,13 +287,34 @@ API
:returns: 0 on success, or an error code < 0 on failure.
.. c:function:: int uv_udp_set_source_membership(uv_udp_t* handle, const char* multicast_addr, const char* interface_addr, const char* source_addr, uv_membership membership)
Set membership for a source-specific multicast group.
:param handle: UDP handle. Should have been initialized with
:c:func:`uv_udp_init`.
:param multicast_addr: Multicast address to set membership for.
:param interface_addr: Interface address.
:param source_addr: Source address.
:param membership: Should be ``UV_JOIN_GROUP`` or ``UV_LEAVE_GROUP``.
:returns: 0 on success, or an error code < 0 on failure.
.. versionadded:: 1.32.0
.. c:function:: int uv_udp_set_multicast_loop(uv_udp_t* handle, int on)
Set IP multicast loop flag. Makes multicast packets loop back to
local sockets.
: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.
@ -198,7 +325,9 @@ API
Set the multicast ttl.
: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.
@ -209,7 +338,9 @@ API
Set the multicast interface to send or receive data on.
: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.
@ -220,7 +351,9 @@ API
Set broadcast on or off.
: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.
@ -231,7 +364,9 @@ API
Set the time to live.
: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.
@ -247,6 +382,12 @@ API
(``0.0.0.0`` or ``::``) it will be changed to point to ``localhost``.
This is done to match the behavior of Linux systems.
For connected UDP handles, `addr` must be set to `NULL`, otherwise it will
return `UV_EISCONN` error.
For connectionless UDP handles, `addr` cannot be `NULL`, otherwise it will
return `UV_EDESTADDRREQ` error.
:param req: UDP request handle. Need not be initialized.
:param handle: UDP handle. Should have been initialized with
@ -266,15 +407,39 @@ API
.. versionchanged:: 1.19.0 added ``0.0.0.0`` and ``::`` to ``localhost``
mapping
.. versionchanged:: 1.27.0 added support for connected sockets
.. c:function:: int uv_udp_try_send(uv_udp_t* handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr* addr)
Same as :c:func:`uv_udp_send`, but won't queue a send request if it can't
be completed immediately.
For connected UDP handles, `addr` must be set to `NULL`, otherwise it will
return `UV_EISCONN` error.
For connectionless UDP handles, `addr` cannot be `NULL`, otherwise it will
return `UV_EDESTADDRREQ` error.
:returns: >= 0: number of bytes sent (it matches the given buffer size).
< 0: negative error code (``UV_EAGAIN`` is returned when the message
can't be sent immediately).
.. 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)
Prepare for receiving data. If the socket has not previously been bound
@ -290,6 +455,28 @@ API
: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).
The use of this feature requires a buffer larger than
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)
Stop listening for incoming datagrams.

View File

@ -10,7 +10,7 @@ a major release. In this section you'll find all macros and functions that
will allow you to write or compile code conditionally, in order to work with
multiple libuv versions.
.. _semantic versioning: http://semver.org
.. _semantic versioning: https://semver.org
Macros

View File

@ -1,73 +0,0 @@
#!/usr/bin/env python
import os
import platform
import sys
try:
import multiprocessing.synchronize
gyp_parallel_support = True
except ImportError:
gyp_parallel_support = False
CC = os.environ.get('CC', 'cc')
script_dir = os.path.dirname(__file__)
uv_root = os.path.normpath(script_dir)
output_dir = os.path.join(os.path.abspath(uv_root), 'out')
sys.path.insert(0, os.path.join(uv_root, 'build', 'gyp', 'pylib'))
try:
import gyp
except ImportError:
print('You need to install gyp in build/gyp first. See the README.')
sys.exit(42)
def host_arch():
machine = platform.machine()
if machine == 'i386': return 'ia32'
if machine == 'AMD64': return 'x64'
if machine == 'x86_64': return 'x64'
if machine.startswith('arm'): return 'arm'
if machine.startswith('mips'): return 'mips'
return machine # Return as-is and hope for the best.
def run_gyp(args):
rc = gyp.main(args)
if rc != 0:
print('Error running GYP')
sys.exit(rc)
if __name__ == '__main__':
args = sys.argv[1:]
args.extend('-I common.gypi test/test.gyp'.split(' '))
args.append('--depth=' + uv_root)
# There's a bug with windows which doesn't allow this feature.
if sys.platform != 'win32':
if '-f' not in args:
args.extend('-f make'.split())
if 'eclipse' not in args and 'ninja' not in args:
args.extend(['-Goutput_dir=' + output_dir])
args.extend(['--generator-output', output_dir])
if not any(a.startswith('-Dhost_arch=') for a in args):
args.append('-Dhost_arch=%s' % host_arch())
if not any(a.startswith('-Dtarget_arch=') for a in args):
args.append('-Dtarget_arch=%s' % host_arch())
if not any(a.startswith('-Duv_library=') for a in args):
args.append('-Duv_library=static_library')
# Some platforms (OpenBSD for example) don't have multiprocessing.synchronize
# so gyp must be run with --no-parallel
if not gyp_parallel_support:
args.append('--no-parallel')
gyp_args = list(args)
print(gyp_args)
run_gyp(gyp_args)

View File

@ -27,6 +27,11 @@
extern "C" {
#endif
#if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED)
#error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both."
#endif
#ifndef UV_EXTERN
#ifdef _WIN32
/* Windows - set up dll import/export decorators. */
# if defined(BUILDING_UV_SHARED)
@ -41,20 +46,25 @@ extern "C" {
# endif
#elif __GNUC__ >= 4
# define UV_EXTERN __attribute__((visibility("default")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) /* Sun Studio >= 8 */
# define UV_EXTERN __global
#else
# define UV_EXTERN /* nothing */
#endif
#endif /* UV_EXTERN */
#include "uv/errno.h"
#include "uv/version.h"
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
# include "uv/stdint-msvc2008.h"
#else
# include <stdint.h>
#endif
/* Internal type, do not use. */
struct uv__queue {
struct uv__queue* next;
struct uv__queue* prev;
};
#if defined(_WIN32)
# include "uv/win.h"
@ -122,6 +132,7 @@ extern "C" {
XX(ENOTEMPTY, "directory not empty") \
XX(ENOTSOCK, "socket operation on non-socket") \
XX(ENOTSUP, "operation not supported on socket") \
XX(EOVERFLOW, "value too large for defined data type") \
XX(EPERM, "operation not permitted") \
XX(EPIPE, "broken pipe") \
XX(EPROTO, "protocol error") \
@ -143,6 +154,11 @@ extern "C" {
XX(EREMOTEIO, "remote I/O error") \
XX(ENOTTY, "inappropriate ioctl for device") \
XX(EFTYPE, "inappropriate file type or format") \
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) \
XX(ASYNC, async) \
@ -172,6 +188,7 @@ extern "C" {
XX(WORK, work) \
XX(GETADDRINFO, getaddrinfo) \
XX(GETNAMEINFO, getnameinfo) \
XX(RANDOM, random) \
typedef enum {
#define XX(code, _) UV_ ## code = UV__ ## code,
@ -202,6 +219,7 @@ typedef enum {
/* Handle types. */
typedef struct uv_loop_s uv_loop_t;
typedef struct uv_handle_s uv_handle_t;
typedef struct uv_dir_s uv_dir_t;
typedef struct uv_stream_s uv_stream_t;
typedef struct uv_tcp_s uv_tcp_t;
typedef struct uv_udp_s uv_udp_t;
@ -228,15 +246,25 @@ typedef struct uv_connect_s uv_connect_t;
typedef struct uv_udp_send_s uv_udp_send_t;
typedef struct uv_fs_s uv_fs_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_group_s uv_group_t;
typedef struct uv_utsname_s uv_utsname_t;
typedef struct uv_statfs_s uv_statfs_t;
typedef struct uv_metrics_s uv_metrics_t;
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;
typedef enum {
@ -254,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_free_func)(void* ptr);
UV_EXTERN void uv_library_shutdown(void);
UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func,
uv_realloc_func realloc_func,
uv_calloc_func calloc_func,
@ -264,13 +294,13 @@ UV_EXTERN int uv_loop_init(uv_loop_t* loop);
UV_EXTERN int uv_loop_close(uv_loop_t* loop);
/*
* 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.
*/
UV_EXTERN uv_loop_t* uv_loop_new(void);
/*
* 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_EXTERN void uv_loop_delete(uv_loop_t*);
@ -321,12 +351,37 @@ typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req,
int status,
const char* hostname,
const char* service);
typedef void (*uv_random_cb)(uv_random_t* req,
int status,
void* buf,
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 {
long tv_sec;
long tv_nsec;
} 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 {
uint64_t st_dev;
@ -415,7 +470,7 @@ struct uv_shutdown_s {
uv_handle_type type; \
/* private */ \
uv_close_cb close_cb; \
void* handle_queue[2]; \
struct uv__queue handle_queue; \
union { \
int fd; \
void* reserved[4]; \
@ -457,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 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 \
/* number of bytes queued for writing */ \
@ -502,6 +563,10 @@ UV_EXTERN int uv_write2(uv_write_t* req,
UV_EXTERN int uv_try_write(uv_stream_t* handle,
const uv_buf_t bufs[],
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. */
struct uv_write_s {
@ -543,7 +608,18 @@ UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable);
enum uv_tcp_flags {
/* 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,
@ -555,6 +631,7 @@ UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle,
UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle,
struct sockaddr* name,
int* namelen);
UV_EXTERN int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb);
UV_EXTERN int uv_tcp_connect(uv_connect_t* req,
uv_tcp_t* handle,
const struct sockaddr* addr,
@ -583,13 +660,51 @@ enum uv_udp_flags {
UV_UDP_PARTIAL = 2,
/*
* 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
* 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
* This sets the SO_REUSEPORT socket flag on the BSDs (except for
* DragonFlyBSD), OS X, and other platforms where SO_REUSEPORTs don't
* have the capability of load balancing, as the opposite of what
* 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.
*/
UV_UDP_REUSEADDR = 4
UV_UDP_REUSEADDR = 4,
/*
* Indicates that the message was received by recvmmsg, so the buffer provided
* must not be freed by the recv_cb callback.
*/
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);
@ -629,7 +744,11 @@ UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock);
UV_EXTERN int uv_udp_bind(uv_udp_t* handle,
const struct sockaddr* addr,
unsigned int flags);
UV_EXTERN int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr);
UV_EXTERN int uv_udp_getpeername(const uv_udp_t* handle,
struct sockaddr* name,
int* namelen);
UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle,
struct sockaddr* name,
int* namelen);
@ -637,6 +756,11 @@ UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
const char* multicast_addr,
const char* interface_addr,
uv_membership membership);
UV_EXTERN int uv_udp_set_source_membership(uv_udp_t* handle,
const char* multicast_addr,
const char* interface_addr,
const char* source_addr,
uv_membership membership);
UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on);
UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle,
@ -653,9 +777,16 @@ UV_EXTERN int uv_udp_try_send(uv_udp_t* handle,
const uv_buf_t bufs[],
unsigned int nbufs,
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_alloc_cb alloc_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 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);
@ -675,16 +806,36 @@ struct uv_tty_s {
typedef enum {
/* Initial/normal terminal mode */
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,
/* 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;
typedef enum {
/*
* The console supports handling of virtual terminal sequences
* (Windows10 new console, ConEmu)
*/
UV_TTY_SUPPORTED,
/* The console cannot process the virtual terminal sequence. (Legacy
* console)
*/
UV_TTY_UNSUPPORTED
} uv_tty_vtermstate_t;
UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable);
UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode);
UV_EXTERN int uv_tty_reset_mode(void);
UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state);
UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state);
#ifdef __cplusplus
extern "C++" {
@ -698,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);
enum {
UV_PIPE_NO_TRUNCATE = 1u << 0
};
/*
* uv_pipe_t is a subclass of uv_stream_t.
*
@ -714,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_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_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_pipe_t* handle,
const char* name,
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,
char* buffer,
size_t* size);
@ -811,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 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_due_in(const uv_timer_t* handle);
/*
@ -872,10 +1038,13 @@ typedef enum {
UV_WRITABLE_PIPE = 0x20,
/*
* Open the child pipe handle in overlapped mode on Windows.
* On Unix it is silently ignored.
* When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the
* 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;
typedef struct uv_stdio_container_s {
@ -962,12 +1131,30 @@ enum uv_process_flags {
* the child's process handle.
*/
UV_PROCESS_DETACHED = (1 << 3),
/*
* Hide the subprocess window that would normally be created. This option is
* only meaningful on Windows systems. On Unix it is silently ignored.
*/
UV_PROCESS_WINDOWS_HIDE = (1 << 4),
/*
* Hide the subprocess console window that would normally be created. This
* option is only meaningful on Windows systems. On Unix it is silently
* ignored.
*/
UV_PROCESS_WINDOWS_HIDE = (1 << 4)
UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5),
/*
* Hide the subprocess GUI window that would normally be created. This
* option is only meaningful on Windows systems. On Unix it is silently
* ignored.
*/
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)
};
/*
@ -1008,11 +1195,11 @@ UV_EXTERN int uv_cancel(uv_req_t* req);
struct uv_cpu_times_s {
uint64_t user;
uint64_t nice;
uint64_t sys;
uint64_t idle;
uint64_t irq;
uint64_t user; /* milliseconds */
uint64_t nice; /* milliseconds */
uint64_t sys; /* milliseconds */
uint64_t idle; /* milliseconds */
uint64_t irq; /* milliseconds */
};
struct uv_cpu_info_s {
@ -1037,12 +1224,39 @@ struct uv_interface_address_s {
struct uv_passwd_s {
char* username;
long uid;
long gid;
unsigned long uid;
unsigned long gid;
char* shell;
char* homedir;
};
struct uv_group_s {
char* groupname;
unsigned long gid;
char** members;
};
struct uv_utsname_s {
char sysname[256];
char release[256];
char version[256];
char machine[256];
/* This struct does not contain the nodename and domainname fields present in
the utsname type. domainname is a GNU extension. Both fields are referred
to as meaningless in the docs. */
};
struct uv_statfs_s {
uint64_t f_type;
uint64_t f_bsize;
uint64_t f_blocks;
uint64_t f_bfree;
uint64_t f_bavail;
uint64_t f_files;
uint64_t f_ffree;
uint64_t f_spare[4];
};
typedef enum {
UV_DIRENT_UNKNOWN,
UV_DIRENT_FILE,
@ -1067,11 +1281,6 @@ UV_EXTERN int uv_uptime(double* uptime);
UV_EXTERN uv_os_fd_t uv_get_osfhandle(int 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 {
uv_timeval_t ru_utime; /* user CPU time used */
uv_timeval_t ru_stime; /* system CPU time used */
@ -1092,38 +1301,95 @@ typedef struct {
} uv_rusage_t;
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_tmpdir(char* buffer, size_t* size);
UV_EXTERN int uv_os_get_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_getppid(void);
#define UV_PRIORITY_LOW 19
#define UV_PRIORITY_BELOW_NORMAL 10
#define UV_PRIORITY_NORMAL 0
#define UV_PRIORITY_ABOVE_NORMAL -7
#define UV_PRIORITY_HIGH -14
#define UV_PRIORITY_HIGHEST -20
#if defined(__PASE__)
/* On IBM i PASE, the highest process priority is -10 */
# define UV_PRIORITY_LOW 39 /* RUNPTY(99) */
# define UV_PRIORITY_BELOW_NORMAL 15 /* RUNPTY(50) */
# define UV_PRIORITY_NORMAL 0 /* RUNPTY(20) */
# define UV_PRIORITY_ABOVE_NORMAL -4 /* RUNTY(12) */
# define UV_PRIORITY_HIGH -7 /* RUNPTY(6) */
# define UV_PRIORITY_HIGHEST -10 /* RUNPTY(1) */
#else
# define UV_PRIORITY_LOW 19
# define UV_PRIORITY_BELOW_NORMAL 10
# define UV_PRIORITY_NORMAL 0
# define UV_PRIORITY_ABOVE_NORMAL -7
# define UV_PRIORITY_HIGH -14
# define UV_PRIORITY_HIGHEST -20
#endif
UV_EXTERN int uv_os_getpriority(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 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,
int* count);
UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses,
int count);
struct uv_env_item_s {
char* name;
char* value;
};
UV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count);
UV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count);
UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size);
UV_EXTERN int uv_os_setenv(const char* name, const char* value);
UV_EXTERN int uv_os_unsetenv(const char* name);
#ifdef MAXHOSTNAMELEN
# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
#else
/*
Fallback for the maximum hostname size, including the null terminator. The
Windows gethostname() documentation states that 256 bytes will always be
large enough to hold the null-terminated hostname.
*/
# define UV_MAXHOSTNAMESIZE 256
#endif
UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size);
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 {
UV_FS_UNKNOWN = -1,
@ -1157,9 +1423,22 @@ typedef enum {
UV_FS_FCHOWN,
UV_FS_REALPATH,
UV_FS_COPYFILE,
UV_FS_LCHOWN
UV_FS_LCHOWN,
UV_FS_OPENDIR,
UV_FS_READDIR,
UV_FS_CLOSEDIR,
UV_FS_STATFS,
UV_FS_MKSTEMP,
UV_FS_LUTIME
} uv_fs_type;
struct uv_dir_s {
uv_dirent_t* dirents;
size_t nentries;
void* reserved[4];
UV_DIR_PRIVATE_FIELDS
};
/* uv_fs_t is a subclass of uv_req_t. */
struct uv_fs_s {
UV_REQ_FIELDS
@ -1175,6 +1454,7 @@ struct uv_fs_s {
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 int uv_fs_get_system_error(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 uv_stat_t* uv_fs_get_statbuf(uv_fs_t*);
@ -1241,6 +1521,10 @@ UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop,
uv_fs_t* req,
const char* tpl,
uv_fs_cb cb);
UV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop,
uv_fs_t* req,
const char* tpl,
uv_fs_cb cb);
UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
@ -1252,6 +1536,18 @@ UV_EXTERN int uv_fs_scandir(uv_loop_t* loop,
uv_fs_cb cb);
UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req,
uv_dirent_t* ent);
UV_EXTERN int uv_fs_opendir(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
uv_fs_cb cb);
UV_EXTERN int uv_fs_readdir(uv_loop_t* loop,
uv_fs_t* req,
uv_dir_t* dir,
uv_fs_cb cb);
UV_EXTERN int uv_fs_closedir(uv_loop_t* loop,
uv_fs_t* req,
uv_dir_t* dir,
uv_fs_cb cb);
UV_EXTERN int uv_fs_stat(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
@ -1295,6 +1591,8 @@ UV_EXTERN int uv_fs_chmod(uv_loop_t* loop,
const char* path,
int mode,
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_fs_t* req,
const char* path,
@ -1307,6 +1605,12 @@ UV_EXTERN int uv_fs_futime(uv_loop_t* loop,
double atime,
double mtime,
uv_fs_cb cb);
UV_EXTERN int uv_fs_lutime(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
double atime,
double mtime,
uv_fs_cb cb);
UV_EXTERN int uv_fs_lstat(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
@ -1366,6 +1670,10 @@ UV_EXTERN int uv_fs_lchown(uv_loop_t* loop,
uv_uid_t uid,
uv_gid_t gid,
uv_fs_cb cb);
UV_EXTERN int uv_fs_statfs(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
uv_fs_cb cb);
enum uv_fs_event {
@ -1467,10 +1775,31 @@ 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_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_pton(int af, const char* src, void* dst);
struct uv_random_s {
UV_REQ_FIELDS
/* read-only */
uv_loop_t* loop;
/* private */
int status;
void* buf;
size_t buflen;
uv_random_cb cb;
struct uv__work work_req;
};
UV_EXTERN int uv_random(uv_loop_t* loop,
uv_random_t* req,
void *buf,
size_t buflen,
unsigned flags, /* For future extension; must be 0. */
uv_random_cb cb);
#if defined(IF_NAMESIZE)
# define UV_IF_NAMESIZE (IF_NAMESIZE + 1)
#elif defined(IFNAMSIZ)
@ -1494,8 +1823,12 @@ UV_EXTERN int uv_chdir(const char* dir);
UV_EXTERN uint64_t uv_get_free_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_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 void uv_sleep(unsigned int msec);
UV_EXTERN void uv_disable_stdio_inheritance(void);
@ -1547,12 +1880,44 @@ UV_EXTERN void uv_key_delete(uv_key_t* key);
UV_EXTERN void* uv_key_get(uv_key_t* key);
UV_EXTERN void uv_key_set(uv_key_t* key, void* value);
UV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv);
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_detach(uv_thread_t* tid);
typedef enum {
UV_THREAD_NO_FLAGS = 0x00,
UV_THREAD_HAS_STACK_SIZE = 0x01
} uv_thread_create_flags;
struct uv_thread_options_s {
unsigned int flags;
size_t stack_size;
/* More fields may be added at any time. */
};
typedef struct uv_thread_options_s uv_thread_options_t;
UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid,
const uv_thread_options_t* params,
uv_thread_cb entry,
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 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_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. */
#define XX(_, name) uv_ ## name ## _t name;
@ -1571,11 +1936,13 @@ struct uv_loop_s {
void* data;
/* Loop reference counting. */
unsigned int active_handles;
void* handle_queue[2];
struct uv__queue handle_queue;
union {
void* unused[2];
void* unused;
unsigned int count;
} active_reqs;
/* Internal storage for future extensions. */
void* internal_fields;
/* Internal flag to signal loop stop. */
unsigned int stop_flag;
UV_LOOP_PRIVATE_FIELDS
@ -1584,6 +1951,18 @@ struct uv_loop_s {
UV_EXTERN void* uv_loop_get_data(const uv_loop_t*);
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. */
#undef UV_HANDLE_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; \
uv_mutex_t cf_mutex; \
uv_sem_t cf_sem; \
void* cf_signals[2]; \
struct uv__queue cf_signals; \
#define UV_PLATFORM_FS_EVENT_FIELDS \
uv__io_t event_watcher; \
@ -48,8 +48,8 @@
int realpath_len; \
int cf_flags; \
uv_async_t* cf_cb; \
void* cf_events[2]; \
void* cf_member[2]; \
struct uv__queue cf_events; \
struct uv__queue cf_member; \
int cf_error; \
uv_mutex_t cf_mutex; \

View File

@ -317,7 +317,7 @@
#if defined(EPROTO) && !defined(_WIN32)
# define UV__EPROTO UV__ERR(EPROTO)
#else
# define UV__EPROTO UV__ERR(4046)
# define UV__EPROTO (-4046)
#endif
#if defined(EPROTONOSUPPORT) && !defined(_WIN32)
@ -413,7 +413,6 @@
#elif defined(__APPLE__) || \
defined(__DragonFly__) || \
defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || \
defined(__NetBSD__) || \
defined(__OpenBSD__)
# define UV__EHOSTDOWN (-64)
@ -439,5 +438,46 @@
# define UV__EFTYPE (-4028)
#endif
#if defined(EILSEQ) && !defined(_WIN32)
# define UV__EILSEQ UV__ERR(EILSEQ)
#else
# define UV__EILSEQ (-4027)
#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_ */

View File

@ -28,7 +28,7 @@
int inotify_fd; \
#define UV_PLATFORM_FS_EVENT_FIELDS \
void* watchers[2]; \
struct uv__queue watchers; \
int wd; \
#endif /* UV_LINUX_H */

View File

@ -1,69 +0,0 @@
/*
Copyright (c) 2016, Kari Tristan Helgason <kthelgason@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _UV_PTHREAD_BARRIER_
#define _UV_PTHREAD_BARRIER_
#include <errno.h>
#include <pthread.h>
#if !defined(__MVS__)
#include <semaphore.h> /* sem_t */
#endif
#define PTHREAD_BARRIER_SERIAL_THREAD 0x12345
#define UV__PTHREAD_BARRIER_FALLBACK 1
/*
* To maintain ABI compatibility with
* libuv v1.x struct is padded according
* to target platform
*/
#if defined(__ANDROID__)
# define UV_BARRIER_STRUCT_PADDING \
sizeof(pthread_mutex_t) + \
sizeof(pthread_cond_t) + \
sizeof(unsigned int) - \
sizeof(void *)
#elif defined(__APPLE__)
# define UV_BARRIER_STRUCT_PADDING \
sizeof(pthread_mutex_t) + \
2 * sizeof(sem_t) + \
2 * sizeof(unsigned int) - \
sizeof(void *)
#else
# define UV_BARRIER_STRUCT_PADDING 0
#endif
typedef struct {
pthread_mutex_t mutex;
pthread_cond_t cond;
unsigned threshold;
unsigned in;
unsigned out;
} _uv_barrier;
typedef struct {
_uv_barrier* b;
char _pad[UV_BARRIER_STRUCT_PADDING];
} pthread_barrier_t;
int pthread_barrier_init(pthread_barrier_t* barrier,
const void* barrier_attr,
unsigned count);
int pthread_barrier_wait(pthread_barrier_t* barrier);
int pthread_barrier_destroy(pthread_barrier_t *barrier);
#endif /* _UV_PTHREAD_BARRIER_ */

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 (*done)(struct uv__work *w, int status);
struct uv_loop_s* loop;
void* wq[2];
struct uv__queue wq;
};
#endif /* UV_THREADPOOL_H_ */

View File

@ -35,21 +35,7 @@
#endif
/*
* This file defines data structures for different types of 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);
*
* This file defines data structures for red-black trees.
* A red-black tree is a binary search tree with the node color as an
* extra attribute. It fulfills a set of conditions:
* - 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).
*/
#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 */
#define RB_HEAD(name, type) \
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_FIND(name, x, y) name##_RB_FIND(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_PREV(name, x, y) name##_RB_PREV(y)
#define RB_NEXT(name, x) name##_RB_NEXT(x)
#define RB_PREV(name, x) name##_RB_PREV(x)
#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF)
#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF)

View File

@ -31,13 +31,14 @@
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netdb.h> /* MAXHOSTNAMELEN on Solaris */
#include <termios.h>
#include <pwd.h>
#if !defined(__MVS__)
#include <semaphore.h>
#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
#endif
#include <pthread.h>
#include <signal.h>
@ -48,8 +49,8 @@
# include "uv/linux.h"
#elif defined (__MVS__)
# include "uv/os390.h"
#elif defined(__PASE__)
# include "uv/posix.h"
#elif defined(__PASE__) /* __PASE__ and _AIX are both defined on IBM i */
# include "uv/posix.h" /* IBM i needs uv/posix.h, not uv/aix.h */
#elif defined(_AIX)
# include "uv/aix.h"
#elif defined(__sun)
@ -58,18 +59,17 @@
# include "uv/darwin.h"
#elif defined(__DragonFly__) || \
defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || \
defined(__OpenBSD__) || \
defined(__NetBSD__)
# include "uv/bsd.h"
#elif defined(__CYGWIN__) || defined(__MSYS__)
#elif defined(__CYGWIN__) || \
defined(__MSYS__) || \
defined(__HAIKU__) || \
defined(__QNX__) || \
defined(__GNU__)
# include "uv/posix.h"
#endif
#ifndef PTHREAD_BARRIER_SERIAL_THREAD
# include "uv/pthread-barrier.h"
#endif
#ifndef NI_MAXHOST
# define NI_MAXHOST 1025
#endif
@ -92,8 +92,8 @@ typedef struct uv__io_s uv__io_t;
struct uv__io_s {
uv__io_cb cb;
void* pending_queue[2];
void* watcher_queue[2];
struct uv__queue pending_queue;
struct uv__queue watcher_queue;
unsigned int pevents; /* Pending event mask i.e. mask at next tick. */
unsigned int events; /* Current event mask. */
int fd;
@ -136,8 +136,30 @@ typedef pthread_rwlock_t uv_rwlock_t;
typedef UV_PLATFORM_SEM_T uv_sem_t;
typedef pthread_cond_t uv_cond_t;
typedef pthread_key_t uv_key_t;
typedef pthread_barrier_t uv_barrier_t;
/* Note: guard clauses should match uv_barrier_init's in src/unix/thread.c. */
#if defined(_AIX) || \
defined(__OpenBSD__) || \
!defined(PTHREAD_BARRIER_SERIAL_THREAD)
/* TODO(bnoordhuis) Merge into uv_barrier_t in v2. */
struct _uv_barrier {
uv_mutex_t mutex;
uv_cond_t cond;
unsigned threshold;
unsigned in;
unsigned out;
};
typedef struct {
struct _uv_barrier* b;
# if defined(PTHREAD_BARRIER_SERIAL_THREAD)
/* TODO(bnoordhuis) Remove padding in v2. */
char pad[sizeof(pthread_barrier_t) - sizeof(struct _uv_barrier*)];
# endif
} uv_barrier_t;
#else
typedef pthread_barrier_t uv_barrier_t;
#endif
/* Platform-specific definitions for uv_spawn support. */
typedef gid_t uv_gid_t;
@ -145,6 +167,9 @@ typedef uid_t uv_uid_t;
typedef struct dirent uv__dirent_t;
#define UV_DIR_PRIVATE_FIELDS \
DIR* dir;
#if defined(DT_UNKNOWN)
# define HAVE_DIRENT_TYPES
# if defined(DT_REG)
@ -195,21 +220,21 @@ typedef struct {
#define UV_LOOP_PRIVATE_FIELDS \
unsigned long flags; \
int backend_fd; \
void* pending_queue[2]; \
void* watcher_queue[2]; \
struct uv__queue pending_queue; \
struct uv__queue watcher_queue; \
uv__io_t** watchers; \
unsigned int nwatchers; \
unsigned int nfds; \
void* wq[2]; \
struct uv__queue wq; \
uv_mutex_t wq_mutex; \
uv_async_t wq_async; \
uv_rwlock_t cloexec_lock; \
uv_handle_t* closing_handles; \
void* process_handles[2]; \
void* prepare_handles[2]; \
void* check_handles[2]; \
void* idle_handles[2]; \
void* async_handles[2]; \
struct uv__queue process_handles; \
struct uv__queue prepare_handles; \
struct uv__queue check_handles; \
struct uv__queue idle_handles; \
struct uv__queue async_handles; \
void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \
uv__io_t async_io_watcher; \
int async_wfd; \
@ -232,7 +257,7 @@ typedef struct {
#define UV_PRIVATE_REQ_TYPES /* empty */
#define UV_WRITE_PRIVATE_FIELDS \
void* queue[2]; \
struct uv__queue queue; \
unsigned int write_index; \
uv_buf_t* bufs; \
unsigned int nbufs; \
@ -240,13 +265,16 @@ typedef struct {
uv_buf_t bufsml[4]; \
#define UV_CONNECT_PRIVATE_FIELDS \
void* queue[2]; \
struct uv__queue queue; \
#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */
#define UV_UDP_SEND_PRIVATE_FIELDS \
void* queue[2]; \
struct sockaddr_storage addr; \
struct uv__queue queue; \
union { \
struct sockaddr addr; \
struct sockaddr_storage storage; \
} u; \
unsigned int nbufs; \
uv_buf_t* bufs; \
ssize_t status; \
@ -261,8 +289,8 @@ typedef struct {
uv_connect_t *connect_req; \
uv_shutdown_t *shutdown_req; \
uv__io_t io_watcher; \
void* write_queue[2]; \
void* write_completed_queue[2]; \
struct uv__queue write_queue; \
struct uv__queue write_completed_queue; \
uv_connection_cb connection_cb; \
int delayed_error; \
int accepted_fd; \
@ -275,35 +303,38 @@ typedef struct {
uv_alloc_cb alloc_cb; \
uv_udp_recv_cb recv_cb; \
uv__io_t io_watcher; \
void* write_queue[2]; \
void* write_completed_queue[2]; \
struct uv__queue write_queue; \
struct uv__queue write_completed_queue; \
#define UV_PIPE_PRIVATE_FIELDS \
const char* pipe_fname; /* strdup'ed */
const char* pipe_fname; /* NULL or strdup'ed */
#define UV_POLL_PRIVATE_FIELDS \
uv__io_t io_watcher;
#define UV_PREPARE_PRIVATE_FIELDS \
uv_prepare_cb prepare_cb; \
void* queue[2]; \
struct uv__queue queue; \
#define UV_CHECK_PRIVATE_FIELDS \
uv_check_cb check_cb; \
void* queue[2]; \
struct uv__queue queue; \
#define UV_IDLE_PRIVATE_FIELDS \
uv_idle_cb idle_cb; \
void* queue[2]; \
struct uv__queue queue; \
#define UV_ASYNC_PRIVATE_FIELDS \
uv_async_cb async_cb; \
void* queue[2]; \
struct uv__queue queue; \
int pending; \
#define UV_TIMER_PRIVATE_FIELDS \
uv_timer_cb timer_cb; \
void* heap_node[3]; \
union { \
void* heap[3]; \
struct uv__queue queue; \
} node; \
uint64_t timeout; \
uint64_t repeat; \
uint64_t start_id;
@ -327,7 +358,7 @@ typedef struct {
int retcode;
#define UV_PROCESS_PRIVATE_FIELDS \
void* queue[2]; \
struct uv__queue queue; \
int status; \
#define UV_FS_PRIVATE_FIELDS \
@ -379,11 +410,27 @@ typedef struct {
#else
# define UV_FS_O_CREAT 0
#endif
#if defined(O_DIRECT)
#if defined(__linux__) && defined(__arm__)
# define UV_FS_O_DIRECT 0x10000
#elif defined(__linux__) && defined(__m68k__)
# define UV_FS_O_DIRECT 0x10000
#elif defined(__linux__) && defined(__mips__)
# define UV_FS_O_DIRECT 0x08000
#elif defined(__linux__) && defined(__powerpc__)
# define UV_FS_O_DIRECT 0x20000
#elif defined(__linux__) && defined(__s390x__)
# define UV_FS_O_DIRECT 0x04000
#elif defined(__linux__) && defined(__x86_64__)
# define UV_FS_O_DIRECT 0x04000
#elif defined(__linux__) && defined(__loongarch__)
# define UV_FS_O_DIRECT 0x04000
#elif defined(O_DIRECT)
# define UV_FS_O_DIRECT O_DIRECT
#else
# define UV_FS_O_DIRECT 0
#endif
#if defined(O_DIRECTORY)
# define UV_FS_O_DIRECTORY O_DIRECTORY
#else
@ -456,6 +503,7 @@ typedef struct {
#endif
/* fs open() flags supported on other platforms: */
#define UV_FS_O_FILEMAP 0
#define UV_FS_O_RANDOM 0
#define UV_FS_O_SHORT_LIVED 0
#define UV_FS_O_SEQUENTIAL 0

View File

@ -26,15 +26,15 @@
* Versions with the same major number are ABI stable. API is allowed to
* evolve between minor releases, but only in a backwards compatible way.
* Make sure you update the -soname directives in configure.ac
* and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but
* whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but
* not UV_VERSION_PATCH.)
*/
#define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 23
#define UV_VERSION_PATCH 0
#define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX ""
#define UV_VERSION_MINOR 50
#define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 0
#define UV_VERSION_SUFFIX "dev"
#define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \
(UV_VERSION_MINOR << 8) | \

View File

@ -20,43 +20,38 @@
*/
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0600
# define _WIN32_WINNT 0x0A00
#endif
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
typedef intptr_t ssize_t;
# define SSIZE_MAX INTPTR_MAX
# define _SSIZE_T_
# define _SSIZE_T_DEFINED
#endif
#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
# define LOCALE_INVARIANT 0x007f
#endif
#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>
#undef _TCP_INITIAL_RTO_PARAMETERS
#undef TCP_INITIAL_RTO_PARAMETERS
#undef PTCP_INITIAL_RTO_PARAMETERS
#include <windows.h>
#include <process.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/stat.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
# include "uv/stdint-msvc2008.h"
#else
# include <stdint.h>
#endif
#include <stdint.h>
#include "uv/tree.h"
#include "uv/threadpool.h"
@ -67,6 +62,11 @@ typedef struct pollfd {
# define S_IFLNK 0xA000
#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
* the following signals already:
*
@ -83,9 +83,18 @@ typedef struct pollfd {
* variants (Linux and Darwin)
*/
#define SIGHUP 1
#define SIGQUIT 3
#define SIGKILL 9
#define SIGWINCH 28
/* Redefine NSIG to take SIGWINCH into consideration */
#if defined(NSIG) && NSIG <= SIGWINCH
# undef NSIG
#endif
#ifndef NSIG
# define NSIG SIGWINCH + 1
#endif
/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many unix-like
* platforms. However MinGW doesn't define it, so we do. */
#ifndef SIGABRT_COMPAT
@ -207,7 +216,7 @@ typedef struct _AFD_POLL_INFO {
AFD_POLL_HANDLE_INFO Handles[1];
} AFD_POLL_INFO, *PAFD_POLL_INFO;
#define UV_MSAFD_PROVIDER_COUNT 3
#define UV_MSAFD_PROVIDER_COUNT 4
/**
@ -247,29 +256,23 @@ typedef union {
} unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */
} uv_cond_t;
typedef union {
struct {
unsigned int num_readers_;
CRITICAL_SECTION num_readers_lock_;
HANDLE write_semaphore_;
} state_;
/* TODO: remove me in v2.x. */
struct {
SRWLOCK unused_;
} unused1_;
/* TODO: remove me in v2.x. */
struct {
uv_mutex_t unused1_;
uv_mutex_t unused2_;
} unused2_;
typedef struct {
SRWLOCK read_write_lock_;
/* TODO: retained for ABI compatibility; remove me in v2.x */
#ifdef _WIN64
unsigned char padding_[72];
#else
unsigned char padding_[44];
#endif
} uv_rwlock_t;
typedef struct {
unsigned int n;
unsigned int count;
unsigned threshold;
unsigned in;
uv_mutex_t mutex;
uv_sem_t turnstile1;
uv_sem_t turnstile2;
/* TODO: in v2 make this a uv_cond_t, without unused_ */
CONDITION_VARIABLE cond;
unsigned out;
} uv_barrier_t;
typedef struct {
@ -279,8 +282,8 @@ typedef struct {
#define UV_ONCE_INIT { 0, NULL }
typedef struct uv_once_s {
unsigned char ran;
HANDLE event;
unsigned char unused;
INIT_ONCE init_once;
} uv_once_t;
/* Platform-specific definitions for uv_spawn support. */
@ -292,6 +295,11 @@ typedef struct uv__dirent_s {
char d_name[1];
} uv__dirent_t;
#define UV_DIR_PRIVATE_FIELDS \
HANDLE dir_handle; \
WIN32_FIND_DATAW find_data; \
BOOL need_find_call;
#define HAVE_DIRENT_TYPES
#define UV__DT_DIR UV_DIRENT_DIR
#define UV__DT_FILE UV_DIRENT_FILE
@ -334,14 +342,14 @@ typedef struct {
uv_idle_t* next_idle_handle; \
/* This handle holds the peer sockets for the fast variant of uv_poll_t */ \
SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \
/* Counter to keep track of active tcp streams */ \
/* No longer used. */ \
unsigned int active_tcp_streams; \
/* Counter to keep track of active udp streams */ \
/* No longer used. */ \
unsigned int active_udp_streams; \
/* Counter to started timer */ \
uint64_t timer_counter; \
/* Threadpool */ \
void* wq[2]; \
struct uv__queue wq; \
uv_mutex_t wq_mutex; \
uv_async_t wq_async;
@ -363,6 +371,13 @@ typedef struct {
OVERLAPPED overlapped; \
size_t queued_bytes; \
} 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; \
struct uv_req_s* next_req;
@ -463,7 +478,7 @@ typedef struct {
uint32_t payload_remaining; \
uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \
} ipc_data_frame; \
void* ipc_xfer_queue[2]; \
struct uv__queue ipc_xfer_queue; \
int ipc_xfer_queue_length; \
uv_write_t* non_overlapped_writes_tail; \
CRITICAL_SECTION readfile_thread_lock; \
@ -477,15 +492,18 @@ typedef struct {
struct { uv_pipe_connection_fields } conn; \
} 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. */
#define UV_TTY_PRIVATE_FIELDS \
HANDLE handle; \
union { \
struct { \
/* Used for readable TTY handles */ \
/* TODO: remove me in v2.x. */ \
HANDLE unused_; \
union { \
/* TODO: remove me in v2.x. */ \
HANDLE unused_; \
int mode; \
} mode; \
uv_buf_t read_line_buffer; \
HANDLE read_raw_wait; \
/* Fields used for translating win keystrokes into vt100 characters */ \
@ -503,7 +521,7 @@ typedef struct {
/* eol conversion state */ \
unsigned char previous_eol; \
/* ansi parser state */ \
unsigned char ansi_parser_state; \
unsigned short ansi_parser_state; \
unsigned char ansi_csi_argc; \
unsigned short ansi_csi_argv[4]; \
COORD saved_position; \
@ -527,7 +545,10 @@ typedef struct {
unsigned char events;
#define UV_TIMER_PRIVATE_FIELDS \
void* heap_node[3]; \
union { \
void* heap[3]; \
struct uv__queue queue; \
} node; \
int unused; \
uint64_t timeout; \
uint64_t repeat; \
@ -585,7 +606,7 @@ typedef struct {
struct uv_process_exit_s { \
UV_REQ_FIELDS \
} exit_req; \
BYTE* child_stdio_buffer; \
void* unused; /* TODO: retained for ABI compat; remove this in v2.x. */ \
int exit_signal; \
HANDLE wait_handle; \
HANDLE process_handle; \
@ -654,6 +675,7 @@ typedef struct {
#define UV_FS_O_APPEND _O_APPEND
#define UV_FS_O_CREAT _O_CREAT
#define UV_FS_O_EXCL _O_EXCL
#define UV_FS_O_FILEMAP 0x20000000
#define UV_FS_O_RANDOM _O_RANDOM
#define UV_FS_O_RDONLY _O_RDONLY
#define UV_FS_O_RDWR _O_RDWR

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}
libdir=@libdir@
includedir=@includedir@
LIBUV_STATIC=-L${libdir} -l:libuv.a @LIBS@
Name: libuv
Version: @PACKAGE_VERSION@

1
m4/.gitignore vendored
View File

@ -1,4 +1,5 @@
# Ignore libtoolize-generated files.
*.m4
!as_case.m4
!ax_pthread.m4
!libuv-check-flags.m4

Some files were not shown because too many files have changed in this diff Show More