Commit Graph

1541 Commits

Author SHA1 Message Date
cjihrig
0c28363059
win: allow setting udp socket options before bind
Unix allows socket options to be set prior to binding. This
commit aligns Windows with this behavior.

Refs: https://github.com/joyent/libuv/issues/1205
Refs: https://github.com/joyent/libuv/pull/1270
Fixes: https://github.com/libuv/libuv/issues/1842
PR-URL: https://github.com/libuv/libuv/pull/1861
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-06-04 09:19:06 -04:00
cjihrig
06fdc2bd0e
src,test: s/olny/only
PR-URL: https://github.com/libuv/libuv/pull/1848
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-05-30 13:29:15 -07:00
Ben Noordhuis
585dc821f3 test: use custom timeout for getaddrinfo_fail_sync
We don't control the running time of the test and as a result it
frequently times out on some of the CI buildbots.

We are already using a custom timeout for getaddrinfo_fail so it only
makes sense to do the same for its synchronous counterpart.

PR-URL: https://github.com/libuv/libuv/pull/1856
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-05-30 14:41:23 +02:00
Ben Noordhuis
2256be01b0 unix: catch some cases of watching fd twice
Libuv does not support multiple handles watching the same file
descriptor.  That condition is caught by an assert but it's detached
from the call site and therefore not always trivial to track down.

This commit turns cases where we can easily detect duplicates into
runtime `UV_EEXIST` errors.  More work is needed to catch _all_ cases.

Partially addresses https://github.com/libuv/libuv/issues/1172.

