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.