Add getter/setter functions for the fields of public structs that
might be relevant to e.g. Node.js addons.
Through these methods, ABI compatibility for a subset of the ABI
is easier to achieve, since using them makes code independent
of the exact offsets of these fields.
The intended use case that prompted this are N-API addons for
Node.js, which look for more long-term ABI compatibility guarantees
than typical Node code. With these helper functions, using libuv
directly should no longer be an obstacle for such addons.
PR-URL: https://github.com/libuv/libuv/pull/1657
Refs: https://github.com/nodejs/node/issues/13512
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Unbreaks libuv compilation on Windows.
PR-URL: https://github.com/libuv/libuv/pull/1641
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
I'm 99% sure `WaitForSingleObject()` already issues a memory barrier for
thread objects but since I could find no mention of that on MSDN, let's
play it safe and do it ourselves, too.
PR-URL: https://github.com/libuv/libuv/pull/1634
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Stack-allocate the `uv_loop_t` instance, no reason to heap-allocate it.
PR-URL: https://github.com/libuv/libuv/pull/1634
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Verify that quick setup and teardown of the threadpool doesn't cause
crashes or hangs.
PR-URL: https://github.com/libuv/libuv/pull/1639
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
We use the UV_HANDLE_BOUND flag to mark a socket as bound to a
port. We need to do this for sockets that are sent from another
process as well as sockets that created by the process itself.
First check if the port number is non-zero. If yes then mark
it as bound.
PR-URL: https://github.com/libuv/libuv/pull/1348
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Include `<winioctl.h>` for the definition of `FSCTL_SET_REPARSE_POINT`
and define `ERROR_SYMLINK_NOT_SUPPORTED` if not already defined.
PR-URL: https://github.com/libuv/libuv/pull/1632
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
uv_if_indextoname() is used to convert an IPv6 scope_id
to an interface identifier string such as %eth0 or %lo.
uv_if_indextoiid() returns an IPv6 interface identifier.
On Unix it calls uv_if_indextoname(). On Windows it uses
snprintf() to return the numeric interface identifier as
a string.
Refs: https://github.com/nodejs/node/pull/14500
PR-URL: https://github.com/libuv/libuv/pull/1445
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Adds new uv_pipe_chmod function which can be used to make the pipe
writable or readable by all users.
PR-URL: https://github.com/libuv/libuv/pull/1386
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
`options.file` is of type `const char*`, don't assign it to a variable
that is a non-const `char*`. The other way around is perfectly legal,
though.
PR-URL: https://github.com/libuv/libuv/pull/1588
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
When sorting tests, keeps platform_output as the first test.
PR-URL: https://github.com/libuv/libuv/pull/1584
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
z/OS does not allow a child process to create threads if it was
forked from a multi-threaded parent.
PR-URL: https://github.com/libuv/libuv/pull/1596
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
These have been around for some time apparently (commit 391f0098de from
May 2011) but went unnoticed so far. No longer.
PR-URL: https://github.com/libuv/libuv/pull/1581
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Fixes uv_fs_stat and uv_fs_lstat returning EINVAL when invoked on a
non-symlink reparse point.
1. Only tries to read symlinks when invoked via lstat (do_lstat == 1).
Rationale is that only lstat can set S_IFLNK because when a file is
tested by stat, symlinks are resolved by the OS and the returned file
must be real. Note that broken symlinks fail at CreateFile.
FILE_ATTRIBUTE_REPARSE_POINT is used by filesystem drivers for purposes
besides symlinks, and uv_fs_stat fails when invoked on these files
because fs__readlink_handle returns ERROR_SYMLINK_NOT_SUPPORTED. By
ignoring the attribute in uv_fs_stat, these files are now handled
correctly.
2. Modifies the logic added to fs__stat_handle to fix#995 as follows:
A failed fs__readlink_handle on a file with a reparse point indicates
that the file is not a symlink. The fix for #995 added code to fall
through and behave as with a normal file in this case. However, this is
not correct because lstat had opened the file with
FILE_FLAG_OPEN_REPARSE_POINT, preventing the filesystem from acting
based on the reparse point contents.
The fix makes fs__stat_handle fail back to the higher level
fs__stat_impl, which sets do_lstat to 0 and re-opens the file without
FILE_FLAG_OPEN_REPARSE_POINT, allowing normal filesystem processing to
take place.
This is also a slightly cleaner solution as symlink fallback is only
handled in one place (fs__stat_impl) instead of two (fs__stat_impl and
fs__stat_handle).
Note that the error tested in the fix for #995,
ERROR_NOT_A_REPARSE_POINT, is not actually returned by Windows in the
case of a non-symlink reparse point. I attempted to reproduce the error
by repeating the test steps in the issue but failed. However, the the
fix logic is preserved out of caution.
3. Adds tests to fs-test.c for the above two changes.
Thorough testing requires some non-trivial setup - like an OSX computer
on the LAN or a custom filesystem driver - so these tests are left
commented out for manual invocation.
PR-URL: https://github.com/libuv/libuv/pull/1522
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
NetBSD must use the uv_udp_set_membership call with
"::1%lo0", similar to FreeBSD.
PR-URL: https://github.com/libuv/libuv/pull/1577
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Follow other BSDs and disable the failing poll_bad_fdtype test on
NetBSD.
PR-URL: https://github.com/libuv/libuv/pull/1574
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
As it is, when the tests run, there is no indicator as to how long the
tests will run, how many more tests are pending.
PR-URL: https://github.com/libuv/libuv/pull/1543
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
On systems that use System V semaphores, it is necessary to destroy
semaphores to free up system resources when the process finishes
execution.
PR-URL: https://github.com/libuv/libuv/pull/1559
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
musl has tiny default thread stack sizes compared to glibc (80 kB vs.
2048 kB or more) so set an explicit stack size to harmonize between
different libcs.
Fixes: https://github.com/libuv/libuv/issues/1507
PR-URL: https://github.com/libuv/libuv/pull/1526
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
NetBSD and FreeBSD can share the can_ipv6_ipv4_dual() function as
is. This commit also corrects the function definition to be
compliant with C standards. This fixes a warning on
NetBSD 8.99.2 with GCC 5.4.0.
PR-URL: https://github.com/libuv/libuv/pull/1535
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit adds the O_TRUNC flag to the destination file in
the sendfile() fallback. This allows smaller source files to
be properly copied into larger existing destination files.
Refs: https://github.com/libuv/libuv/pull/1551
PR-URL: https://github.com/libuv/libuv/pull/1552
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Initialize the error variable in uv_fs_copyfile() to zero. If
the source file being copied has no data in it, then it's
possible to make it to the exit without ever setting error.
In this situation, the function's behavior is unpredictable.
Refs: https://github.com/libuv/libuv/pull/1551
PR-URL: https://github.com/libuv/libuv/pull/1552
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit introduces an INIT macro to file system functions on
Windows, similar to the one used on Unix platforms. The macro
checks for NULL requests, and returns UV_EINVAL in such
scenarios. This commit also adds support for passing NULL to
uv_fs_req_cleanup(). In this scenario, the function is a
no-op.
Fixes: https://github.com/libuv/libuv/issues/1508
PR-URL: https://github.com/libuv/libuv/pull/1509
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Prior to this change, several of the fs functions checked for
invalid arguments before initializing the fs request. If a
consumer received a UV_EINVAL from one of these functions, and
then called uv_fs_req_cleanup(), the application would crash, as
the pointer being freed was not allocated. This commit makes
sure that all fs functions initialize the request before returning.
Fixes: https://github.com/libuv/libuv/issues/1508
PR-URL: https://github.com/libuv/libuv/pull/1509
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Need to flush out the OOB data. Otherwise, this callback will get
triggered on every poll with nread = 0.
PR-URL: https://github.com/libuv/libuv/pull/1484
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
On Unix you can pass bound and even connected socket to uv_tcp_open
and it will work as expected: you can run uv_listen or other io
functions (uv_read, uv_write) on it without problems.
On windows on the other hand the function always assumes to have clean
socket and for example uv_listen will try to bind it again, and
uv_read/write will return with errors about unreadable streams
(basically invalid internal flags).
To check if socket is already bound uv_tcp_getsockname is called which
on windows returns error when socket is unbound. To further
differentiate connected one from just bound, uv_tcp_getpeername also
returns error but when target socket is not connected.
PR-URL: https://github.com/libuv/libuv/pull/1447
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This is because on some platforms like z/OS, setgid(0) is
allowed for non-superusers. So instead, use setgid(-1) to
get UV_EINVAL to test that spawn failure returns the right
return code.
PR-URL: https://github.com/libuv/libuv/pull/1456
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
z/OS allows non root users to chown a file to root via the
CHOWN.UNRESTRICTED profile. So avoid that test on z/OS.
PR-URL: https://github.com/libuv/libuv/pull/1454
Reviewed-By: Colin Ihrig <cjihrig@gmail.com
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Should make the dreaded "%1 is not a valid Win32 application" error
message a thing of the past.
PR-URL: https://github.com/libuv/libuv/pull/1116
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Out-of-band TCP messages are used for TCP data
transmission outside (outband) the inbound TCP
data. These packets are sent with an
"urgent pointer", but previously discarded.
Additionally, when using (e)poll a POLLPRI is
triggered when an interrupt signal is received
on GPIO capable systems such as the Raspberry Pi.
PR-URL: https://github.com/libuv/libuv/pull/1040
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Like the previous commit, except now the signal mask is reset instead
of the signal disposition. This does open a race window where blocked
signals can get delivered in the interval between the pthread_sigmask()
call and the execve() call (and may end up terminating the process) but
that cannot be helped; the same caveat applies to the previous commit.
Fixes: https://github.com/nodejs/node/issues/13662
PR-URL: https://github.com/libuv/libuv/pull/1376
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Signal dispositions are inherited by child processes. Libuv itself
does not touch them (if you don't use uv_signal_start(), that is)
but the embedder might and probably does in the case of SIGPIPE.
Reset the disposition for signals 1-31 to their defaults right before
execve'ing into the new process.
Fixes: https://github.com/nodejs/node/issues/13662
PR-URL: https://github.com/libuv/libuv/pull/1376
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
atomic_cas_ptr() is for compare-and-swap pointer addresses.
So when building 64 bit:
1. `ptr` is used casted to a pointer value (4-byte into 8-byte).
2. atomic_cas_ptr reads 8-byte at `ptr` and returns
In the case of `uv_async_send`, if handle->pending is 0, cmpxchgi()
actually returns the value of the 4-bytes past handle->pending,
causing uv__async_send to never be called.
The modified test-async-null-cb.c hangs at uv_run in this case.
PR-URL: https://github.com/libuv/libuv/pull/1361
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
The FILE* object is not guaranteed to be in the same state after
a fork. Instead store the file descriptor instead and use that in
the child process.
PR-URL: https://github.com/libuv/libuv/pull/1369
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
File read or write from specified position will move file pointer on
Windows but not on POSIX. This makes Windows behave as other
supported platforms.
Ref: https://github.com/nodejs/node/issues/9671
PR-URL: https://github.com/libuv/libuv/pull/1357
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The uv__get_osfhandle() function is a private functio of the
Windows subsystem, and its used to get a Windows HANDLE out
of a file descriptor number.
The motivation behind making this function public is to
allow Node.js programs to pass file descriptors created
using fs.open() to native Node.js C++ add-ons, and be able to
successfully convert them to Windows HANDLEs.
Refs: https://github.com/libuv/libuv/pull/1166
Refs: https://github.com/nodejs/node/issues/6369
Fixes: https://github.com/libuv/libuv/issues/1291
PR-URL: https://github.com/libuv/libuv/pull/1323
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
The cygwin runtime library fails to connect a socket client to a
listening server within the same thread. Test cases that use
this approach hang while waiting for the connection to complete.
This can be reproduced independent of libuv in a simple example
using both socket/bind/listen and socket/connect in a single
thread.
Avoid this problem in our test suite by skipping such tests on cygwin.
PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
On Cygwin `recvmsg` always sets `msg_controllen` to zero on a
message received from a named pipe. Therefore we cannot use
`sendmsg` to send handles for ipc. Return failure early from
this code path as `ENOSYS`.
Skip tests requiring this feature since it is not available.
PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Cygwin and MSYS2 are POSIX layers implemented on top of Windows.
Use our POSIX `poll(2)` implementation of our poll abstraction.
For most other components we already have dedicated sources
implementing them in terms of APIs available on Cygwin or
providing non-implementations of components not supported.
This leaves only three components that need Cygwin-specific
implementations:
* uv_uptime: implement using sysinfo
* uv_resident_set_memory: add a placeholder returning UV_ENOSYS
* uv_cpu_info: add a placeholder returning UV_ENOSYS
Update our test suite to account for features not available
due to Cygwin platform limitations or our placeholders.
PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
On platforms not supporting fsevents do not run the fork
fsevent tests.
PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Factor out a dedicated test macro for use on platforms that
do not support fsevents instead of duplicating the os390
platform condition and explanation text.
PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
A small timeout resulted in flaky behaviour on the z/OS test
machine.
PR-URL: https://github.com/libuv/libuv/pull/1353
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Delay the timer start to be sure all handles are created when `timer_cb`
is executed. In some cases this was not the case causing the following
error:
```
not ok 51 - tcp_write_queue_order
exit code 134
Output from process `tcp_write_queue_order`:
lt-run-tests: src/unix/core.c:166: uv_close: Assertion `0' failed.
```
PR-URL: https://github.com/libuv/libuv/pull/1338
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Andrius Bentkus <andrius.bentkus@gmail.com>
Basic implementation of uv__io_fork on z/OS.
As of now, since filesystem events are not supported,
skip all of those tests on z/OS.
PR-URL: https://github.com/libuv/libuv/pull/1303
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit fixes the following warning:
warning C4047: char *' differs in levels of indirection from 'char
(*)[1]'
PR-URL: https://github.com/libuv/libuv/pull/1290
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Fix a bug in process_copy_output that would cause output larger
than 1kb to be incorrectly split into lines.
PR-URL: https://github.com/libuv/libuv/pull/1325
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Test that the fast path will continue writing. On failure, this test
will timeout.
PR-URL: https://github.com/libuv/libuv/pull/1308
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Fixes deadstore in uv_pipe_bind as 'sockfd' is no longer used.
Fixes deadstore in test related to unused variables or missing
assert.
PR-URL: https://github.com/libuv/libuv/pull/1288
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
At least starting with Darwin Kernel Version 16.4.0, sending a SIGTERM
to a process that is still starting up kills it with SIGKILL instead of
SIGTERM.
Fixes: https://github.com/libuv/libuv/issues/1226
PR-URL: https://github.com/libuv/libuv/pull/1282
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Added the uv_loop_fork() API that must be called in a child process to
continue using an existing loop. Internally this calls a uv__io_fork
function for each supported platform, similar to the way
uv__platform_loop_init works.
After this call, existing and new IO, async and signal watchers will
contiue working as before on all platforms, as will the
threadpool (although any threads it was using are of course gone).
On Linux and BSDs that use kqueue, existing and new fsevent watchers
will also continue to work as expected. On OS X, though, directory
fsevents will not be able to use the optimized CoreFoundation path if
they had already been used in the parent process, instead falling back
to the kqueue path used on other BSDs.
Existing fsevent watchers will not function on AIX or SunOS. This
could be relatively easily fixed by someone with AIX knowledge in the
future, but SunOS will require some additional work to keep track if
the watchers.
A new test file, test/test-fork.c, was added to contain fork-related
tests to verify functionality in the child process.
PR-URL: https://github.com/libuv/libuv/pull/846
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
"setenv" on z/OS returns successfully on a NULL ptr argument
for name. Check for this on all unixes.
PR-URL: https://github.com/libuv/libuv/pull/1243
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
It behaves as `uv_signal_start` but it resets the signal handler as soon
as the signal is received.
Fixes: https://github.com/libuv/libuv/issues/1104
PR-URL: https://github.com/libuv/libuv/pull/1106
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Substitute the `z` length modifier with `l` to avoid warnings, as the
`z` modifier is defined in the C99 standard.
PR-URL: https://github.com/libuv/libuv/pull/1220
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Fixes an issue where the Windows-only tty_large_write attempts to write
an uninitialized buffer to the console.
PR-URL: https://github.com/libuv/libuv/pull/1212
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Use built-in proctitle implementation because there is no such thing as
a process title on zOS.
PR-URL: https://github.com/libuv/libuv/pull/1208
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This patch enables querying and setting the process title on AIX.
libuv takes ownership of the memory for argv and returns a deep copy
of the array and its contents.
It also enables the process_title test case.
The process title can be changed on AIX but is handled differently
to Linux/Mac. Commands like ps read the original argv array passed
to the process instead of the memory at argv[0]. To change the process
title we need to update argv[0] to point at a new string and set
argv[1] to NULL (if it exists). This means the process title
can be set to a string of any length.
PR-URL: https://github.com/libuv/libuv/pull/1187
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Handle the case when it's called after the request has ended, or in case
it ended with an error.
PR-URL: https://github.com/libuv/libuv/pull/1181
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The error path frees `req->alloc` but that hasn't been set yet when
`service` and `node` are both NULL. Simply return instead of jumping
to the error handling block.
Fixes: https://github.com/libuv/libuv/issues/1122
PR-URL: https://github.com/libuv/libuv/pull/1123
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
uv_spawn() on Windows will fail with ERROR_ELEVATION_REQUIRED
if attempting to run an application that requires elevation.
Fixes: https://github.com/nodejs/node/issues/9464
PR-URL: https://github.com/libuv/libuv/pull/1154
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Fix the #ifdef logic to make sure all the available fields filled in the
`stat` struct are correcly copied into the `uv_stat_t` struct. Before
this change, the `n_sec` were being set to 0.
PR-URL: https://github.com/libuv/libuv/pull/1152
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
uv_translate_sys_error() was a private function for Windows.
This commit adds an equivalent function on other platforms, and
exposes it as public API.
Exposing this is useful in scenarios where the application uses
both libuv functions and platform-specific system calls and wants
to report errors uniformly as libuv errors.
Fixes: https://github.com/libuv/libuv/issues/79
PR-URL: https://github.com/libuv/libuv/pull/1060
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Use a deterministic approach for saturating the threadpool instead of
depending on a timeout. Should help reduce the flakiness of the CI.
PR-URL: https://github.com/libuv/libuv/pull/1014
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Saturate the thread pool before trying to post-and-cancel the work
request. Before this commit we simply posted requests in a loop,
in the (sometimes idle) hope that one would get queued up instead
of being dispatched right away.
PR-URL: https://github.com/libuv/libuv/pull/1014
Refs: https://github.com/libuv/libuv/pull/1010
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The expected error is UV_ECANCELED but the test tries to connect to what
is basically an arbitrary address in the expectation that no network
path exists, so UV_ENETUNREACH is an equally plausible outcome.
This commit undoes the change from commit e994000 ("test: make
tcp_close_while_connecting more resilient") because I don't think
the connection ever actually succeeds.
PR-URL: https://github.com/libuv/libuv/pull/1048
Refs: https://github.com/libuv/libuv/pull/1005
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Under Windows uv_fs_event_start with UV_FS_EVENT_RECURSIVE will report new file
creation and file deletion twice - once with the name of the file, and second
time with the name of the directory itself. This will filter out callbacks with
directory name, making observed callbacks count match expected values.
Fixes: https://github.com/libuv/libuv/issues/1009
PR-URL: https://github.com/libuv/libuv/pull/1061
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Increase the time between file creations, so all the events are
emitted.
PR-URL: https://github.com/libuv/libuv/pull/1038
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Decrease the data sent for `arm` so the test doesn't timeout in the arm
CI bots.
PR-URL: https://github.com/libuv/libuv/pull/1038
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
In `musl` libc, defining `_GNU_SOURCE` doesn't automatically define the
other feature definitions, causing that `uv_fs_fstat` would not fill the
`nsec` fields. For the same reason, compile the tests on linux with
`-D_GNU_SOURCE` so the `fs_fstat` tests passes on `musl` platforms.
PR-URL: https://github.com/libuv/libuv/pull/1039
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Check that the child process' uid and gid are correctly set.
PR-URL: https://github.com/libuv/libuv/pull/1024
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This change refactors the `fs_event_close_in_callback` test so that:
1. It creates directory entries instead of modifying them. This allows
the test to work on operating systems that use event ports to handle fs
events (e.g SmartOS and Solaris). When using event ports, watching
only a directory does not allow to receive events for files modified
within that directory, but events will be received for files _created_
within that directory.
2. it generates fs events _after_ the process entered the libuv event
loop. This is also needed to make the test work on operating systems
that use event ports to handle fs events (e.g SmartOS and Solaris),
because events are polled as part of running the event loop. That also
makes the test work on systems based on Kqueue and on AIX.
Fixes: https://github.com/libuv/libuv/pull/808
PR-URL: https://github.com/libuv/libuv/pull/1011
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Print `errmsg` on TAP output. After making the TAP output the default,
the info in `errmsg` was not being used anymore.
PR-URL: https://github.com/libuv/libuv/pull/1012
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
uv_sleep uses only usleep which can only take integers in the
range [0,1000000]. Avoid using boundary parameters such as 1000000
for portability reasons. Use sleep and usleep together to expand
the acceptable range of values for uv_sleep.
PR-URL: https://github.com/libuv/libuv/pull/950
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
autotools support only, gvp does not support kfreebsd detection.
PR-URL: https://github.com/libuv/libuv/pull/960
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
It's not impossible for connect() to succeed before the handle is fully
closed, so handle that case too.
PR-URL: https://github.com/libuv/libuv/pull/1005
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
- zos: disable test cases not applicable
- zos: build options
- zos: semaphore implementation
- zos: use compare and swap builtins
- zos: struct rusage not the same as other platforms
- zos: backlog<=0 produces undefined behaviour
Will redefine backlog in the following way
* if backlog == 0, set it to 1
* if backlog < 0, set it to SOMAXCONN
- zos: define IMAXBEL as empty flag and implement uv__tty_make_raw
- zos: use udp multicast operations from aix
- zos: ESC in ebcdic
- zos: use LIBPATH for dynamic linker path
- zos: uv_udp_set_ttl only works for ipv6
- zos: increase pthread stack size by factor of 4
- zos: return ENODEV instead of ENXIO errors for setsockopt
- zos: use uv_cond_init the same way as aix
- test: enable oob test for zos
- zos: return EINVAL for zos error code EOPNOTSUPP
PR-URL: https://github.com/libuv/libuv/pull/937
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Treat both the base being NULL or the length being 0 as ENOBUFS.
PR-URL: https://github.com/libuv/libuv/pull/997
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Do not compile 'tty_pty' test for android.
PR-URL: https://github.com/libuv/libuv/pull/975
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
After 4ed29c2498 got fixed, when a CRT fd
is handed off to a pipe handle using uv_pipe_open libuv will close it
properly, so it's an error to do so ourselves.
PR-URL: https://github.com/libuv/libuv/pull/992
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Libuv leaves loop->data unchanged in uv_loop_init() and uv_loop_done()
on Windows but it clobbered it on UNIX platforms. This commit fixes
that inconsistency.
PR-URL: https://github.com/libuv/libuv/pull/951
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit causes uv_get_process_title() to:
- return EINVAL if the buffer is null or size is 0
- return ENOBUFS if the title is too big for the buffer
- null terminate the buffer on success
Fixes: https://github.com/libuv/libuv/issues/315
PR-URL: https://github.com/libuv/libuv/pull/928
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit causes Window file watching events to compare the
entire file path when filtering events. This fixes a bug where
incomplete path comparisons would cause invalid events to be
raised.
Refs: https://github.com/libuv/libuv/pull/682
PR-URL: https://github.com/libuv/libuv/pull/924
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Do not let `tty_pty` test fail if no terminals are available
to `openpty()`.
PR-URL: https://github.com/libuv/libuv/pull/919
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Put a space after the '#' and handle messages with newlines.
PR-URL: https://github.com/libuv/libuv/pull/898
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
A skipped test already prints a diagnostic. Dumping its output just
prints the same message twice.
PR-URL: https://github.com/libuv/libuv/pull/898
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
With the non-tap output, it's sometimes difficult to distinguish skipped
tests from test failures.
PR-URL: https://github.com/libuv/libuv/pull/898
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
It is not guaranteed which stream will read the data first.
PR-URL: https://github.com/libuv/libuv/pull/807
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Closing the handle does not make ReadConsoleW exit reliably on
Windows 7 and above. Thus, after switching from line to raw mode,
keypresses were held until enter was pressed. This makes ReadConsoleW
exit by writing a return keypress to its input buffer, similar to
what was already done for raw mode.
Fixes: https://github.com/libuv/libuv/issues/852
PR-URL: https://github.com/libuv/libuv/pull/866
Reviewed-by: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
On AIX, if a 'accept' call fails ECONNRESET is set on the socket which
causes uv__emfile_trick to not work as intended and this test to fail.
Fixes: https://github.com/libuv/libuv/issues/845
PR-URL: https://github.com/libuv/libuv/pull/870
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
`POLLHDRUP` is not implemented on AIX. Therefore `UV_DISCONNECT` will
never be set on `events`. This causes the socket to never be closed and
the tests to be stuck inside `pollset_poll` indefinitely, resulting in a
timeout.
This fixes the following tests:
- poll_duplex
- poll_unidirectional
Updated docs to let end users know that `UV_DISCONNECT` can be set, but
is unsupported on AIX.
Fixes: https://github.com/libuv/libuv/issues/844
PR-URL: https://github.com/libuv/libuv/pull/857
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Cast the `ru_majflt` and `ru_maxrss` field to `unsigned long long` when
printing them with `"%llu"`.
Warnings introduced in commit 6f17a61 ("win: add maxrss, pagefaults to
uv_getrusage()".)
PR-URL: https://github.com/libuv/libuv/pull/855
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit populates the ru_majflt and ru_maxrss fields of
uv_getrusage() on Windows.
PR-URL: https://github.com/libuv/libuv/pull/805
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
The file descriptor that you receive from ahafs has to be part of the
pollset_poll set of interest in order to receive events. This does not
happen until we are in the event loop causing the test to hang and
therefore timeout.
PR-URL: https://github.com/libuv/libuv/pull/838
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
'futimens' is only implemented on AIX 7.1. Other functions like
'utimes' and 'utimes' are merely stub functions that return ENOSYS
on AIX 6.1 and below. Skip test fs_futime for AIX versions below 7.1.
PR-URL: https://github.com/libuv/libuv/pull/811
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Currently, the tests assert that the home directory doesn't end
in a slash. However, if the home directory is / or something like
C:\, then this assertion is incorrect. This commit adds special
handling for these cases.
Fixes: https://github.com/libuv/libuv/issues/812
PR-URL: https://github.com/libuv/libuv/pull/813
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Find the real name of the tty using ttyname_r(3) instead of
opening "/dev/tty" which causes trouble if the fd doesn't point to the
controlling terminal.
PR-URL: https://github.com/libuv/libuv/pull/779
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The uid and gid fields in uv_passwd_t are of type long so use %ld for
printing them. Fixes two -Wformat compiler warnings.
PR-URL: https://github.com/libuv/libuv/pull/797
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit adds the copyright header to the two tests that
were missing it.
PR-URL: https://github.com/libuv/libuv/pull/782
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Calling uv_cond_wait without uv_cond_signal/uv_cond_broadcast may
cause deadlock. This commit avoids this situation as well as tests
these functions.
PR-URL: https://github.com/libuv/libuv/pull/728
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
libuv has multiple functions which return buffers. Make them consistent
with the following rules: the returned size *does not* include the null
byte, but the buffer *is* null terminated.
There is only one exception to the above: Linux abstract sockets,
because null bytes are not used as string terminators in those.
Refs: https://github.com/libuv/libuv/pull/674
PR-URL: https://github.com/libuv/libuv/pull/690
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Somtimes (once every 10 runs or so) the socket would 'connect' before
'uv_close' was called. This caused EHOSTUNREACH to be set for SO_ERROR
instead of ECANCELED.
PR-URL: https://github.com/libuv/libuv/pull/744
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
On PPC (linux and AIX) uv_thread_join (which is just a call to
pthread_join) takes quite a while. Increased the timeout of this
specific test on PPC so that there is ample time for all threads to join
back. The fs_do and getaddrinfo_do calls do not take up much time.
Also removing the ifdef for AIX around fs_do since it did nothing.
Fixes: https://github.com/libuv/libuv/issues/687
PR-URL: https://github.com/libuv/libuv/pull/737
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Libuv would abort() when trying to watch a file descriptor that is
not compatible with epoll-style polling; file descriptors referring
to on-disk files fall into this category.
File descriptors that libuv creates itself are not an issue but
external ones that come in through the uv_poll_init() API are.
Make uv_poll_init() check whether the file descriptor is accepted by
the underlying system call and return an error when it's not.
Fixes: https://github.com/libuv/libuv/issues/658
PR-URL: https://github.com/libuv/libuv/pull/659
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Disabled the filesystem portion of the test as there are known issues
with AIX and its fs. This particular test was failing with a timeout.
PR-URL: https://github.com/libuv/libuv/pull/689
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
If the child process reaches uv_run before the parent has closed the
write end of the pipe the test fails with the following output:
Assertion failed in test/test-pipe-close-stdout-read-stdin.c
on line 86: uv_run(uv_default_loop(), UV_RUN_NOWAIT) == 0
Assertion failed in test/test-pipe-close-stdout-read-stdin.c
on line 97: WIFEXITED(status) && WEXITSTATUS(status) == 0
This is mainly seen on AIX, but does not mean that it can not occur on
linux. This change causes the child process to be blocked until the
write end of the pipe is properly closed. See 'man 7 pipe'[0] for
more detail.
[0]http://linux.die.net/man/7/pipe
PR-URL: https://github.com/libuv/libuv/pull/688
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
uv__fs_buf_iter currently sets req->bufs to NULL after it is done, but
if the operation fails with EINTR then it will be retried, at which
point it expects the bufs to not be NULL, causing a seg fault as in
https://github.com/nodejs/node/issues/4291.
uv__fs_buf_iter should not set req->bufs to NULL if the operation
fails with EINTR.
Also, when it sets req->bufs to NULL, it should set req->nbufs to 0 as
well, so we don't have the messy situation of a positive nbufs with no
actual bufs.
PR-URL: https://github.com/libuv/libuv/pull/661
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Trying to acquire a rwlock that the current thread already owns may fail
(not "shall fail") with EDEADLK. Libuv considers that a fatal error and
rightly so in my opinion; it normally means the program contains a logic
error.
The test had indeed logic errors. This commit splits off the UV_EBUSY
return code testing into a separate thread, eliminating the potential
for self-deadlock.
Fixes: https://github.com/libuv/libuv/issues/544
PR-URL: https://github.com/libuv/libuv/pull/649
Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The following changeset
442b8a5a84 "unix: use QUEUE_MOVE when iterating over lists"
introduced a new assert failure:
`queue_foreach_delete` failed: exit code 6
Output from process `queue_foreach_delete`:
run-tests: src/unix/linux-inotify.c:244: uv_fs_event_stop: Assertion `w != ((void *)0)' failed.
Simplest test case for this:
1. create and start two uv_fs_event_t for the same path;
2. in the callback for the first one, call uv_close() on it;
3. assert/segfault while accessing the second uv_fs_event_t from uv__inotify_read().
PR-URL: https://github.com/libuv/libuv/pull/621
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The test adds all types of handles, that were known to be affected by
QUEUE_REMOVE()-within-QUEUE_FOREACH() bug, to a loop.
It then calls uv_close() to trigger QUEUE_REMOVE()-within-QUEUE_FOREACH() case
and checks whether a particular QUEUE is corrupted or not.
Restrict the test to Linux only for now as it fails on other platforms
for various reasons.
PR-URL: https://github.com/libuv/libuv/pull/621
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
On Windows the pipe implementation could read more from a stream than
was available and it would create an assertion failure. This change
will make it so we read the minimum of the available data or the length
of the data.
To test this, I took the existing ipc_send_recv_tcp test and updated it
to do two writes and two read on each side of the pipe since that was the
reproduction recipe used by the reporter. This approach reproduced the
issue on Windows and the committed fix resolved the issue.
Fixes: https://github.com/libuv/libuv/issues/505
PR-URL: https://github.com/libuv/libuv/pull/549
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Previous behavior on Windows was to set the path to NULL for removed
and renamed fs events. This was because the path provided by
ReadDirectoryChangesW might (in rare cases) be an 8.3 short name which
could then no longer be converted to a long name after the path had
been removed or renamed. This meant that the user had to detect which
path was actually deleted or renamed and required the user to rescan
the entire watched subtree, taking several seconds or more for large
subtrees.
However, ReadDirectoryChangesW is publicly documented to emit 8.3
short names if the original handle for the changed path was opened
using an 8.3 short name, and libuv may already emit 8.3 short names for
other events if the path cannot be explicitly resolved to a long name.
This commit fixes the path for removed and renamed fs events, and does
not set the path to NULL, even if the path might be an 8.3 short name.
This makes it possible for the user to do a partial scan of the
subtree, restricting the scan to paths which match the long form or 8.3
short name (even if some of these are false positive matches). This
means that deletes and renames can now be detected accurately on
Windows within a few milliseconds.
Fixes: https://github.com/libuv/libuv/issues/634
Refs: https://github.com/libuv/libuv/pull/199
PR-URL: https://github.com/libuv/libuv/pull/639
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Equivalent to realpath(3), returns the full resolved absolute path of a
file or directory.
PR-URL: https://github.com/libuv/libuv/pull/531
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
'/dev/random' causes 'isatty()' to return 1 on AIX[1]. This causes
an issue where 'dev/tty' is opened (hard coded in
src/unix/tty.c:uv_tty_init). Tried to replace the hardcoded value with
what is returned by 'ttyname()' but on AIX all that is returned is
'/dev/'.
This seems to be a bug with the AIX kernel.
[1]http://goo.gl/wGa7mf
PR-URL: https://github.com/libuv/libuv/pull/624
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
~~~~
test/test-get-loadavg.c:30:14: warning: comparison of array 'avg' not
equal to a null pointer is always true [-Wtautological-pointer-compare]
test/test-getnameinfo.c:76:18: warning: comparison of array 'req.host'
not equal to a null pointer is always true
[-Wtautological-pointer-compare]
test/test-getnameinfo.c:77:18: warning: comparison of array
'req.service' not equal to a null pointer is always true
[-Wtautological-pointer-compare]
~~~~
PR-URL: https://github.com/libuv/libuv/pull/622
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
By default, FreeBSD has net.inet6.ip6.v6only set to 1 (i.e., no dual stack
support). A new function can_ipv6_ipv4_dual is added to check its value and
decide whether `udp_dual_stack` test must be skipped or not.
PR-URL: https://github.com/libuv/libuv/pull/614
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
uv_(get|set)_process_title is not implemented for AIX. See unix/aix.c
PR-URL: https://github.com/libuv/libuv/pull/616
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
When duplicating the socket handle being sent the target process
id is defaulted to the current process id. This enables uv_write2
to be used for thread-clustering in addition to process-clustering on
multi-threaded programming languages.
The ipc tests are updated to run in two modes. In the _inproc mode
the echo work is done on a second thread instead of in a second
process.
An internal function int uv_current_pid() is added to the windows
specific code which caches the value of GetCurrentProcessId(). This
means uv_write2 does not call GetCurrentProcessId() every inprocess
send.
Refs: https://github.com/joyent/libuv/issues/926
PR-URL: https://github.com/libuv/libuv/pull/540
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
In FreeBSD 10.2 the test sometimes times out because the "touch file"
timer fires before the "watch file" event has been registered in the
kqueue. Increasing the timeout value seems to fix the issue.
PR-URL: https://github.com/libuv/libuv/pull/581
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Valgrind blocks the setrlimit() system call. Print a warning and skip
the test, don't consider it a fatal error.
PR-URL: https://github.com/libuv/libuv/pull/565
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
uv_os_fd_t is HANDLE on Windows, but closesocket needs a SOCKET.
PR-URL: https://github.com/libuv/libuv/pull/534
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
In FreeBSD if connect is called and the queue of pending connections(backlog)
is full, the call is automatically rejected with ECONNRESET. In the tests, 100
connections were tried and the backlog of both servers is 12, so the error.
To fix ipc_listen_before_write and ipc_listen_after_write, the backlog of the
server has been increased to 128.
PR-URL: https://github.com/libuv/libuv/pull/504
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
fs_access, fs_async_dir and fs_symlink_dir could fail when the
filesystem where the tests are run does not fully support getting the
file type via getdents. Having getdents support does not imply that the
underlying filesystem fully supports what is necessary for these tests
to have passed prior to this commit. So the failing tests were updated
to check for UV_DIRENT_FILE as it did previously but it will also check for
UV_DIRENT_UNKNOWN as well to handle the filesystems that do not fully support
getting the file type via getdents. For OS X and Windows, which are
known to fully support getting the file type, the tests work as they did
before and will not check for UV_DIRENT_UNKNOWN. We could/should update the
preprocessor directive that chooses "rigorous" or "lax" checks
accordingly when we learn of new environments that should always do the
original "rigorous" checks.
Fixes: https://github.com/libuv/libuv/issues/501
PR-URL: https://github.com/libuv/libuv/pull/508
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
It's an error to do so, so just ignore it. The test would cause an
invalid memory access if the fix is undone.
PR-URL: https://github.com/libuv/libuv/pull/488
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
On Windows we create multiple pipe handles (system handles) which are
attached to pending accept requests. Each of these will take turns in
replacing the reference in handle->handle, so make sure we allow for
that **only** for pipe servers.
PR-URL: https://github.com/libuv/libuv/pull/488
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
fs_event_watch_dir and fs_event_watch_dir_recursive could fail randomly
due to the way in which the tests were written. Originally timers were
used to create, remove and recreate the test files but this could lead
to a race condition if the timeout used to delete the test files ran
before all file creation fs events were handled. On top of that, the
file removal timer scheduled another timer to recreate the test files
and that timer's timeout could also lead to the same condition.
The refactoring removed timers for the removal/recreation of the test
files and instead the fs event callback was updated to have the
necessary logic to drive the test file removal. We no longer recreate
the test files since it appears to be unnecessary.
Fixes: https://github.com/libuv/libuv/issues/30
PR-URL: https://github.com/libuv/libuv/pull/480
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Join the watchdog thread unconditionally on exit. Fixes the following
harmless but noisy memory leak:
576 bytes in 1 blocks are possibly lost in loss record 1 of 2
at 0x4C2A9C7: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x40121B4: _dl_allocate_tls (in /usr/lib64/ld-2.21.so)
by 0x5AEA045: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.21.so)
by 0x450D3E: process_wait (runner-unix.c:212)
by 0x4067F1: run_test (runner.c:284)
by 0x405EC3: maybe_run_test (run-tests.c:180)
by 0x4058AD: main (run-tests.c:57)
PR-URL: https://github.com/libuv/libuv/pull/479
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This allows writing and reading any amount of buffers,
regardless of what IOV_MAX may be defined as.
It also moves the IOV_MAX test from stream to core.
This is based on the excellent work of @bwijen in #269.
Refs: https://github.com/libuv/libuv/pull/269
PR-URL: https://github.com/libuv/libuv/pull/448
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
file_prefix_in_subdir is only used in Windows and OSX. Fixes the
following warning, which shows up with Clang:
test/test-fs-event.c:40:19: warning: unused variable
'file_prefix_in_subdir' [-Wunused-const-variable]
static const char file_prefix_in_subdir[] = "subdir";
PR-URL: https://github.com/libuv/libuv/pull/450
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Ifdef out the tests that rely on internal symbols when making a shared build.
PR-URL: https://github.com/libuv/libuv/pull/444
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Do not hard-fail network tests when libuv is built on
an isolated host/container.
Signed-off-by: Luca Bruno <lucab@debian.org>
PR-URL: https://github.com/libuv/libuv/pull/437
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Add new UV__POLLRDHUP event to be emitted when EPOLLRDHUP(in Linux) or
EV_EOF(in BSD / OSX) is detected and only if UV_READABLE is set.
When a read returns ECONNRESET after a UV__POLLRDHUP event, emit EOF instead
of the error.
Add tcp-squelch-connreset test. Not to be run on Windows as it returns
ECONNRESET error.
Fixes in test-poll and test-tcp-open so they pass after these changes.
PR-URL: https://github.com/libuv/libuv/pull/403
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Some 32 bits architectures, linux/mips and linux/mipsel in particular,
suffer from address space fragmentation when spawning many threads
with the default 8 MB stack size. The watchdog threads don't need
much stack space, all they do is sleep until the monitored process
exits, so lower it to 256 kB.
Fixes: https://github.com/libuv/libuv/issues/408
PR-URL: https://github.com/libuv/libuv/pull/429
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
UV_HANDLE_CONNECTED was defined, but never used anywhere - outside this if
condition inside uv__stdio_create. So this test can't be true.
UV_HANDLE_CONNECTION was meant.
A test was also added verifying the behaviour.
PR-URL: https://github.com/libuv/libuv/pull/404
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Make the test runner code that waits for other processes to terminate
retry the select() system call on EINTR and take elapsed time into
account.
A small side effect of this change is that millisecond timeout values
are now honored.
PR-URL: https://github.com/libuv/libuv/pull/410
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Introduce two new APIs:
int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, int flags)
int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, int flags)
The lower 8 bits of the flags field are used for the socket domain.
AF_INET, AF_INET6 and AF_UNSPEC are supported. If AF_UNSPEC is specified
the socket is created lazily, just like uv_{tcp,udp}_init.
Some Windows notes:
getsockname fails with WSAEINVAL if the socket is not bound. This could
potentially be improved by detecting the socket family and filling
the sockaddr_in/6 struct manually.
bind returns WSAEFAULT if we try to bind a socket to the wrong family.
Unix returns EINVAL.
PR-URL: https://github.com/libuv/libuv/pull/400
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Prior to MSVC 2015, the standard C99 `inline` keyword was missing,
added a compiler version check and disabled the inline replacement for
MSVC >= 2015 in test/task.h.
Refs: https://github.com/libuv/libuv/pull/341
PR-URL: https://github.com/libuv/libuv/pull/369
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The implementation will leave the family set to `AF_UNSPEC` if a
netmask is not present, but the test driver would always print the
uninitialized buffer as an `AF_INET4` address. It will now print
"none" if there is no netmask (e.g., for loopback interfaces).
PR-URL: https://github.com/libuv/libuv/pull/373
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Prior to MSVC 2015, there was no standard compliant snprintf(), added a
compiler version check and disabled the snprintf() replacement for MSVC >=
2015 in test/task.h.
PR-URL: https://github.com/libuv/libuv/pull/341
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The MSVC compiler does not accept static methods defined in headers,
when linking against a shared library. The snprintf replacement
function used for windows, is now an inline function.
PR-URL: https://github.com/libuv/libuv/pull/329
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
For posterity, these are the rules for access on Windows (taken from
CPython's implementation), Access is possible if:
* Write access wasn't requested
* The file isn't read-only
* It's a directory (directories cannot be read-only on Windows)
PR-URL: https://github.com/libuv/libuv/pull/316
Reviewed-By: Bert Belder <bertbelder@gmail.com>
If the handle is closed when it wasn't initialized, uv_close will fail.
PR-URL: https://github.com/libuv/libuv/pull/279
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
uv_tty_reset_mode() is designed to be async signal-safe and is therefore
not allowed to clobber errno.
PR-URL: https://github.com/libuv/libuv/pull/259
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The UV_TTY_MODE_* enumeration values were introduced in commit 025602d
("tty: implement binary I/O terminal mode") but the test was not updated
to use them. This commit rectifies that.
PR-URL: https://github.com/libuv/libuv/pull/259
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
In the collaboration with Ben Noordhuis <info@bnoordhuis.nl> and
Saúl Ibarra Corretgé <saghul@gmail.com>.
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Also make the tests more strict.
PR-URL: https://github.com/libuv/libuv/pull/201
Reviewed-By: Tim Caswell <tim@creationix.com>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Commit 393c1c5 ("unix: set non-block mode in uv_{pipe,tcp,udp}_open")
causes a regression in the io.js cluster module.
The io.js documentation states that `worker.send()` and `process.send()`
are synchronous but they no longer were after upgrading to libuv v1.2.1.
The reason they are synchronous is because of backpressure - or rather,
lack of backpressure: a slow consumer eventually causes a fast producer
to run out of memory because the backlog of pending messages in the
producer can grow unchecked.
Ergo, implement uv_stream_set_blocking() on UNIX platforms to let io.js
enable the old blocking behavior for pipes again.
Refs: https://github.com/iojs/io.js/issues/760
PR-URL: https://github.com/libuv/libuv/pull/187
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The Windows spawn_with_an_odd_path test builds a PATH variable that
starts with ";.;". However, the old path is then used to run the test.
This commit updates the test to use the new path.
PR: https://github.com/libuv/libuv/pull/184
Reviewed-by: Bert Belder <bertbelder@gmail.com>
libuv requires that the socket/fd is in non-blocking mode, so do it
internally so the user doesn't need to write platform specific code to
do so.
This also makes the API consistent with uv_{tcp,udp,pipe}_open, since
it's not required to pass the fd in non-blocking mode there either.
PR-URL: https://github.com/libuv/libuv/pull/136
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
The contract specifies that the file descriptor should already be in
non-blocking mode before passing it to libuv.
However, node users don't really have an opportunity to do so, never
mind the fact that the call to uv_pipe_open() or uv_tcp_open() is an
implementation detail that most users won't be aware of.
Let's be nice and set the non-blocking flag explicitly. It's a cheap
operation anyway.
Fixes: https://github.com/libuv/libuv/issues/124
PR: https://github.com/libuv/libuv/pull/134
Reviewed-by: Saúl Ibarra Corretgé <saghul@gmail.com>
uv_exepath() should write as much as possible to the output buffer.
In the case of size=1, skip the call to readlink() because it will
fail with EINVAL; just write the terminating zero byte.
PR-URL: https://github.com/libuv/libuv/pull/104
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Passing a buffer that was too small to hold the result made it fail
with UV_EPERM because the -1 status code from _NSGetExecutablePath()
was returned unmodified to the caller.
This commit rewrites uv_exepath() to:
1. Not allocate heap memory, and
2. Not clobber the result buffer on error, and
3. Handle _NSGetExecutablePath()'s and realpath()'s idiosyncracies, and
4. Store as much of the path in the output buffer as possible, don't
fail with an error. Makes it behave the same as other platforms.
The result is always zero-terminated.
Fixes: https://github.com/libuv/libuv/issues/103
PR-URL: https://github.com/libuv/libuv/pull/104
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Make the behavior of a call to uv_exepath() with a size argument of zero
consistent with the Windows implementation where it returns UV_EINVAL.
PR-URL: https://github.com/libuv/libuv/pull/104
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Fix spawn_reads_child_path when executed as `test/run-tests` or
`make check`:
1. `make check` builds a dynamic libuv.so or libuv.dyld by default.
2. spawn_reads_child_path spawns a new instance of the test runner
by consulting uv_exepath() and executing the result.
3. `test/run-tests` is normally a shell script that sets up
DYLD_LIBRARY_PATH or LD_LIBRARY_PATH before executing the
real test runner in `test/.libs`.
4. uv_exepath() (corectly) returns the path of the binary in
`test/.libs`. The binary is linked against libuv.so but that
library is not on any of the default linker paths; and if it is,
it's almost certainly the wrong version.
5. Ergo, carry over the value of the (DY)LD_LIBRARY_PATH environment
variable into the environment of the child process so that the
dynamic linker knows where to find the library.
Alternatively, we could link the test runner statically against libuv.a
but that breaks `make check` when configured with `--disable-static`.
Fixes: https://github.com/libuv/libuv/issues/85
PR-URL: https://github.com/libuv/libuv/pull/91
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Revisit the fix from commit b705b53. The problem with using sigset_t
and _NSIG is that the size of sigset_t and the value of _NSIG depend
on what headers libuv picks up first, <signal.h> or <asm/signal.h>.
With the former, sizeof(sigset_t) = 128; with the latter, it's 8.
Simply sidestep the issue by calculating the signal mask as a 64 bits
integer, without using sigset_t or _NSIG.
PR-URL: https://github.com/libuv/libuv/pull/83
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
There is no need to check for a trailing slash, uv_cwd ensures it.
PR-URL: https://github.com/libuv/libuv/pull/63
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Check uv_dlerror() doesn't return "no_error", in order to make the test
less dependent on the exact error message the platform produces when
loading a dynamic library fails.
PR-URL: https://github.com/libuv/libuv/pull/59
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
PR-URL: https://github.com/libuv/libuv/pull/67
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1502 is not enough, since there are other fds which are in use
internally.
PR-URL: https://github.com/libuv/libuv/pull/67
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
More often than not, users run the test suite from /root, which means
the 'nobody' user won't be able to access the test runner and the test
will fail because we drop privileges to that user. Just skip it then.
PR-URL: https://github.com/libuv/libuv/pull/66
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
The test used to call uv_cwd() twice, in this fashion:
char buf[PATH_MAX];
size_t size = sizeof buf;
uv_cwd(buf, &size);
uv_cwd(buf, &size);
The `size` variable is supposed to contain the buffer size (including
terminating null) on input, and it is also used as an out parameter for
returning the actual length of the working directory (not including the
terminating null). This makes the second uv_cwd() call fail with
UV_ENOBUFS.
PR-URL: https://github.com/libuv/libuv/pull/54
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
* Check whether uv_fs_symlink() succeeds.
* Bail out early if we're on an old version of windows, or if we're not
able to create symlinks because we're not elevated.
PR-URL: https://github.com/libuv/libuv/pull/55
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This happens in certain build environments such as Jenkins if
some tweaking is not performed in the host system.
PR-URL: https://github.com/libuv/libuv/pull/22
The get_currentexe test requires a canonicalized argv[0] to check
against. Before this commit, it failed when argv[0] contained symbolic
links.
Fixeslibuv/libuv#18.
When multiple bufs are specified, overlapped needs to be advanced
manually between each write. Without this, each buf will be written
to the same position (if offset is specified.)
ReadFile() automatically advances, but WriteFile() does not.
The echo server shouldn't close the connection when there's an error on
write. Instead simply echo the error message and allow the other side to
close the connection.
Also do a partial revert of 4d905fb where after_shutdown was removed.
Fixes: 4d905fb "test: close stream immediately on error"
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Signed-off-by: Saúl Ibarra Corretgé <saghul@gmail.com>
`fd_set`s are way too small for `select()` hack when stream's fd is
bigger than 1023. Make `fd_set`s a part of `uv__stream_select_t`
structure.
fix#1461
Conflicts:
src/unix/stream.c
`fd_set`s are way too small for `select()` hack when stream's fd is
bigger than 1023. Make `fd_set`s a part of `uv__stream_select_t`
structure.
fix#1461
Returns the platform specific file descriptor for handles that are
backed by one. The datatype is abstracted as uv_os_fd_t, which maps to
int on Unices and HANDLE on Windows.
Users can use this function to set specific socket options, for example,
in a non portable way.
This function is essentially a shotgun, you better be careful with
whatever you do with it, don't blame me if you used it to get the fd of
a stream, close it yourself and expect things to Just Work.
If the connect wouldn't go off (no such tcp remote or any other failure),
the subsequent writes made would not be called. Now we call the writes
in the queue with ECANCELED if the connect fails.
Fix#1432
This fixes a SmartOS specific issue that happens when reading from
a stream that is the reading end of a pipe that has been closed by
the parent process.
In this case, a UV__POLLHUP event would be set on the stream and would
prevent the event loop from closing it. As a result, the event loop
would think there are stil handles open, and leave the process
hanging.
Fixes#1419.
Support all possible types on Unix, and files, directories and links on
Windows. Some systems (hello SunOS!) don't have the d_type field on struct
dirent, so mark them as UV_DIRENT_UNKNOWN.
Introduce:
int uv_fs_readdir_next(uv_fs_t* req, uv_dirent_t* ent);
`uv_fs_readdir()` is not returning a file names list in `req->ptr`
anymore, the proper way to gather them is to call `uv_fs_readdir_next()`
in a callback.
As of right now Linux comes with bindv6only=0 by default but BSDs use
bindv6only=1. It can be changed systemwide with sysctl, but it's not
nice to depend on the environment for running tests, so disable it just
on BSDs.
This implements locking around the blocking call to ReadFile to get
around a Windows kernel bug where a blocking ReadFile operation on a
stream can deadlock the thread. This allows uv_read_stop to immediately
cancel a pending IO operation, and allows uv_pipe_getsockname to
"pause" any pending read (from libuv) while it retrieves the
sockname information.
If unsupported by the OS (pre-Vista), this reverts to the old
(e.g. deadlock-prone) behavior
Closes#1313
The unix and windows process implementations diverge in their behavior
when dealing with subprocesses that are spawned with a relative path.
With unix the *child's* PATH environment variable is read, whereas
with windows the *parent's* environment variable is read.
This commit brings the two implementation in line with respect to
their behavior of reading PATH by having both read the *child's* PATH
environment variable. This involves looking into the user-provided
environment on windows and extracting the PATH variable specifically
so it can be inspected later on.
This is the libuv side of the fix for Node's cluster module on Windows.
https://github.com/joyent/node/issues/7691
Windows and Unix return certain socket errors (i.e. EADDRINUSE) at
different times: bind on Windows, and listen on Unix.
In an effort to hide this difference, libuv on Windows stores such
errors in the bind_error field of uv_tcp_t, to defer raising it at
listen time.
This worked fine except for the case in which a socket is shared in
a Node cluster and a bind error occurs.
A previous attempt to fix this (
d1e6be14603da36fe00e
) was flawed becaused in an attempt to relay the error at the JS level
it caused the master to start accepting connections.
With this new approach, libuv itself is relaying the bind errors,
providing for a uniform behavior of uv_tcp_listen.
After 41891222bc landed it's possible that uv__udp_sendmsg is called
even if there are no pending write nor write completed requests:
1. User calls uv_udp_send and the request is sent immediately. The
request is the added to the completed queue and we 'feed' the uv__io
handle so that we process the completed request in the next
iteration.
2. User calls uv_udp_send again but the request is not completed
immediately, so it's queued in the write_queue.
3. The uv__io handle gets a UV__POLLOUT event and uv__udp_sendmsg is
run, which completes the send request and puts it in the
write_completed_queue. Afterwards, uv__udp_run_completed is executed
and the write_completed queue is drained.
4. At this point, the uv__io handle was made pending in step 3, in
uv__udp_sendmsg, but we no longer have requests to write or to complete,
so we skip processing.
It's possible that recv_cb_called is bigger than the number of sockets,
because if all sends succeed the recv callback is called twice: once
with the actual data, and another time with 0.
This functionality is present in stream and uv_udp_t has a queue
as well so it makes sense for udp to have a send_write_size.
Since udp sends entire messages atomically, the send_queue_count field
lets the user determine how many messages are there left to send.
A correct barriers implementation blocks in uv_barrier_destroy() until
the last thread returns from uv_barrier_wait() so make the test more
rigorous by destroying the barrier straight away instead of first
joining the worker thread.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
Make uv_barrier_wait() return a boolean value indicating whether this
thread was the "serializer".
From `man pthread_barrier_wait`:
Upon successful completion, the pthread_barrier_wait() function
shall return PTHREAD_BARRIER_SERIAL_THREAD for a single (arbitrary)
thread synchronized at the barrier and zero for each of the other
threads.
Exposing that information from libuv is useful because it can make
cleanup significantly easier:
if (uv_barrier_wait(&barrier) > 0)
uv_barrier_destroy(&barrier);
Signed-off-by: Fedor Indutny <fedor@indutny.com>
Only these functions will trigger an implicit binding of a UDP handle:
- uv_udp_send
- uv_udp_recv_start
- uv_udp_set_membership
All other functions will return UV_EBADF in case the socket was not
bound.
Note: currently the socket is created and bound at the same time. This
may change in the future.
If there is an error in the uv_read_cb, close the uv_stream_t
immediately instead of waiting until the uv_write_cb, and only close the
stream in after_write() if it hasn't been closed already.
The PATH-parsing code for windows erroneously contained an infinite
loop when the PATH started with a leading semicolon. Each iteration of
the loop usually bumped over the separator, but if the first character
was a semicolon then it would never skip it, causing the infinite
loop.
Closes#909
Add UV_UDP_REUSEADDR flag instead, which can be passed to uv_udp_bind.
If the udp handle is unbound when uv_udp_set_memberhsip or
uv_udp_set_multicast_interface is called, the handle will be bound with
UV_UDP_REUSEADDR set.
When choosing an IPv6 interface all low level APIs use the interface
index which can be gathered with if_nametoindex. Passing a 0 means to
use the default as per the documentation. On OSX, however, this is not
the case and when 0 is specified it gives EADDRNOTAVAIL error. So, we
workaround the test, by using the 'lo0' interface on OSX, which has an
index of 1.
If the same file description is open in two different processes, then
closing the file descriptor is not sufficient to deregister it from the
epoll instance (as described in epoll(7)), resulting in spurious events
that cause the event loop to spin repeatedly. So always explicitly
deregister it.
Fixes#1099.
Conflicts:
test/test-spawn.c
Introduce `int uv_pipe_pending_count(uv_pipe_t*)` and
`uv_handle_type uv_pipe_pending_type(uv_pipe_t*)`. They should be
used in IPC pipe's read cb to accept incoming handles:
int count = uv_pipe_pending_count(pipe);
int i;
for (i = 0; i < count; i++) {
uv_handle_type type = uv_pipe_pending_type(pipe);
/* ... */
uv_accept(...);
}
This improves API consistency with uv_read and uv_write and may
improve efficiency for some uses. Vectored IO is emulated when the
requisite system calls are unavailable.
These functions supersede uv_loop_new and uv_loop_delete.
uv_loop_init initialized a user allocated loop and uv_loop_close
removes all associated resources a loop uses after it has finished
execution.
uv_loop_new and uv_loop_delete are now deprecated.
If the same file description is open in two different processes, then
closing the file descriptor is not sufficient to deregister it from the
epoll instance (as described in epoll(7)), resulting in spurious events
that cause the event loop to spin repeatedly. So always explicitly
deregister it.
Fixes#1099.
This improves API consistency with uv_read and uv_write and may
improve efficiency for some uses. Vectored IO is emulated when the
requisite system calls are unavailable.
Every file descriptor opened using libuv should be automatically marked
as CLOEXEC to prevent it from leaking to a child process. Note that
since we are opening fds in a thread pool, there is a possible race
condition between `uv_spawn()` and the `open()` + `uv__cloexec()`. The
rwlock was added to avoid it.
see https://github.com/joyent/node/issues/6905
getaddrinfo_fail can sometimes take slightly longer than the default
timeout of 5000. Set its timeout to 10000 to compensate, but leave the
timeout of all other tests at the default.
Add a single TEST_ENTRY_CUSTOM hook that can be used to override task
entry defaults. Different tests can have different timeouts depending on
what is appropriate for each test. A separate TEST_OUTPUT_ENTRY hook is
no longer necessary.
In order to support per-task timeouts, the timeout field has been moved
into the task_entry_t struct. The default (5000) is now set as part of
TEST_ENTRY.
Thus allow passing the same file descriptor as the source of multiple
stdios.
Committed with the help and code parts from:
* Sam Roberts <sam@strongloop.com>
fix#1074
When a server and a client are both part of the same event loop, and
the client connects to the server, the order in which the connect
callback and the connection callback are called is unspecified.
Apparently on linux the connection callback sometimes happens first,
which is not a bug, and should not make this test fail.
Useful to know when the the event loop is empty, this can't be done with
uv_run() without possibly blocking, or running some events (which might
empty the event loop as a side-effect).
Allow UV_EACCES as a successful return value when uv_spawn fails.
When the PATH environment variable contains a directory which the
user cannot access, execvp may return EACCES instead of ENOENT.
fix#1045.
`uv_try_write(stream, buf, size)` acts like `uv_write()`,
but without queueing actual write until UV_POLLOUT (or IOCP completion).
This is useful for doing writes using on-stack `uv_write_t` requests.
fix#1025
Fix a bug that was introduced in commit 3ee4d3f ("unix, windows:
return error codes directly") and add a regression test for good
measure.
Hat tip to Fedor for pointing out the issue.
Fixes#1007.
When fd is closed and new one (with the same number) is opened inside
kqueue/epoll/port loop's callback - stale events might invoke callbacks
on wrong watchers.
Check if watcher was changed after invocation and invalidate all events
with the same fd.
fix#826
Otherwise `FSEventStreamCreate()` will coalesce events, even if they're
happening in the interval, bigger than supplied `latency`. In other
words, if this flag is not set events will happen in separate callback
only if there was a delay bigger than `latency` between two consecutive
events.
Work around an epoll quirk where it sometimes reports just the EPOLLERR
or EPOLLHUP event. In order to force the event loop to move forward,
we merge in the read/write events that the watcher is interested in;
uv__read() and uv__write() will then deal with the error or hangup in
the usual fashion.
Fixes#982.
Drops commit 3780e12 ("fsevents: support japaneese characters in path")
for being quite inapplicable to the master branch. Will be reworked
and applied in a follow-up commit.
Conflicts:
README.md
build.mk
src/unix/fsevents.c
src/unix/udp.c
If spawning a process fails due to an exec() failure (but it succeeded
in forking), then this should be considered a spawn failure instead of
an asynchronous termination of the process. This allows to check for
common exec() failure conditions such as a bad path quickly instead of
having to rely on keeping track of the async callback.
Additionally, the meaning of the two fields returned in the callback are
now exactly what they advertise to be. The process exit argument is not
one of two values depending on what happened to the child.
Fixes#978.
timer_again test makes an implicit assumption on the triggering
timing of a repeating timer. However, this assumption may be not
true on slower or virtualized architecture due to delay accumulation,
which may fail the test as show in [0].
This commit makes explicit checks conforming to the asserted behavior.
[0] http://ur1.ca/fr5c4
Signed-off-by: Luca Bruno <lucab@debian.org>
The loop_stop test makes an implicit assumption about the triggering
timing of a repeating trigger, which may not hold true on slower or
virtualized machines, thus failing the test as shown at [0] and
discussed at [1].
This commit relaxes the assumption, without mandating the exact number
of runs.
[0] http://ur1.ca/fr5bw
[1] https://groups.google.com/d/msg/libuv/5-fNIC7hIAo/yqznDmwHDAIJ
Signed-off-by: Luca Bruno <lucab@debian.org>
test-tty.c currently assumes that a TTY is available to the test runner,
and fails hard if not. This may not be true on some autobuilding
environment, making the build fail as shown in [0].
Instead, let's properly skip the test in such cases.
[0] http://ur1.ca/fr5bd
Signed-off-by: Luca Bruno <lucab@debian.org>
There're could be a situation, where one fsevents handle gets created
and another one is destroyed simultaneously. In such cases
`fsevent_need_reschedule` will be set to 1 twice and reset only once,
leaving handle destructor hanging in uv_sem_wait().
Ensure that close() system calls don't close stdio file descriptors
because that is almost never the intention.
This is also a partial workaround for a kernel bug that seems to affect
all Linux kernels when stdin is a pipe that gets closed: fd 0 keeps
signalling EPOLLHUP but a subsequent call to epoll_ctl(EPOLL_CTL_DEL)
fails with EBADF. See joyent/node#6271 for details and a test case.
* Add finer-grained measurements to the million_timers benchmark.
Before this commit it only measured the total running time.
* Bump the number of inserted timers from 1M to 10M. With one million
timers, it finishes too quickly to get useful profiling data out of
it with perf or oprofile. The name of the benchmark is now a lie but
such is life.
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.
Fixes#684.
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.
Fixes#684.
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.
Fixes#684.
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.
Fixes#684.
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.
Fixes#684.
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.
Fixes#684.
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.
Fixes#684.
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.
Fixes#684.
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.
Fixes#684.
Uses the pthread_key_{create,delete} and pthread_{get,set}specific
functions on UNIX platforms, Tls{Alloc,Free} and Tls{Get,Set}Value
on Windows.
Fixes#904.
This means we no longer have to strip the high bit from the process exit
code on Windows, which is problematic because an unhandled SEH exception
can make a process exit with a status code that has the high bit set.
Should fix the build after 96f32a2 inadvertently broke it.
There is no snprintf() on Windows because, hey, it's a C99 addition
and the people from Redmond, WA are still firmly stuck in 1989.
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.
A code snippet like this one:
if (uv_foo(loop) < 0) {
uv_err_t err = uv_last_error(loop);
fprintf(stderr, "%s\n", uv_strerror(err));
}
Should be rewritten like this:
int err = uv_foo(loop);
if (err < 0)
fprintf(stderr, "%s\n", uv_strerror(err));
The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
Don't try to set a bogus UID or GID and expect to get a meaningful
error. The test expected EPERM but SunOS returns EINVAL because the
id is outside of the range of valid user/group ids.
Try to switch to UID/GID 0. Give up privileges first if we're root,
else the setuid/setgid system call will succeed when it's expected
to fail.
The tests are no longer compiled with -D_XOPEN_SOURCE=500 when building
with autotools. Tell the test explicitly that SunOS systems are
expected to have nanosecond fstat(2) granularity.
Switch to the build tool everyone loves to hate. The Makefile has
served us well over the years but it's been acquiring more and more
features that autotools gives us for free, like easy static+shared
library building, sane install targets, and so on.
This commit drops MinGW support. If there is demand for it, we'll
re-add it.
Check that a timer that is started from a check handle gets picked up
correctly, i.e. that it influences the timeout used in the next tick
of the event loop.
They're BSD-isms and obsolete ones at that. Replace with S_IRUSR and
S_IWUSR. Alias as _S_IREAD and _S_IWRITE on Windows because the '90s
never ended in Redmond, WA.
Before this commit, creating an event loop, starting a timer and
calling uv_run(UV_RUN_ONCE) blocked in uv_run() until the timer
expired - but didn't actually run the timer.
Disable unit test failing due to missing implementation
of uv_(set|get)_process_title for Sun OS (SmartOS).
Based on discussion with @tjfontaine, such implementation is difficult
if possible at all and it won't be done anytime soon. Thus there is
no point in keeping the failing test around.
Shorten the test string from 40 to 38 characters because the title
length is limited to 39 characters.
Truncation of long titles was introduced intentionally by commit
a0c1d84 (see discussion in joyent/node#5006).