PR-URL: https://github.com/libuv/libuv/pull/1851
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-05-30 13:24:19 +02:00
Bert Belder
421d7571a3
test: add test for IPC deadlock on Windows (#1099)
PR-URL: https://github.com/libuv/libuv/pull/1843
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2018-05-29 13:01:59 -07:00
Bert Belder
b6eb3cef46
test: improve output from IPC test helpers
PR-URL: https://github.com/libuv/libuv/pull/1843
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2018-05-29 13:01:44 -07:00
Bert Belder
b36c0945d1
test: add vectored uv_write() ping-pong tests
PR-URL: https://github.com/libuv/libuv/pull/1843
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2018-05-29 13:01:23 -07:00
Bert Belder
e7e8b6fb9b
win,pipe: properly set uv_write_t.send_handle in uv_write2()
PR-URL: https://github.com/libuv/libuv/pull/1843
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2018-05-29 13:01:19 -07:00
Bert Belder
5191ab5e93
test: fs_fchmod_archive_readonly must return a value
PR-URL: https://github.com/libuv/libuv/pull/1843
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2018-05-29 13:01:05 -07:00
Bert Belder
9584df25dc
src,test: fix idiosyncratic comment style
Back in the day I wrote comments in a really unusual way. Nowadays it
makes my eyes bleed, and clang-format doesn't know how to deal with it.

PR-URL: https://github.com/libuv/libuv/pull/1853
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2018-05-29 11:56:49 -07:00
Tobias Nießen
02e358fa45
src,lib: fix comments
PR-URL: https://github.com/libuv/libuv/pull/1840
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-05-22 16:34:33 -04:00
Bartosz Sosnowski
b59fc58326 win, fs: uv_fs_fchmod support for -A files
Adds uv_fs_chmod support for files with the Archive attribute cleared

Ref: https://github.com/libuv/libuv/pull/1777
Ref: https://github.com/nodejs/node/issues/12803
PR-URL: https://github.com/libuv/libuv/pull/1819
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-05-17 09:27:09 +02:00
cjihrig
1954e9e3c1
Revert "win, fs: use FILE_WRITE_ATTRIBUTES when opening files"
This reverts commit aa1beaa07c.
This commit was causing EPERM errors in Node.js.

Fixes: https://github.com/nodejs/node/issues/20112
PR-URL: https://github.com/libuv/libuv/pull/1800
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2018-04-18 09:01:51 -04:00
Alex Arslan
0aa4ed0d0a
test,openbsd: fix multicast test
Use the same code path as other BSDs.

Upstreamed from the OpenBSD Ports Collection.

PR-URL: https://github.com/libuv/libuv/pull/1797
Reviewed-By: Aaron Bieber <deftly@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-04-17 11:49:02 +02:00
Alex Arslan
992a13df9b
test,openbsd: use RETURN_SKIP in UDP IPv6 tests
IPv6-IPv4 dual stack is not supported on OpenBSD.

Upstreamed from the OpenBSD Ports Collection.

PR-URL: https://github.com/libuv/libuv/pull/1797
Reviewed-By: Aaron Bieber <deftly@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-04-17 11:48:55 +02:00
zzzjim
19855c03ba
unix: fix uv_pipe_chmod() on macOS
According to its man page, there is a bug in fstat()
on macOS related to pipes. This commit replaces a
fstat() call in uv_pipe_chmod() with a stat() call in
order to get the correct permissions.

PR-URL: https://github.com/libuv/libuv/pull/1635
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-04-12 09:15:15 -04:00
John Barboza
67a00e27c1
test: increase connection timeout to 1 second
The previous timeout of 1 millisecond could lead to intermittent
failures. Increase it to 1 second to be on the safe side.

PR-URL: https://github.com/libuv/libuv/pull/1776
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-03-31 17:05:26 -04:00
Santiago Gimeno
9051126b56
test,freebsd: fix flaky poll tests
On FreeBSD `close()` can fail with `ECONNRESET` if the socket was
shutdown by the peer before all pending data was delivered.

PR-URL: https://github.com/libuv/libuv/pull/1780
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-03-31 16:59:41 -04:00
Bartosz Sosnowski
aa1beaa07c win, fs: use FILE_WRITE_ATTRIBUTES when opening files
This allows for running uv_fs_fchmod on files with Archive flag cleared

Refs: https://github.com/nodejs/node/issues/12803
PR-URL: https://github.com/libuv/libuv/pull/1777
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-03-29 10:54:18 +02:00
Bartosz Sosnowski
edf05b97f0 win, fs: fix uv_fs_unlink for +R -A files
uv_fs_unlink would fail for read-only files with Archive attribute
cleared. This fixes this issue.

PR-URL: https://github.com/libuv/libuv/pull/1774
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-03-21 14:03:00 +01:00
Nikolai Vavilov
7e865b680a win: use long directory name for handle->dirw
`uv_relative_path` assumes `dir` is a prefix of `filename`, which is not
the case when `handle->dirw` is a short path.

Refs: https://github.com/nodejs/node/issues/19170
PR-URL: https://github.com/libuv/libuv/pull/1769
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2018-03-19 10:20:56 +01:00
cjihrig
3ae88200d6
unix,win: add UV_FS_COPYFILE_FICLONE_FORCE support
UV_FS_COPYFILE_FICLONE_FORCE attempts to use copy-on-write
semantics in uv_fs_copyfile(). If CoW is not available, an
error is returned.

Refs: https://github.com/libuv/libuv/pull/1465
Refs: https://github.com/libuv/libuv/pull/1491
PR-URL: https://github.com/libuv/libuv/pull/1768
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-03-16 01:00:43 -04:00
Santiago Gimeno
36671bf32c
test: fix connect_unspecified
So it passes on boxes without ipv6 support.

Fixes: https://github.com/libuv/libuv/issues/1766
PR-URL: https://github.com/libuv/libuv/pull/1767
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-03-08 11:37:00 +01:00
cjihrig
db918361eb
unix: add UV_FS_COPYFILE_FICLONE support
UV_FS_COPYFILE_FICLONE attemps to use copy-on-write
semantics in uv_fs_copyfile(). If CoW is not available,
it falls back to a normal copy operation.

Refs: https://github.com/libuv/libuv/pull/1465
PR-URL: https://github.com/libuv/libuv/pull/1491
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-03-05 10:18:30 -05:00
Santiago Gimeno
d6dadc0739
test: fix tcp_oob test flakiness
`EAGAIN` is an acceptable return value for `read()` and the test was not
taking it into account.

Fixes: https://github.com/libuv/libuv/issues/1602
PR-URL: https://github.com/libuv/libuv/pull/1759
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-02-28 21:58:56 +01:00
Jameson Nash
8f9ba2a597
Revert "Revert "unix,tcp: avoid marking server sockets connected""
This reverts commit 2098773243.

PR-URL: https://github.com/libuv/libuv/pull/1741
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-02-25 18:45:05 +01:00
cjihrig
c1ecaf7b43
test: add additional fs memory management checks
This commit adds checks for fs request values when a call
fails with UV_EINVAL.

PR-URL: https://github.com/libuv/libuv/pull/1752
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-02-21 15:03:10 -05:00
Joyee Cheung
e485d28674
test: add tests for bad inputs
This commit adds tests that pass bad options to uv_fs_copyfile(),
uv_fs_read(), and uv_fs_write(). These tests verify that the
asynchronous version of these functions do not hold the event
loop open on bad inputs.

Refs: https://github.com/nodejs/node/pull/18811
PR-URL: https://github.com/libuv/libuv/pull/1747
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-02-21 09:58:07 -05:00
Mason X
89cbbc895b
include,src: introduce UV__ERR() macro
Using -errno, -E**, and -pthread_function() can be
error prone, and breaks compatibility with some operating
systems that already negate errno's (e.g. Haiku).

This commit adds a UV__ERR() macro that ensures libuv
errors are negative.

Fixes: https://github.com/libuv/help/issues/39
PR-URL: https://github.com/libuv/libuv/pull/1687
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-02-08 22:38:02 -05:00
Jamie Davis
693c217f80 test: check uv_cond_timedwait more carefully
Problem:
The "timeout" functionality of uv_cond_timedwait was not being tested.
The test (condvar_3) would use a worker that signaled the condition.

Solution:
Introduce a new condvar test case to ensure that the timeout also works.

PR-URL: https://github.com/libuv/libuv/pull/1713
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: John Barboza <jbarboza@ca.ibm.com>
2018-02-01 23:26:08 +01:00
Ben Noordhuis
fdf7c2ad1d build: split off tests into separate gyp file
Make it easier for Node.js to ship libuv in its tarballs without also
including the test suite.  Node.js already does so but recent changes
to its build system complicate that.

Kills two birds with one stone: it helps out Node.js and it makes it
harder for us to introduce hidden dependencies between the library and
the test suite.

PR-URL: https://github.com/libuv/libuv/pull/1725
Refs: https://github.com/nodejs/node/pull/18287
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-01-27 22:59:47 +01:00
Felix Yan
83e1871780
test: fix a typo in test-fork.c
PR-URL: https://github.com/libuv/libuv/pull/1721
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-01-26 15:05:24 -05:00
cjihrig
974a5bf30e
test: fix incorrect asserts
This commit fixes two assertions of the form
(events == UV_CHANGE || UV_RENAME) which always passed because
UV_RENAME is 1.

Refs: https://github.com/libuv/help/issues/41
PR-URL: https://github.com/libuv/libuv/pull/1722
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-01-22 09:49:28 -05:00
Ben Noordhuis
9f07a3673b Revert "win: use RemoveDirectoryW() instead of _wmrmdir()"
Reverted for breaking `test/parallel/test-child-process-cwd.js` from the
Node.js test suite.  Instead of ENOENT when trying to remove a directory
that does not exist, it started failing with ENOTDIR.

This reverts commit 15f29dc08f.

PR-URL: https://github.com/libuv/libuv/pull/1717
Refs: https://github.com/nodejs/node/issues/18014
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-01-19 17:52:13 +01:00
Ben Noordhuis
b0f3310bb1 Revert "unix,fs: fix for potential partial reads/writes"
This commit has been reported as introducing a backwards-incompatible
change in reading from stdin and is independently suspected of breaking
the Node.js test suite on MacOS and maybe other platforms, possibly in
combination with commit fd049399 ("unix,tcp: avoid marking server
sockets connected".)

This reverts commit 14bfc27e64.

Fixes: https://github.com/libuv/libuv/issues/1716
Fixes: https://github.com/libuv/libuv/issues/1720
Fixes: https://github.com/nodejs/node/issues/18225
PR-URL: https://github.com/libuv/libuv/pull/1717
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-01-19 17:51:08 +01:00
Ben Noordhuis
2098773243 Revert "unix,tcp: avoid marking server sockets connected"
Reverted for breaking Node.js in rather spectacular fashion.

The bug is arguably on the Node.js side.  It looks like Node.js starts
reading before the socket is actually connected to something.
Until that is fixed downstream, let's revert the change.

This reverts commit fd049399aa.

Fixes: https://github.com/libuv/libuv/issues/1716
Fixes: https://github.com/nodejs/node/issues/18225
PR-URL: https://github.com/libuv/libuv/pull/1717
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-01-19 17:51:04 +01:00
John Barboza
9c503a278c
zos,test: decrease pings to avoid timeout
Fixes: https://github.com/libuv/libuv/issues/1691
PR-URL: https://github.com/libuv/libuv/pull/1704
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-01-17 09:51:14 -05:00
Ben Noordhuis
15f29dc08f
win: use RemoveDirectoryW() instead of _wmrmdir()
Use RemoveDirectoryW() and remap ERROR_DIRECTORY from UV_ENOENT
to UV_ENOTDIR so that attempted removal of a non-directory produces
the right (and legible) error message.

Fixes: https://github.com/nodejs/node/issues/18014
PR-URL: https://github.com/libuv/libuv/pull/1698
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-01-17 09:40:19 -05:00
John Barboza
634bcc3164
zos,test: accept SIGKILL for flaky test
Sending a SIGTERM to a process that is still starting up kills it with
SIGKILL instead of SIGTERM.

PR-URL: https://github.com/libuv/libuv/pull/1709
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-01-17 09:35:44 -05:00
Bert Belder
dcd9b3cb27 win: allow directory symlinks to be created in a non-elevated context
PR-URL: https://github.com/libuv/libuv/pull/1706
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-01-16 09:52:15 -08:00
Ben Wijen
14bfc27e64
unix,fs: fix for potential partial reads/writes
Added a check in uv__fs_buf_iter to detect partial reads and writes.
Partial reads and writes are looped until all data has been processed.

PR-URL: https://github.com/libuv/libuv/pull/640
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-01-10 17:14:53 +01:00
Ben Noordhuis
a468257e5d test: allow net unreachable status in udp test
Since the destination address may not be routable, UV_ENETUNREACH is
an error that can happen and should be handled.

Fixes: https://github.com/libuv/libuv/issues/1680
PR-URL: https://github.com/libuv/libuv/pull/1695
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-01-09 15:09:46 +01:00
Jérémy Lal
3ad4dfad0c test: allow multicast not permitted status
PR-URL: https://github.com/libuv/libuv/pull/1689
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-01-09 14:32:35 +01:00
Ben Noordhuis
6ecd79eb6e test: remove custom timeout for thread test on ppc
The two minute timeout should not be necessary anymore after commit
aeaff5f0 ("test: lower number of tasks in threadpool test".)

PR-URL: https://github.com/libuv/libuv/pull/1681
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2018-01-09 14:28:56 +01:00
Bartosz Sosnowski
2b32e77bb6 win: map 0.0.0.0 and :: addresses to localhost
On Linux when connecting IP addresses 0.0.0.0 and :: are automatically
converted to localhost. This adds same functionality to Windows.

PR-URL: https://github.com/libuv/libuv/pull/1515
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-12-28 10:42:11 +01:00
Jameson Nash
fd049399aa
unix,tcp: avoid marking server sockets connected
It shouldn't be setting READABLE and WRITABLE on the socket server,
since they aren't, and this could confuse the client.

PR-URL: https://github.com/libuv/libuv/pull/1655
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-12-20 22:17:52 +01:00
John Barboza
b01de7341f
zos: implement uv_fs_event* functions
This commit uses the Register File Interest feature on z/OS
to enable users to monitor file system events.
The poll call is used to check for file descriptors as well
as a message queue that z/OS will report file system events
on. The last item on the list used by poll will contain the
message queue id instead of a file descriptor.

Limitation:
Writes to a directory (that is, file creation and deletion)
do not generate a change message for a registered directory.

PR-URL: https://github.com/libuv/libuv/pull/1311
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-12-15 11:04:16 +01:00
Bartosz Sosnowski
890eedaf59 win, process: uv_kill improvements
Maps pid 0 to the current process, simulating Linux kill sending signal
to the process group.

Adds detection of invalid signals. If the signum is invalid - below 0
or NSIG or above – UV_EINVAL will be returned instead of UV_ENOSYS.

PR-URL: https://github.com/libuv/libuv/pull/1642
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-12-07 14:00:05 +01:00
Bartosz Sosnowski
c73e73c874 test: add threadpool init/teardown test
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>
2017-12-06 23:47:38 +01:00
Matt Harrison
8a6d1b32c5 unix: make get(set)_process_title MT-safe
Used a shared uv_mutex_t in unix implementations of these functions
to prevent simultaneous execution.

Fixes: https://github.com/libuv/libuv/issues/271
PR-URL: https://github.com/libuv/libuv/pull/1640
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-12-02 12:06:34 +01:00
Anna Henningsen
0d6525acae core: add getter/setter functions for easier ABI compat
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>
2017-12-02 09:51:25 +01:00
Bartosz Sosnowski
d708df110a
unix,win: add uv_os_getpid()
Adds a multi platform way to get current process id.

PR-URL: https://github.com/libuv/libuv/pull/1661
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-30 20:11:21 -05:00
Ben Noordhuis
49616e4e17 Revert "unix,win: wait for threads to start"
Reverted for suspected regressions in the Node.js test suite on Windows.

Also revert e99ac4c1f4 ("test: add threadpool init/teardown test") since
it depends on 5486f6bd51.

This reverts commit 5486f6bd51.
This reverts commit e99ac4c1f4.

PR-URL: https://github.com/libuv/libuv/pull/1656
Refs: https://github.com/libuv/libuv/pull/1639
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-30 02:24:22 +01:00
Bartosz Sosnowski
c6cca31463 test: fix test-spawn compilation
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>
2017-11-22 20:43:02 +01:00
Ben Noordhuis
5070620777 win: issue memory barrier in uv_thread_join()
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>
2017-11-20 20:59:33 +01:00
Ben Noordhuis
aeaff5f037 test: lower number of tasks in threadpool test
Reduce the task count from 2*16*16 to 2*4*4 (512 vs. 32) because several
people have reported that the test frequently times out on their system.

Fixes: https://github.com/libuv/libuv/issues/1471
PR-URL: https://github.com/libuv/libuv/pull/1634
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-20 20:59:28 +01:00
Ben Noordhuis
9594719e73 test: avoid malloc() in threadpool test
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>
2017-11-20 20:59:15 +01:00
Bartosz Sosnowski
e99ac4c1f4 test: add threadpool init/teardown test
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>
2017-11-20 20:35:23 +01:00
John Barboza
c5dd2d4218
unix: keep track of bound sockets sent via spawn
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>
2017-11-20 18:36:26 +01:00
Ben Noordhuis
0b18f57be5 win: remove unused variable in test/test-fs.c
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>
2017-11-18 13:12:06 +01:00
Ben Noordhuis
fe3e635425 win: fix test runner build with mingw64
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>
2017-11-18 13:11:30 +01:00
Joran Dirk Greef
1c4de1916e win: map UV_FS_O_EXLOCK to a share mode of 0
This is necessary to enable writing past the MBR of a raw block device.

Fixes: https://github.com/libuv/libuv/issues/1605
PR-URL: https://github.com/libuv/libuv/pull/1613
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2017-11-16 15:14:52 +01:00
Pekka Nikander
695afe8322
unix,win: add uv_if_{indextoname,indextoiid}
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>
2017-11-06 09:54:47 -05:00
Bartosz Sosnowski
fd02ab681b pipe: allow access from other users
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>
2017-11-06 15:45:00 +01:00
Bartosz Sosnowski
96ea5ac96d
test: no extra new line in skipped test output
Removes extra empty line when a test was skipped.

PR-URL: https://github.com/libuv/libuv/pull/1616
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-06 09:33:40 -05:00
Ben Noordhuis
d2101b0b9f
test: fix const qualification compiler warning
`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>
2017-11-01 10:51:32 -04:00
cjihrig
e8e6a8a500
unix,win: add uv_os_getppid()
Refs: https://github.com/nodejs/node/issues/14957
PR-URL: https://github.com/libuv/libuv/pull/1610
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2017-11-01 10:32:12 -04:00
Bartosz Sosnowski
bdbae7d46b test: keep platform_output as first test
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>
2017-10-19 15:25:17 +02:00
John Barboza
f2214561f3
zos: skip fork_threadpool_queue_work_simple
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>
2017-10-17 22:34:07 +02:00
Ben Noordhuis
763f34cc1f test: fix -Wstrict-prototypes warnings
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>
2017-10-05 22:26:55 +02:00
Wade Brainerd
1d9c13f1f7 win, fs: fix non-symlink reparse points
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>
2017-10-03 16:36:32 +02:00
Scott Parker
ec96b55438
unix,win: add uv_mutex_init_recursive()
Support the creation of recursive mutexes on Unix. A matching
API is added on Windows, however mutexes on Windows are always
recursive.

Refs: https://github.com/libuv/libuv/issues/1022
PR-URL: https://github.com/libuv/libuv/pull/1555
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-10-02 10:01:09 -04:00
Kamil Rytarowski
5b6eead064
test: fix udp_multicast_join6 on NetBSD
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>
2017-10-02 09:38:20 -04:00
Kamil Rytarowski
7824370ff8
netbsd: disable poll_bad_fdtype on NetBSD
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>
2017-10-02 09:23:22 -04:00
Sakthipriyan Vairamani
c1ca7f078d test: sort the tests alphabetically
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>
2017-09-27 23:12:01 +02:00
John Barboza
bf144cee42 test: clean up semaphore after use
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>
2017-09-25 22:43:44 +02:00
Ben Noordhuis
0afccdb0a4 linux: increase thread stack size with musl libc
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>
2017-09-25 22:22:30 +02:00
Kamil Rytarowski
fbb8132d90
test: add NetBSD support to test-udp-ipv6.c
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>
2017-09-23 20:26:02 -04:00
Nick Logan
b0653625e2
unix: truncate destination in uv_fs_copyfile()
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>
2017-09-20 09:19:44 -04:00
cjihrig
a41f8b52e1
unix: support copying empty files
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>
2017-09-20 09:18:27 -04:00
Bartosz Sosnowski
e79589d550
win, test: remove surplus CloseHandle
Fixes: https://github.com/libuv/libuv/issues/1426
PR-URL: https://github.com/libuv/libuv/pull/1523
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-09-06 09:26:58 -04:00
Bartosz Sosnowski
eb4a37c8f6
Revert "win, test: fix double close in test runner"
Causes test output to be lost.

This reverts commit bded0fa4f0.

Refs: https://github.com/libuv/libuv/issues/1426
Refs: https://github.com/libuv/libuv/pull/1450
PR-URL: https://github.com/libuv/libuv/pull/1523
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-09-06 09:24:09 -04:00
cjihrig
e539fc412f
unix,windows: return UV_EINVAL on NULL fs reqs
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>
2017-09-02 19:04:01 -04:00
cjihrig
7a0e64d2e0
unix,windows: init all requests in fs calls
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>
2017-09-02 19:04:01 -04:00
cjihrig
8a95c6b5c1
unix,win: check for bad flags in uv_fs_copyfile()
Refs: https://github.com/libuv/libuv/pull/1465
PR-URL: https://github.com/libuv/libuv/pull/1493
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-08-21 22:07:13 -04:00
John Barboza
607dc073eb
zos, test: flush out the oob data in callback
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>
2017-08-21 13:11:35 +02:00
cjihrig
766d7e9c0b
unix, windows: add basic uv_fs_copyfile()
Fixes: https://github.com/libuv/libuv/issues/925
PR-URL: https://github.com/libuv/libuv/pull/1465
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-08-15 10:43:49 -04:00
Maciej Szeptuch (Neverous)
6827fa3451 win: allow bound/connected socket in uv_tcp_open()
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>
2017-08-08 17:19:20 +02:00
John Barboza
f9823e5c12 test,zos: use gid=-1 to test spawn_setgid_fails
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>
2017-08-08 15:03:07 +02:00
John Barboza
5e2fbe5994 test,zos: skip chown root test
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>
2017-08-08 15:02:48 +02:00
Bartosz Sosnowski
bded0fa4f0 win, test: fix double close in test runner
Fixes: https://github.com/libuv/libuv/issues/1426
Credit: Tom Seddon <github@tomseddon.plus.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-08-07 14:56:20 +02:00
John Barboza
3c6f9e54ef unix: add missing semicolon
PR-URL: https://github.com/libuv/libuv/pull/1444
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2017-07-29 15:41:29 +02:00
Bartosz Sosnowski
cbcf13af6a win, process: support semicolons in PATH variable
Fixes a bug that would cause libuv to crash when PATH environment
variable contained paths with semicolon in it

Refs: https://github.com/nodejs/help/issues/728
Fixes: https://github.com/libuv/libuv/issues/1422
PR-URL: https://github.com/libuv/libuv/pull/1438
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-07-27 12:34:31 +02:00
Ben Noordhuis
1e6f1159cf win: include filename in dlopen error message
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>
2017-07-13 23:06:11 +02:00
CurlyMoo
d731fd1bd9 poll: add support for OOB TCP and GPIO interrupts
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>
2017-07-12 23:04:34 +02:00
Barnabas Gema
c33fe9874a
win,udp: implements uv_udp_try_send
PR-URL: https://github.com/libuv/libuv/pull/1385
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-07-01 17:20:15 +02:00
Ben Noordhuis
11563e179f unix: reset signal mask before execve()
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>
2017-07-01 00:33:27 +02:00
Ben Noordhuis
28eb1d44f5 unix: reset signal disposition before execve()
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>
2017-07-01 00:31:52 +02:00
Sai Ke WANG
d0a27baa7d sunos: fix cmpxchgi and cmpxchgl type error
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>
2017-07-01 00:24:42 +02:00
John Barboza
d4f3a42ec7
unix,benchmark: use fd instead of FILE* after fork
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>
2017-06-23 09:41:02 +02:00
Santiago Gimeno
404ee42706
unix,stream: return error on closed handle passing
Return `EBADF` when trying to send a handle which, while enqueued, was
closed.

Fixes: https://github.com/libuv/libuv/issues/806
PR-URL: https://github.com/libuv/libuv/pull/1352
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2017-06-23 09:38:15 +02:00
Bartosz Sosnowski
0bd8f5bf36 win: restore file pos after positional read/write
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>
2017-06-21 12:47:00 +02:00
Juan Cruz Viotti
e133923e93 win: make uv__get_osfhandle() public
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>
2017-05-30 11:53:31 -04:00
Brad King
621655352c test: skip self-connecting tests on cygwin
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>
2017-05-21 16:12:30 +02:00
Brad King
580f032737 cygwin: disable non-functional ipc handle send
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>
2017-05-21 16:12:28 +02:00
Brad King
6398251aff cygwin: implement support for cygwin and msys2
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>
2017-05-21 16:12:21 +02:00
Brad King
773d678c6a test: skip fork fsevent cases when lacking support
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>
2017-05-21 16:12:09 +02:00
Brad King
f4f1f57e7c test: factor out fsevents skip explanation
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>
2017-05-21 16:12:08 +02:00
Ben Noordhuis
6c2fe3d946 test: fix -Wstrict-prototypes compiler warnings
PR-URL: https://github.com/libuv/libuv/pull/1354
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-05-21 16:07:34 +02:00
John Barboza
573e7fe8fc
zos: increase timeout for tcp_writealot
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>
2017-05-19 12:05:29 +02:00
cjihrig
d8cd08bd98 unix,win: add uv_os_gethostname()
Fixes: https://github.com/libuv/libuv/issues/1315
PR-URL: https://github.com/libuv/libuv/pull/1342
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2017-05-18 10:27:47 -04:00
Santiago Gimeno
4d0054145d
test: fix flaky tcp-write-queue-order
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>
2017-05-17 18:56:59 +02:00
John Barboza
cb0cc7346d
zos: implement uv__io_fork, skip fs event tests
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>
2017-05-03 11:58:16 +02:00
Rasmus Christian Pedersen
51f3f56f34 test: fix VC++ compilation warning
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>
2017-05-01 14:44:28 -04:00
Bartosz Sosnowski
bcf6202921 win,test: support stdout output larger than 1kb
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>
2017-05-01 12:52:23 -04:00
Trevor Norris
d898a1f6f8 test: add test for uv_udp_send() fix
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>
2017-04-20 18:10:43 -04:00
Rasmus Christian Pedersen
cd676e2dbc unix,test: deadstore fixes
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>
2017-04-05 09:57:20 -04:00
Santiago Gimeno
cd37fd0fd2
test,osx: fix flaky kill test
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>
2017-04-04 12:30:12 +02:00
cjihrig
463800ffc1 win,sunos: stop handle on uv_fs_event_start() err
This commit stops the handle in uv_fs_event_start() when an
error occurs.

Fixes: https://github.com/libuv/libuv/issues/1253
PR-URL: https://github.com/libuv/libuv/pull/1257
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-03-21 10:35:53 -04:00
Jason Madden
fd7ce57f2b unix: make loops and watchers usable after fork()
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>
2017-03-21 12:23:44 +01:00
jBarz
399b08aa9f unix: return UV_EINVAL for NULL env name
"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>
2017-03-14 08:28:46 +01:00
cjihrig
ee02f60c90 unix,win: add uv_os_{get,set,unset}env()
These functions are used to create, retrieve, update, and delete
environment variables.

Fixes: https://github.com/libuv/libuv/issues/1198
PR-URL: https://github.com/libuv/libuv/pull/1234
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-03-08 20:39:33 -05:00
Santiago Gimeno
45616f542d
signal: add uv_signal_start_oneshot method
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>
2017-02-28 14:16:54 +01:00
Santiago Gimeno
309d603382
test: fix -Wformat warning
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>
2017-02-08 12:47:50 +01:00
Santiago Gimeno
c355c8b1a6
test: fix tests on OpenBSD
It fixes `process_title`, `poll_bad_fdtype` and `poll_nested_kqueue`
tests.

Fixes: https://github.com/libuv/libuv/issues/1216
PR-URL: https://github.com/libuv/libuv/pull/1218
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-02-07 17:47:17 +01:00
Richard Lau
12bfad9c6d win: define ERROR_ELEVATION_REQUIRED for MinGW
Refs: https://github.com/libuv/libuv/issues/1194
PR-URL: https://github.com/libuv/libuv/pull/1195
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2017-01-30 12:07:14 -05:00
Bert Belder
67a5c86b86 win,test: don't write uninitialized buffer to tty
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>
2017-01-30 00:54:35 -08:00
John Barboza
f9484cf515 zos: use built-in proctitle implementation
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>
2017-01-27 18:08:28 +01:00
Howard Hellyer
d6427e4beb
aix: enable uv_get/set_process_title
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>
2017-01-26 12:50:49 +01:00
Bartosz Sosnowski
c66f265b5d win,signal: fix potential deadlock
Trying to remove the controller from the controller handle itself
leads to deadlock. Fix it by always having the global signal handler
engaged.

Ref: https://github.com/nodejs/node/issues/10165
PR-URL: https://github.com/libuv/libuv/pull/1168
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2017-01-17 21:22:56 -06:00
muflub
c8ab24bb92 fs: fix crash in uv_fs_scandir_next
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>
2017-01-17 21:15:43 -06:00
Ben Noordhuis
7bfb5ae7f9 win: fix free() on bad input in uv_getaddrinfo()
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>
2017-01-08 16:29:37 -05:00
Richard Lau
11ce5df5ea win: map ERROR_ELEVATION_REQUIRED to UV_EACCES
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>
2016-12-16 14:50:32 -05:00
Santiago Gimeno
c02176a230
fs: fix uv__to_stat on BSD platforms
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>
2016-12-06 12:08:18 +01:00
Santiago Gimeno
c2f0e4f64e
win,tty: fix MultiByteToWideChar output buffer
Make sure there's enough room in the output buffer by dynamically
allocating memory in case the size of the buffer needs to be greater
than 8192 characters.

PR-URL: https://github.com/libuv/libuv/pull/1143
Refs: https://github.com/libuv/libuv/pull/1138
Refs: https://github.com/libuv/libuv/pull/889
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
2016-11-29 10:36:44 +01:00
Santiago Gimeno
445e3a1f06
Revert "Revert "win,tty: add support for ANSI codes in win10 v1511""
To bring back support for ANSI codes in win10 v1511.

This reverts commit 8cbabaa817.

PR-URL: https://github.com/libuv/libuv/pull/1143
Refs: https://github.com/libuv/libuv/pull/1138
Refs: https://github.com/libuv/libuv/pull/889
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
2016-11-29 10:35:59 +01:00
Ben Noordhuis
8cbabaa817 Revert "win,tty: add support for ANSI codes in win10 v1511"
Causes regressions on Windows 10 in applications that use ANSI codes.

Also reverts commit 0895ccf ("win: fix typo in type name") and
commit d0c2641 ("win, tty: handle empty buffer in uv_tty_write_bufs".)

This reverts commit d0c26414b4.
This reverts commit 0895ccfc8c.
This reverts commit 58ccfd4c21.

PR-URL: https://github.com/libuv/libuv/pull/1138
Refs: https://github.com/libuv/libuv/issues/1135
Refs: https://github.com/libuv/libuv/pull/889
Refs: https://github.com/nodejs/node/issues/9542
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2016-11-15 16:52:42 +01:00
Hitesh Kanwathirtha
d0c26414b4 win, tty: handle empty buffer in uv_tty_write_bufs
In uv_tty_write_bufs, if the console supports Virtual Terminal sequences,
we try to convert the passed in utf8 buffer to utf16. However, we need
to check if the buffer is of non-zero length- otherwise,
MultiByteToWideChar returns an error.

Fixes: https://github.com/libuv/libuv/issues/1135
Fixes: https://github.com/nodejs/node/issues/9542
PR-URL: https://github.com/libuv/libuv/pull/1139
Refs: https://github.com/libuv/libuv/pull/889
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
2016-11-15 09:54:25 +01:00
Will Speak
cded27b663 test: fix sign-compare warning
PR-URL: https://github.com/libuv/libuv/pull/1089
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-10-19 11:57:59 -04:00
Philippe Laferriere
f1863dae6b unix,win: add uv_translate_sys_error() public API
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>
2016-10-16 17:47:42 -04:00
Ben Noordhuis
538782fbda test: make threadpool saturation reliable
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>
2016-10-14 02:06:55 +02:00
Ben Noordhuis
39baaa58b7 test: make threadpool_cancel_single deterministic
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>
2016-10-14 02:02:47 +02:00
Ben Noordhuis
e58f7535c8 test: fix tcp_close_while_connecting CI failures
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>
2016-10-14 01:57:15 +02:00
Bartosz Sosnowski
468d44620a win, test: fix fs_event_watch_dir_recursive
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>
2016-09-20 00:14:36 +02:00
Vit Gottwald
fa81a1b2d7 test: fix fs_fstat on Android
Fixes: https://github.com/libuv/libuv/issues/1051
PR-URL: https://github.com/libuv/libuv/pull/1056
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-09-19 11:14:28 +01:00
Santiago Gimeno
29138058a5 test: fix fs_event_watch_dir flakiness on arm
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>
2016-09-12 08:33:44 +02:00
Santiago Gimeno
6d7d57a983 test: fix test-tcp-writealot flakiness on arm
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>
2016-09-12 08:33:41 +02:00
Santiago Gimeno
0d7f72f219 fs: fix uv_fs_fstat on platforms using musl libc
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>
2016-09-10 10:28:14 +02:00
Saúl Ibarra Corretgé
2112e7a67c test: fix building pty test on Android
Fixes: https://github.com/libuv/libuv/issues/1029
PR-URL: https://github.com/libuv/libuv/pull/1030
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-09-05 10:11:13 +02:00
Santiago Gimeno
4a71e7747a test: improve spawn_setuid_setgid test
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>
2016-09-03 10:16:59 +02:00
Santiago Gimeno
897738b160
test: use RETURN_SKIP in spawn_setuid_setgid test
PR-URL: https://github.com/libuv/libuv/pull/1021
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-08-30 01:32:24 -04:00
Julien Gilli
ad20b96a8f test: refactor fs_event_close_in_callback
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>
2016-08-25 10:12:49 +01:00
Santiago Gimeno
282dc7bc22 test: improve tap output on test failures
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>
2016-08-24 10:47:14 +01:00
John Barboza
e37f25d776 unix: expand range of values for usleep
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>
2016-08-24 09:58:49 +01:00
Jeffrey Clark
0a4b51fcb4 build: GNU/kFreeBSD support
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>
2016-08-20 08:55:30 +02:00
Saúl Ibarra Corretgé
e994000834 test: make tcp_close_while_connecting more resilient
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>
2016-08-19 00:54:42 +01:00
John Barboza
1cff5b7557 zos: add support for new platform
- 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>
2016-08-19 01:34:29 +02:00
Saúl Ibarra Corretgé
d796bedf5b unix,win: make on_alloc_cb failures more resilient
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>
2016-08-17 09:57:55 +02:00
sunjin.lee
791c817891 test: fix android build error.
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>
2016-08-11 10:39:43 -04:00
Saúl Ibarra Corretgé
63ab64144e test: don't close CRT fd handed off to uv_pipe_t
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>
2016-08-11 09:33:43 +01:00
Saúl Ibarra Corretgé
a6acc82245 test: fix OOB buffer access
The test uses an annonymous pipe, which means the returned length will
be 0.

Fixes: https://github.com/libuv/libuv/issues/376
Fixes: https://github.com/libuv/libuv/issues/529
Refs: https://github.com/libuv/libuv/issues/264
PR-URL: https://github.com/libuv/libuv/pull/981
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-08-09 13:14:45 +01:00
Ben Noordhuis
ff0ae10496 unix: preserve loop->data across loop init/done
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>
2016-07-30 10:49:19 +02:00
John Barboza
00dab91ce5 test: account for multiple handles in one ipc read
PR-URL: https://github.com/libuv/libuv/pull/940
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-07-18 10:26:04 +01:00
John Barboza
4b58985370 test: close server before initiating new connection
PR-URL: https://github.com/libuv/libuv/pull/944
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-07-18 10:22:36 +01:00
cjihrig
840a8c599e unix,win: make uv_get_process_title() stricter
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>
2016-07-14 09:47:23 -04:00
cjihrig
77c8abae33 win: compare entire filename in watch events
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>
2016-06-24 10:36:04 -04:00
Luca Bruno
7b9e25a9a9 test: skip tty_pty test if pty is not available
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>
2016-06-21 12:32:00 -04:00
Ben Noordhuis
7e7e221260 test: remove unused RETURN_TODO macro
PR-URL: https://github.com/libuv/libuv/pull/898
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-06-10 10:08:15 +02:00
Ben Noordhuis
b936ace934 test: improve formatting of diagnostic messages
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>
2016-06-10 10:08:13 +02:00
Ben Noordhuis
dd9f751ead test: don't dump output for skipped tests
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>
2016-06-10 10:08:11 +02:00
Ben Noordhuis
cc1d38ea93 test: make tap output the default
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>
2016-06-10 10:07:45 +02:00
Kári Tristan Helgason
89f01a41ab test: silence build warnings
PR-URL: https://github.com/libuv/libuv/pull/893
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-06-03 01:18:17 +02:00
Jason Ginchereau
399e2c8140 win: support sub-second precision in uv_fs_futimes()
Fixes: https://github.com/libuv/libuv/issues/800
PR-URL: https://github.com/libuv/libuv/pull/849
Reviewed-by: Bert Belder <bertbelder@gmail.com>
2016-05-29 11:58:46 +02:00
Santiago Gimeno
51d660de00 test: fix test_close_accept flakiness on Centos5
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>
2016-05-28 12:50:05 +02:00
Ben Noordhuis
c5c419f7c8 unix: allow nesting of kqueue fds in uv_poll_start
kqueue file descriptors don't support ioctl(FIONBIO) (or any other ioctl
for that matter) so retry using fcntl(F_GETFL) + fcntl(F_SETFL) when we
receive a ENOTTY error.

Fixes: https://github.com/libuv/libuv/issues/883
PR-URL: https://github.com/libuv/libuv/pull/885
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-05-24 17:12:31 +02:00
João Reis
e51442bbc9 win,tty: fix read stop in line mode
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>
2016-05-16 23:05:35 +02:00
Imran Iqbal
a1bd1ee803 test: skip emfile on AIX
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>
2016-05-12 23:11:04 +02:00
Imran Iqbal
337e9fd0f5 test: fix POLLHDRUP related failures for AIX
`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>
2016-05-05 23:23:28 +02:00
Ben Noordhuis
2753bc1fc8 test: fix -Wformat warnings in platform test
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>
2016-05-04 17:25:21 +02:00
Andrius Bentkus
5c6c268182 test: set a big send buffer size for tcp_write_queue_order
We set the maximum buffer size of the client socket to a specific
value so unreasonable OS settings won't trigger assert failures.

Fixes: https://github.com/libuv/libuv/issues/764
Refs: https://github.com/libuv/libuv/pull/767
PR-URL: https://github.com/libuv/libuv/pull/768
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-04-21 20:28:33 +02:00
Robert Jefe Lindstaedt
6f17a617da win: add maxrss, pagefaults to uv_getrusage()
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>
2016-04-21 10:44:08 -04:00
Imran Iqbal
faea76d81d test: skip fs_event_close_in_callback on AIX
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>
2016-04-20 12:23:17 +02:00
Imran Iqbal
f28a11229f test: fix fs_event_watch_file_current_dir for AIX
PR-URL: https://github.com/libuv/libuv/pull/828
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-04-13 11:39:00 +02:00
Saúl Ibarra Corretgé
7acb6bd843 test: skip early bind tests if no IPv6 is supported
PR-URL: https://github.com/libuv/libuv/pull/814
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-10 09:53:25 -03:00
Imran Iqbal
4aeed1ac13 unix: implement uv__fs_futime for AIX 7.1
'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>
2016-04-08 21:08:13 +02:00
cjihrig
a84caf6fd7 test: handle root home directories
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>
2016-04-08 11:08:46 -04:00
Enno Boland
387102b247 unix: open ttyname instead of /dev/tty
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>
2016-04-01 11:13:22 +02:00
Ben Noordhuis
2d6437888e test: use %ld for printing uid/gid
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>
2016-03-31 13:19:53 +02:00
cjihrig
217f81b6a1 unix,win: add uv_get_passwd()
This commit adds the uv_get_passwd() function, which returns a
subset of the current effective user's password file entry.

Refs: https://github.com/libuv/libuv/issues/11
Fixes: https://github.com/libuv/libuv/issues/731
PR-URL: https://github.com/libuv/libuv/pull/742
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-29 08:13:59 -04:00
cjihrig
13f4dc8288 test: add missing copyright header
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>
2016-03-24 13:17:31 -04:00
Santiago Gimeno
c7c8e916b8 poll: add UV_DISCONNECT event
It allows detecting the remote socket closing the connection. It's
emitted when `EPOLLRDHUP`(Linux), `EV_EOF`(BSD), `POLLRDHUP`(Solaris,
AIX) and `AFD_POLL_DISCONNECT`(Windows) events are received.

PR-URL: https://github.com/libuv/libuv/pull/691
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-15 23:39:49 +01:00
Imran Iqbal
213e681acf test: fix poll_bad_fdtype for AIX
PR-URL: https://github.com/libuv/libuv/pull/757
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-10 09:50:33 -05:00
Katsutoshi Horie
ca0b657891 test: fix deadlocks in uv_cond_wait
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>
2016-03-03 09:29:39 +01:00
Saúl Ibarra Corretgé
e5f4b79809 unix, win: consistently null-terminate buffers
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>
2016-03-03 09:20:41 +01:00
Imran Iqbal
e76e21389b test: reduce timeout in tcp_close_while_connecting
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>
2016-03-03 09:15:21 +01:00
Imran Iqbal
b015b4d0ee test: fix threadpool_multiple_event_loops on PPC
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>
2016-02-27 18:06:17 +01:00
Nan Xiang
12548de1b5 test: assume no IPv6 if interfaces cannot be listed
PR-URL: https://github.com/libuv/libuv/pull/724
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-02-16 08:47:21 +01:00
Nan Xiang
b6650dff56 test: use uv_loop_close and assert its result
uv_loop_delete is considered deprecated.

PR-URL: https://github.com/libuv/libuv/pull/696
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-02-01 09:15:41 +01:00
Saúl Ibarra Corretgé
51c1a28d7e test,win: fix compilation warning
PR-URL: https://github.com/libuv/libuv/pull/700
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-02-01 09:07:52 +01:00
Nikolai Vavilov
3c59ad6d95 win: fix watching root files
When passing "\\?\C:" to CreateFile, it opens the drive rather than the root
directory. So include the trailing backslash in the directory name.

Fixes: https://github.com/nodejs/node/issues/4643
PR-URL: https://github.com/libuv/libuv/pull/689
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-01-26 09:58:49 +01:00
Ben Noordhuis
a0b56059cf unix: report errors for unpollable fds
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>
2016-01-21 17:57:00 +01:00
Imran Iqbal
c21a75a16c test: fix threadpool_multiple_event_loops for AIX
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>
2016-01-21 09:25:15 +01:00
cjihrig
c0fa2e7518 unix,win: add uv_os_tmpdir()
PR-URL: https://github.com/libuv/libuv/pull/672
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-01-21 09:11:56 +01:00
Imran Iqbal
d41749d546 test: fix race condition in pipe-close-stdout
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>
2016-01-21 09:08:41 +01:00
Saúl Ibarra Corretgé
01ab8d64ad test: fixup eintr_handling
- Add missing include
- Fix test name on Windows
- Fixup style

Refs: https://github.com/libuv/libuv/pull/661
PR-URL: https://github.com/libuv/libuv/pull/673
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-01-06 08:30:49 +01:00
Saúl Ibarra Corretgé
3db07cc379 osx: set the default thread stack size to RLIMIT_STACK
Fixes: https://github.com/libuv/libuv/issues/669
PR-URL: https://github.com/libuv/libuv/pull/671
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-01-05 09:06:15 +01:00
Dave
a564ef09dc fs: don't nullify req->bufs on EINTR
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>
2016-01-04 14:07:50 -05:00
Ben Noordhuis
bcecc3dda3 test,unix: fix logic error in test runner
Fix the logic that guards against the system clock jumping back in time.

Fixes: https://github.com/libuv/libuv/issues/667
PR-URL: https://github.com/libuv/libuv/pull/670
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-01-04 12:20:27 +01:00
João Reis
427e4c9d48 win: wait for full timeout duration
uv_poll should wait for at least the full timeout duration when there
is nothing else to do. This was not happening because
GetQueuedCompletionStatus can occasionally return up to 15ms early.

The added test reproduces d13d7f74d7/test/simple/test-timers-first-fire.js
on libuv, being flaky before this fix.

Fixes: https://github.com/joyent/node/issues/8960
PR-URL: https://github.com/libuv/libuv/pull/385
Reviewed-By: Alexis Campailla <alexis@janeasystems.com>
Reviewed-by: Bert Belder <bertbelder@gmail.com>
2015-12-16 12:08:46 +01:00
Imran Iqbal
99e5fb7670 test: fix test udp_multicast_join6 for AIX
PR-URL: https://github.com/libuv/libuv/pull/650
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-12-13 11:54:38 +01:00
Ben Noordhuis
e4675f6fe7 test: fix self-deadlocks in thread_rwlock_trylock
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>
2015-12-11 23:12:53 +01:00
Andrey Mazo
46343764d5 unix: fix uv_fs_event_stop() from fs_event_cb
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>
2015-12-08 10:03:01 +01:00
Andrey Mazo
6060841edc test: test that uv_close() doesn't corrupt QUEUE
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>
2015-12-08 10:02:25 +01:00
Jeremy Whitlock
eb3f48ebaf win: do not read more from stream than available
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>
2015-12-08 09:28:15 +01:00
Joran Dirk Greef
e0250b7d5c win: fix path for removed and renamed fs events
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>
2015-12-07 16:16:46 +01:00
Yuval Brik
e76b8838e5 fs: add uv_fs_realpath()
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>
2015-12-05 11:32:58 +01:00
Imran Iqbal
f5796d2fba test: fix test/test-tty.c for AIX
'/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>
2015-11-24 21:54:48 +01:00
Saúl Ibarra Corretgé
5f15f72cca test: fix -Wtautological-pointer-compare warnings
~~~~
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>
2015-11-18 22:37:16 +01:00
Santiago Gimeno
4052c74797 test,freebsd: skip udp_dual_stack if not supported
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>
2015-11-17 09:31:26 +01:00
Imran Iqbal
baf700acdb test: skip process_title for AIX
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>
2015-11-11 22:37:33 +01:00
Louis DeJardin
dfdecf0006 pipe: enable inprocess uv_write2 on Windows
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>
2015-11-06 09:33:15 +01:00
Wink Saville
7d7400c87f test: use FQDN in getaddrinfo_fail test
For the getaddrinfo_fail test cases you want to use a fully qualified
domain name so that in network configurations that have a search domain
the test will still fail.

To create a fully qualified domain add a period at the end, see
http://www.dns-sd.org/trailingdotsindomainnames.html for an explanation.

Fixes: https://github.com/libuv/libuv/issues/583
PR-URL: https://github.com/libuv/libuv/pull/586
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-23 18:28:51 +02:00
Santiago Gimeno
a0e30b551c test: fix fs_event_watch_file_currentdir flakiness
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>
2015-10-21 00:19:18 +02:00
Ben Noordhuis
822969ad2f test: don't abort on setrlimit() failure
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>
2015-10-08 21:47:48 +02:00
Fedor Indutny
5e761a5f81 stream: support empty uv_try_write on unix
PR-URL: https://github.com/libuv/libuv/pull/558
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-04 18:06:08 -04:00
Saúl Ibarra Corretgé
037a8ab29f win, test: fix compilation warning
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>
2015-09-29 09:57:27 +02:00
Peter Jas
a59085e140 win: use the MSVC provided snprintf where possible
PR-URL: https://github.com/libuv/libuv/pull/532
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-09-29 09:01:33 +02:00
Bert Belder
1ad6ad7ada test: add tests for the uv_rwlock implementation
PR-URL: https://github.com/libuv/libuv/pull/525
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-09-22 11:17:49 -04:00
Santiago Gimeno
57b0a6da42 test,freebsd: fix ipc_listen_xx_write tests
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>
2015-09-08 10:45:10 +02:00
Jeremy Whitlock
30fc362560 tests: fix fs tests run w/o full getdents support
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>
2015-09-03 23:47:54 +02:00
Saúl Ibarra Corretgé
4f4e956497 win: fix setting pipe pending instances after bind
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>
2015-08-24 23:20:35 +02:00
Saúl Ibarra Corretgé
34768a76f5 win: fix replacing pipe handle for pipe servers
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>
2015-08-24 23:20:35 +02:00
Jeremy Whitlock
83264701a7 tests: refactored fs watch_dir tests for stability
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>
2015-08-19 22:13:51 +02:00
Ben Noordhuis
df62b54aa2 unix,windows: allow NULL loop for sync fs requests
Synchronous file operations don't need an event loop.  Permit NULL as
the event loop parameter.

Fixes: https://github.com/libuv/libuv/issues/469
PR-URL: https://github.com/libuv/libuv/pull/479
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-18 15:39:21 +02:00
Ben Noordhuis
54eecf32a9 test: plug small memory leak in unix test runner
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>
2015-08-18 15:39:18 +02:00
Karl Skomski
939ea06f45 unix,win: return EINVAL on nullptr args in uv_fs_{read,write}
PR-URL: https://github.com/libuv/libuv/pull/470
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-11 13:35:54 +02:00
Karl Skomski
c2e6f3bad1 test: Fix two memory leaks
PR-URL: https://github.com/libuv/libuv/pull/470
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-11 13:35:34 +02:00
Saúl Ibarra Corretgé
01544d861b Revert "stream: squelch ECONNRESET error if already closed"
This reverts commit 05a003a3f7.

This commit triggerd "test-tls-hello-parser-failure" failure in io.js.
See the reference below for a more thorough explanation.

Refs: https://github.com/nodejs/io.js/pull/2310
PR-URL: https://github.com/libuv/libuv/pull/475
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-07 14:19:08 +02:00
ronkorving
2bf782777f unix: allow nbufs > IOV_MAX in uv_fs_{read,write}
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>
2015-08-04 11:31:04 +02:00
Santiago Gimeno
e18848059f test: fix compilation warning
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>
2015-07-28 09:49:56 +02:00
Saúl Ibarra Corretgé
01bbf6fb1c win,test: fix shared library build
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>
2015-07-21 23:38:17 +02:00
Saúl Ibarra Corretgé
085b877ccb test: fix compilation warning
fs_event_cb_dir_multi_file_in_subdir is only used in
fs_event_watch_dir_recursive test, which is only compiled in OSX and Windows.
2015-07-15 19:34:46 +02:00
Luca Bruno
5df06b3f2e tests: skip some tests when network is unreachable
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>
2015-07-13 10:28:46 +02:00
Santiago Gimeno
05a003a3f7 stream: squelch ECONNRESET error if already closed
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>
2015-07-10 09:25:01 +02:00
Saúl Ibarra Corretgé
188e0e94ac win: add support for recursive file watching
Original patch by @ghostoy, modified by @bpasero and yours truly.

Refs: https://github.com/joyent/libuv/pull/1473
Refs: https://github.com/libuv/libuv/pull/198
PR-URL: https://github.com/libuv/libuv/pull/421
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-07-08 23:40:47 +02:00
Ben Noordhuis
f3613e5082 test,unix: reduce stack size of watchdog threads
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>
2015-07-08 21:53:20 +02:00
A. Hauptmann
15e4dedace win: remove UV_HANDLE_CONNECTED
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>
2015-07-07 09:45:48 +02:00
heshamsafi
ca3ec90c6c test: conditionally skip udp_ipv6_multicast_join6
Skip udp_ipv6_multicast_join6 test if no ipv6 multicast route
is defined on ff02::1

Reefs: https://github.com/joyent/libuv/issues/1401#issuecomment-11570984
PR-URL: https://github.com/libuv/libuv/pull/411
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-06-29 09:35:26 +02:00
Ben Noordhuis
af20bb6830 test: retry select() on EINTR, honor milliseconds
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>
2015-06-26 16:37:22 +02:00
Saúl Ibarra Corretgé
f8f59824c4 unix, win: add ability to create tcp/udp sockets early
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>
2015-06-19 09:37:19 +02:00
Saúl Ibarra Corretgé
fb5df542ac unix, win: prevent replacing fd in uv_{udp,tcp,pipe}_t
PR-URL: https://github.com/libuv/libuv/pull/400
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-06-19 09:36:41 +02:00
Peter Jas
514c0b3d06 windows: MSVC 2015 has C99 inline
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>
2015-06-15 10:16:52 +02:00
Andrew Paprocki
266ee6424f test: fix platform_output netmask printing.
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>
2015-05-28 11:09:25 +02:00
cjihrig
a62c2d5928 unix,win: add uv_os_homedir()
PR-URL: https://github.com/libuv/libuv/pull/350
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-05-21 17:31:35 +02:00
Rui Abreu Ferreira
18b857b9bd windows: MSVC 2015 has snprintf()
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>
2015-05-19 11:23:24 +02:00
Saúl Ibarra Corretgé
a6fa3ca99a unix: don't block for io if any io handle is primed
PR-URL: https://github.com/libuv/libuv/pull/347
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-05-12 07:37:26 +02:00
Saúl Ibarra Corretgé
e6e8124b95 test: add test for deferred TCP write failure
The test exhibits that write failures are deferred to the callback.

Refs: https://github.com/libuv/libuv/issues/339
PR_URL: https://github.com/libuv/libuv/pull/344
2015-05-05 23:25:49 +02:00
João Reis
0db81a98ff win: fix unlink of readonly files
Unix unlinks files even if they are not writable, windows version should behave similarly.

Fixes: https://github.com/joyent/node/issues/3006
PR-URL: https://github.com/libuv/libuv/pull/327
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-05-01 01:18:57 +02:00
Saúl Ibarra Corretgé
03df7e79c1 test: fix C++ style comment 2015-04-30 14:26:00 +02:00
Rui Abreu Ferreira
4a7c1268e0 windows: define snprintf replacement as inline instead of static
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>
2015-04-30 10:09:50 +02:00
Saúl Ibarra Corretgé
7dcc3e0cf0 win: fix uv_fs_access on directories
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>
2015-04-13 10:22:18 +02:00
Saúl Ibarra Corretgé
cdc10a907a test: remove LOG and LOGF variadic macros
Initial patch by @simar7, thanks!

PR-URL: https://github.com/libuv/libuv/pull/313
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-04-12 18:44:34 +02:00
Saúl Ibarra Corretgé
009bbad4e7 unix: fix swapping fds order in uv_spawn
Alternative implementation (and test) to
https://github.com/libuv/libuv/pull/226

Fixes: https://github.com/joyent/libuv/issues/1084
PR-URL: https://github.com/libuv/libuv/pull/309
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-04-10 15:27:04 +02:00
Saúl Ibarra Corretgé
edcf04d5b1 test: spawn child replacing std{out,err} to stderr
Refs: https://github.com/libuv/libuv/pull/224

PR-URL: https://github.com/libuv/libuv/pull/309
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-04-10 15:11:14 +02:00
Saúl Ibarra Corretgé
3e405d90d1 Revert "test: fix tcp_oob occassionally timing out"
This reverts commit 3346082132.

See https://github.com/libuv/libuv/issues/258
2015-04-07 11:15:49 +02:00
Saúl Ibarra Corretgé
3346082132 test: fix tcp_oob occassionally timing out
Patch by @indutny

Fixes: https://github.com/libuv/libuv/issues/258
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-03-27 08:34:49 +01:00
Saúl Ibarra Corretgé
34da61b351 test: fix tty_file, close handle if initialized
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>
2015-03-20 16:13:01 +01:00
Ryan Phillips
3616e61439 unix: reap child on execvp() failure
Reap the forked process when execvp() fails.  Fixes leaking zombie child
processes.

PR-URL: https://github.com/libuv/libuv/pull/274
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-03-18 17:11:39 +01:00
Ben Noordhuis
fc9e66e555 unix: reject non-tty fds in uv_tty_init()
Reject file descriptors that correspond to regular files or char/block
devices.  Such file descriptors are incompatible with epoll and trigger
a run-time assert.

Fixes: https://github.com/libuv/libuv/issues/255
PR-URL: https://github.com/libuv/libuv/pull/259
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-03-11 16:45:51 +01:00
Ben Noordhuis
1df46fe478 unix: don't clobber errno in uv_tty_reset_mode()
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>
2015-03-11 16:45:50 +01:00
Ben Noordhuis
25d4abbabb test: use UV_TTY_MODE_* values in tty test
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>
2015-03-11 16:45:48 +01:00
Ben Noordhuis
531b08555d test: fix race condition in multithreaded test
The main thread's epilog closed the file descriptor without waiting for
the worker to shut down, making it sporadically fail with a EBADF error.

Fixes: https://github.com/libuv/libuv/issues/248
PR-URL: https://github.com/libuv/libuv/pull/256
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-03-11 15:42:34 +01:00
Massimiliano Torromeo
fd3cf20a37 unix: fix glibc-2.20+ macro incompatibility
Since glibc-2.20 the _SVID_SOURCE macro is deprecated and the newer
_DEFAULT_SOURCE macro should be used instead.

Fixes: https://github.com/libuv/libuv/issues/173
PR-URL: https://github.com/libuv/libuv/pull/213
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-02-26 21:08:07 +01:00
Fedor Indutny
e19089f7b1 stream: use SO_OOBINLINE on OS X
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>
2015-02-24 22:34:01 +03:00
Saúl Ibarra Corretgé
3ddfb4a9cc windows: fix setting dirent types on uv_fs_scandir_next
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>
2015-02-12 09:05:48 +01:00
Ben Noordhuis
b36d4ff930 unix: implement uv_stream_set_blocking()
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>
2015-02-09 13:28:52 +01:00
cjihrig
e5bdea8ed6 test: use modified path in test
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>
2015-02-05 22:50:09 +01:00
Andrius Bentkus
39a0936fec win, unix: add pipe_peername implementation
PR-URL: https://github.com/libuv/libuv/pull/166
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-28 21:40:32 +01:00
Luis Martinez de Bartolome
60b581fb5a test: fix test-spawn on MinGW32
PR-URL: https://github.com/libuv/libuv/pull/161
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-27 11:35:53 +01:00
Andrius Bentkus
1e59ab1d49 fs, pipe: no trailing terminator in exact sized buffers
uv_fs_poll_getpath, uv_pipe_getsockname, uv_fs_event_getpath used
to return the trailing null terminator, even though the functions
returned the size.

Fixes: https://github.com/libuv/libuv/issues/155
PR-URL: https://github.com/libuv/libuv/pull/159
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-27 11:31:16 +01:00
Saúl Ibarra Corretgé
f2bb8d394c unix, win: add synchronous uv_get{addr,name}info
PR-URL: https://github.com/libuv/libuv/pull/156
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-01-23 01:12:05 +01:00
Saúl Ibarra Corretgé
b30a3e677b unix, windows: set non-block mode in uv_poll_init
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>
2015-01-16 10:41:00 +01:00
Ben Noordhuis
393c1c59a2 unix: set non-block mode in uv_{pipe,tcp,udp}_open
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>
2015-01-14 19:46:54 +01:00
Bert Belder
85a293430f test: enable test-tcp-try-write on windows
PR: https://github.com/libuv/libuv/pull/127
Reviewed-by: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-13 22:53:41 +01:00
Saúl Ibarra Corretgé
72e4b5ab66 test: skip TTY select test if /dev/tty can't be opened
PR-URL: https://github.com/libuv/libuv/pull/123
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-07 13:53:12 +01:00
Saúl Ibarra Corretgé
69678e27c8 test: skip udp_options6 if there no IPv6 support
PR-URL: https://github.com/libuv/libuv/pull/115
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-05 12:32:57 +01:00
Ben Noordhuis
555a9647a0 linux: fix uv_exepath(size=1) UV_EINVAL error
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>
2015-01-03 23:40:31 +01:00
Ben Noordhuis
885b1ecda0 darwin: fix uv_exepath(smallbuf) UV_EPERM error
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>
2015-01-03 23:40:24 +01:00
Ben Noordhuis
afb319215d unix: make uv_exepath(size=0) return UV_EINVAL
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>
2015-01-03 23:39:55 +01:00
Saúl Ibarra Corretgé
2daee9fbeb unix: fix ttl, multicast ttl and loop options on IPv6
Fixes #93

PR-URL: https://github.com/libuv/libuv/pull/99
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-02 17:34:13 +01:00
Ben Noordhuis
a09e77e180 test: skip ipv6 tests when ipv6 is not supported
To verify on Linux, run `sudo sysctl net.ipv6.conf.all.disable_ipv6=1`
before the test suite.

Fixes: https://github.com/libuv/libuv/issues/10
PR-URL: https://github.com/libuv/libuv/pull/92
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-12-29 17:14:48 +01:00
Ben Noordhuis
9141f48ea5 test: fix spawn test with autotools build
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>
2014-12-28 22:51:05 +01:00
Ben Noordhuis
751ac48baa linux: fix epoll_pwait() sigmask size calculation
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>
2014-12-25 14:37:02 +01:00
Saúl Ibarra Corretgé
098ba555c4 test: add uv_cwd output to platform_output test
PR-URL: https://github.com/libuv/libuv/pull/63
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-16 08:12:59 +01:00
Saúl Ibarra Corretgé
37daffaccb test: fix cwd_and_chdir test on Unix
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>
2014-12-16 08:12:46 +01:00
Bert Belder
eb986397c1 Merge branch 'v0.10' into v1.x 2014-12-14 20:36:18 +01:00
Marc Schlaich
59f875d638 test: check dlerror is "no error" in no error case
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>
2014-12-14 20:33:43 +01:00
Marc Schlaich
f70b69d055 test: improve compatibility for dlerror test
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>
2014-12-14 20:31:41 +01:00
Saúl Ibarra Corretgé
9c8e971443 test: fix compilation warnings when building with Clang
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>
2014-12-13 20:57:43 +01:00
Saúl Ibarra Corretgé
5a8f7931b7 test: relax osx_select_many_fds
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>
2014-12-13 20:57:28 +01:00
Saúl Ibarra Corretgé
96f164e52b test: silence some Clang warnings
They only show up on OSX for some reason, though.

PR-URL: https://github.com/libuv/libuv/pull/67
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-13 20:57:14 +01:00
Saúl Ibarra Corretgé
86fcc20f96 test: skip spawn_setuid_setgid if we get EACCES
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>
2014-12-12 13:52:50 +01:00
Bert Belder
e8c4c329e6 test: fix test-cwd-and-chdir
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>
2014-12-11 17:12:04 +01:00
Bert Belder
cb2f6a9743 test: fix test-fs-file-loop on Windows
* 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>
2014-12-11 17:02:26 +01:00
Marc Schlaich
2e30a19641 win: fix compilation of tests
PR-URL: https://github.com/libuv/libuv/pull/51
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-10 16:44:27 +01:00
Marc Schlaich
2f0b41ec82 win: fix compilation of tests
PR-URL: https://github.com/libuv/libuv/pull/51
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-10 15:21:04 +01:00
Bert Belder
5f2016a425 test: test that closing a poll handle doesn't corrupt the stack
This is a regression test for an issue that was originally reported
in https://github.com/libuv/libuv/pull/36, and fixed in cd89452.

PR-URL: https://github.com/libuv/libuv/pull/48
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-12-09 22:03:05 +01:00
Bert Belder
f9aa3b3d60 test: test that closing a poll handle doesn't corrupt the stack
This is a regression test for an issue that was originally reported
in https://github.com/libuv/libuv/pull/36, and fixed in cd89452.

PR-URL: https://github.com/libuv/libuv/pull/48
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-12-09 22:01:16 +01:00
Saúl Ibarra Corretgé
5c1c046dba test: raise fd limit for OSX select test
Fixes #42

PR-URL: https://github.com/libuv/libuv/pull/46
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-09 11:48:52 +01:00
Saúl Ibarra Corretgé
e157dc9c67 test: skip tty test if detected width and height are 0
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
2014-12-02 23:57:06 +01:00
Saúl Ibarra Corretgé
b5442510c5 test: fix compilation warnings
PR-URL: https://github.com/libuv/libuv/pull/23
2014-12-02 23:53:57 +01:00
Ben Noordhuis
ff29322b99 test: canonicalize test runner path
The get_currentexe test requires a canonicalized argv[0] to check
against.  Before this commit, it failed when argv[0] contained symbolic
links.

Fixes libuv/libuv#18.
2014-12-01 16:20:51 +01:00
schlamar
0bcac64512 windows: fix compilation of tests 2014-11-26 08:32:59 +01:00
Unknown W. Brackets
5ac921bb6a windows: fix fs_read with nbufs > 1 and offset
ReadFile() does not seem to update the offset at all.
2014-10-26 07:49:00 -03:00
Unknown W. Brackets
6760d51b52 windows: fix fs_write with nbufs > 1 and offset
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.
2014-10-20 22:44:46 +02:00
Tomasz Kołodziejski
59658a8de7 unix, windows: add uv_thread_equal 2014-10-20 09:51:49 +02:00
cjihrig
c18205a1c5 unix, windows: add uv_fs_access() 2014-10-13 10:23:53 +02:00
Saúl Ibarra Corretgé
03e53f1cf7 fs: rename uv_fs_readdir to uv_fs_scandir
Closes #1431
2014-09-25 10:09:58 +02:00
Fedor Indutny
2f54947b72 fs: fix readdir on empty directory
`uv_fd_readdir()` should initialize all fields even if there are no
files. Fix the implementation and fix the test that should have been
covered it.
2014-09-23 21:06:54 +04:00
Saúl Ibarra Corretgé
5ccdfc568d test: add test for closing and recreating default loop 2014-09-15 21:34:09 +02:00
Trevor Norris
3d38eae377 test: don't close connection on write error
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>
2014-09-10 22:50:54 +02:00
Fedor Indutny
c60d6af011 darwin: allocate enough space for select() hack
`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
2014-09-08 09:09:21 +01:00
Fedor Indutny
145b76b894 darwin: allocate enough space for select() hack
`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
2014-09-08 08:37:36 +01:00
Saúl Ibarra Corretgé
7ff52b836d unix, windows: don't allow a NULL callback on timers 2014-09-05 16:59:18 +02:00
Saúl Ibarra Corretgé
1afdd9a1e5 test: use less requests on tcp-write-queue-order
Makes the test reliably pass on Windows, otherwise the runtime aborts.
2014-09-04 18:45:39 +02:00
Bert Belder
6941cab549 windows: fix buffer leak after failed udp send
Fixes #1426

Signed-off-by: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-08-28 08:41:43 +02:00
Saúl Ibarra Corretgé
4ca9a36389 unix, windows: add uv_fileno
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.
2014-08-27 10:53:40 +02:00
Saúl Ibarra Corretgé
2f83613023 test: fix watcher_cross_stop on Windows
All send callbacks are not necessarily called on the same loop iteration
as the data is received.
2014-08-21 23:34:51 +02:00
Andrius Bentkus
d5e6f4372f unix: fix tcp write after bad connect freezing
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
2014-08-21 16:23:43 +02:00
Julien Gilli
1552184238 unix: read on stream even when UV__POLLHUP set.
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.
2014-08-18 09:06:27 -07:00
Saúl Ibarra Corretgé
df8ab507a0 fs: extend reported types in uv_fs_readdir_next
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.
2014-08-15 16:44:44 +02:00
Fedor Indutny
ab2c4425a5 fs: introduce uv_readdir_next() and report types
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.
2014-08-14 17:19:45 +04:00
Saúl Ibarra Corretgé
09cb5b534e test: fix spawn_reads_child_path when using autoconf
Don't hardcode the name of the executable, take it from the exepath.

Fixes #1407
2014-08-10 11:25:28 +02:00
Saúl Ibarra Corretgé
84ed98e88e test: skip UDP dualstack test on BSDs
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.
2014-08-10 11:04:42 +02:00
Saúl Ibarra Corretgé
94c7a13f0a test: fix udp_multicast_interface6 on FreeBSD 2014-08-10 10:39:58 +02:00
Andrius Bentkus
0ecee213ea unix, windows: add uv_recv_buffer_size and uv_send_buffer_size 2014-08-09 11:36:35 +02:00
Jameson Nash
837c62c71b windows: make uv_read_stop immediately stop reading
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
2014-08-09 11:10:57 +02:00
Alex Crichton
c7e4b31444 windows: read the PATH env var of the child
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.
2014-08-06 02:12:44 +02:00
Saúl Ibarra Corretgé
d802486232 test: disable tcp_close_accept on Windows
It always was a Unix only test
2014-08-05 00:14:26 +02:00
Jameson Nash
2e9d86e105 windows: add uv_backend_timeout 2014-08-04 23:18:38 +02:00
Jameson Nash
8db42383ad windows: sort environment variables before calling CreateProcess 2014-08-01 09:26:21 +02:00
Saúl Ibarra Corretgé
431b535a51 windows: use UV_ECANCELED for aborted TCP writes
For consistency with Unix
2014-08-01 00:23:51 +02:00
Alexis Campailla
6d3a051eb4 windows: relay TCP bind errors via ipc
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 (
d1e6be1460
3da36fe00e
) 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.
2014-07-31 17:24:40 +02:00
Pavel Platto
e99b89f2ad unix, windows: add uv_fs_mkdtemp 2014-07-31 09:43:55 +02:00
Andrew Low
cdc979dbe0 aix: improve AIX compatibility 2014-07-22 22:57:24 +02:00
Andrius Bentkus
960eefb319 unix: guarantee write queue cb execution order in streams
The problem was that the canceled write callbacks
were being called before the already written callbacks, even
though they were queued after them.
2014-07-18 13:16:10 +02:00
Saúl Ibarra Corretgé
817c09257d unix: remove incorrect assert
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.
2014-07-11 22:53:59 +02:00
Saúl Ibarra Corretgé
ad78e456e9 test: fix watcher_cross_stop
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.
2014-07-08 18:44:38 +02:00
Saúl Ibarra Corretgé
b018dc5b72 test: simplify test-tcp-try-write
Use a smaller buffer thus making sure that uv_try_write will succeed at
least once
2014-07-05 11:06:39 +02:00
Saúl Ibarra Corretgé
40ad12e5be unix: return UV_EAGAIN if uv_try_write cannot write any data 2014-07-04 20:45:09 +02:00
Andrius Bentkus
0d43992c3b unix, win: add uv_udp_try_send
The function returns UV_EAGAIN if the queue is not empty and
the message couldn't be sent immediately.
2014-07-04 18:30:33 +02:00
Andrius Bentkus
b769484ca3 unix, win: add send_queue_size and send_queue_count to uv_udp_t
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.
2014-07-04 18:28:18 +02:00
Saúl Ibarra Corretgé
1830a3cd91 Revert "test: make barrier test more rigorous"
This reverts commit 6c6c922167.

It introduced a race condition which made tests fail on Linux and SunOS.

Closes #1340
2014-07-02 00:16:50 +02:00
Saúl Ibarra Corretgé
d4c1228d15 include: const-ify arguments to uv_getnameinfo_cb 2014-06-26 22:46:39 +02:00
Saúl Ibarra Corretgé
570caf04db Merge branch 'v0.10'
Conflicts:
	ChangeLog
	build.mk
	src/unix/darwin.c
	src/unix/getaddrinfo.c
	src/version.c
	test/test-list.h
2014-06-25 10:31:21 +02:00
Saúl Ibarra Corretgé
218f48ae56 build: fix compilation warning on MinGW-w64 2014-06-19 23:25:43 +02:00
Saúl Ibarra Corretgé
133b9d1cc1 unix: allow uv_getnameinfo to be cancelled 2014-06-18 02:00:07 +02:00
Saúl Ibarra Corretgé
12bb46c095 windows: fix handling closed socket while poll handle is closing
fixes #1278

(backport from master for v0.10 branch)
2014-06-17 20:16:43 +02:00
Fedor Indutny
c38e97ee4d test: fix EPIPE race in spawn_closed_process_io
The just created stdin should not be closed by a child process before
writing to it, otherwise EPIPE happens.
2014-06-09 08:47:18 -07:00
Ben Noordhuis
6c6c922167 test: make barrier test more rigorous
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>
2014-06-07 07:57:10 -07:00
Ben Noordhuis
91985d48f6 unix, windows: make uv_barrier_wait() return bool
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>
2014-06-07 07:57:08 -07:00
Saúl Ibarra Corretgé
eee4776549 windows: fix handling closed socket while poll handle is closing
fixes #1278
2014-05-30 19:19:36 +02:00
Saúl Ibarra Corretgé
4fac9427e4 unix, windows: fix parsing scoped IPv6 addresses
Signed-off-by: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-05-25 23:30:46 +02:00
Rasmus Christian Pedersen
70c42563c1 unix, windows: getnameinfo implementation
Closes #852
2014-05-20 17:33:52 +02:00
Ryan Cole
907b55e4bf process: adjust quote_cmd_arg for empty arguments
adjust quote_cmd_arg so that empty command line
arguments are double quoted instead of skipped
2014-05-12 23:55:58 +02:00
Saúl Ibarra Corretgé
386d2141e4 unix, windows: be consistent when binding implictly in UDP
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.
2014-05-08 15:12:09 +02:00
Saúl Ibarra Corretgé
fa0e1e5071 unix, windows: remove unneeded define 2014-05-08 09:08:33 +02:00
Trevor Norris
4d905fbe07 test: close stream immediately on error
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.
2014-04-24 16:48:27 -07:00
Saúl Ibarra Corretgé
9b4f2b84f1 unix, windows: validate flags on uv_udp|tcp_bind
fixes #1247
2014-04-22 22:57:01 +02:00
Rasmus Pedersen
cd6e74dd80 test: fix compilation warnings with VC++
C6011 and C4244
2014-04-17 17:31:11 +02:00
Fedor Indutny
2b21419242 inet: allow scopeid in uv_inet_pton
We already support it in `uv_ip6_addr` anyway.

See https://github.com/joyent/node/issues/7395
2014-04-14 15:47:50 +04:00
Fedor Indutny
23d130b209 Revert "inet: allow scope in uv_inet_pton ip6 check"
This reverts commit d30e3ab65a, because it
is a new feature!
2014-04-14 15:13:20 +04:00
Fedor Indutny
d30e3ab65a inet: allow scope in uv_inet_pton ip6 check
Note that isn't actually parsing it, since the output value is a
`struct in6_addr`.

see https://github.com/joyent/node/issues/7395
2014-04-14 12:45:42 +04:00
Fedor Indutny
69f9f6ffef test: fix EPIPE race in spawn_closed_process_io
The just created stdin should not be closed by a child process before
writing to it, otherwise EPIPE happens.
2014-04-11 18:24:48 +02:00
Alex Crichton
deff0e3571 test: Close process handles when spawn fails
This should avoid assertions tripping in debug mode.
2014-04-10 07:29:31 -07:00
Alex Crichton
621c4a3929 windows: Fix an infinite loop in uv_spawn
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
2014-04-10 07:29:24 -07:00
Saúl Ibarra Corretgé
d1ac594480 mingw: fix build with autotools 2014-04-03 09:56:16 +02:00
Saúl Ibarra Corretgé
7a4c42a054 unix: add UV_HANDLE_IPV6 flag to tcp and udp handles 2014-04-02 01:24:39 +02:00
Saúl Ibarra Corretgé
3558d65d2f unix, windows: do not set SO_REUSEADDR by default on udp
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.
2014-04-02 01:21:35 +02:00
Saúl Ibarra Corretgé
e7fdab1fd9 test: remove debug statement 2014-03-28 14:45:29 +01:00
Saúl Ibarra Corretgé
08327a7cbd unix, windows: add IPv6 support for uv_udp_multicast_interface 2014-03-28 00:39:09 +01:00
Fedor Indutny
c84796ecc2 Merge branch 'v0.10'
Conflicts:
	src/unix/process.c
2014-03-26 20:45:13 +04:00
Tonis Tiigi
fd77a5d6c6 process: don't close stdio fds during spawn
This is needed when closed stdio fd is reused for uv_spawn pipe.
Fixes #1211
2014-03-26 20:35:08 +04:00
Saúl Ibarra Corretgé
8bbf469cb0 test: fix multicast join test on OSX when using IPv6
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.
2014-03-20 23:07:12 +01:00
Saúl Ibarra Corretgé
7c5ab1a73e unix, windows: add IPv6 support to uv_udp_set_membership
Reworked from initial version by @snoj
2014-03-17 22:11:28 +01:00
Saúl Ibarra Corretgé
db2a9072bc unix, windows: removed unused status parameter
async, timer, prepare, idle and check handles don't need the status
parameter.
2014-03-17 21:42:36 +01:00
Geoffry Song
84f305915f linux: always deregister closing fds from epoll
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
2014-03-10 17:27:36 +04:00
Saúl Ibarra Corretgé
0e59136823 test: fix compiation warning
-Wunused-function would kick in because of the close_loop function,
but there tests and benchmarks which actually don't use any loop.
2014-03-03 21:49:34 +01:00
Fedor Indutny
b05a3ee4d1 pipe: allow queueing pending handles
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(...);
    }
2014-03-04 00:34:29 +04:00
Saúl Ibarra Corretgé
e4f28adce4 test: make sure all handles in the loop are closed 2014-02-28 09:33:30 +01:00
Saúl Ibarra Corretgé
422d2810b3 unix, windows: make uv_cwd be consistent with uv_exepath
Fixes #446
2014-02-27 09:44:28 +01:00
Saúl Ibarra Corretgé
3a8767e35e unix: fix uv_fs_write when using an empty buffer 2014-02-26 23:59:29 +01:00
Saúl Ibarra Corretgé
8c9d5dce57 unix, windows: add uv_fs_poll_getpath 2014-02-24 23:21:13 +01:00
Saúl Ibarra Corretgé
a7ac2c462a unix, windows: add uv_fs_event_getpath 2014-02-24 22:08:23 +01:00
Saúl Ibarra Corretgé
d3791bd4c3 test: fix compilation warning on non-linux systems 2014-02-24 21:46:19 +01:00
Fedor Indutny
644337a337 test: fix compiler warning 2014-02-24 15:44:54 +04:00
Saúl Ibarra Corretgé
7677f62c52 test: fix compilation warning 2014-02-24 09:50:34 +01:00
Saúl Ibarra Corretgé
5ac214c712 unix, windows: add uv_pipe_getsockname 2014-02-23 20:25:20 +01:00
Benjamin Saunders
13dd3502a7 fs: vectored IO API for filesystem read/write
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.
2014-02-23 17:24:05 +01:00
Lars Gierth
1ad61807ff test: fix spawn_stdout_and_stderr_to_file test
S_IREAD and S_IWRITE are obsolete in GNU libs and
not included in the Android NDK's libc. See
http://www.gnu.org/savannah-checkouts/gnu/libc
/manual/html_node/Permission-Bits.html
2014-02-21 18:54:52 +01:00