Commit Graph

1541 Commits

Author SHA1 Message Date
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
Oleg Efimov
da9a2b1d3d unix, windows: add uv_getrusage() function 2014-02-21 18:50:15 +01:00
Saúl Ibarra Corretgé
787f5fff92 unix, windows: add uv_loop_init and uv_loop_close
These functions supersede uv_loop_new and uv_loop_delete.
uv_loop_init initialized a user allocated loop and uv_loop_close
removes all associated resources a loop uses after it has finished
execution.

uv_loop_new and uv_loop_delete are now deprecated.
2014-02-21 09:56:13 +01:00
Rasmus Pedersen
fd35e7a0bd test: fix VC++ warning C4244 2014-02-20 11:32:07 +01:00
Geoffry Song
780d8ad8e5 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.
2014-02-19 17:13:49 +04:00
Fedor Indutny
a03ea239db Revert "fs: vectored IO API for filesystem read/write"
This reverts commit 7df24583e5.
2014-02-18 21:48:13 +04:00
Benjamin Saunders
7df24583e5 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-18 12:30:20 +04:00
Saúl Ibarra Corretgé
6e2021ca11 unix: correct error when calling uv_shutdown twice
This is a backport of a284b90 for v0.10 branch
2014-02-15 16:55:06 +01:00
Keno Fischer
a284b90c03 unix: correct error when calling uv_shutdown twice
Before this one of the requests was left as a ghost in the system.
See https://github.com/JuliaLang/julia/issues/5793
2014-02-15 16:37:58 +01:00
Saúl Ibarra Corretgé
419c2ffae7 test: fix udp multicast interface test 2014-02-10 08:56:39 +01:00
Austin Foxley
451de61b72 unix, win: add uv_udp_set_multicast_interface() 2014-02-07 09:07:11 +01:00
Fedor Indutny
280469f4fe test: build spawn_fs_open only on unixes 2014-02-05 13:35:37 +04:00
Fedor Indutny
cb1cc25430 test: fix build on windows
disable spawn_fs_open
2014-02-01 04:57:16 +04:00
Fedor Indutny
6abe1e4b95 fs: uv__cloexec() opened fd
Every file descriptor opened using libuv should be automatically marked
as CLOEXEC to prevent it from leaking to a child process. Note that
since we are opening fds in a thread pool, there is a possible race
condition between `uv_spawn()` and the `open()` + `uv__cloexec()`. The
rwlock was added to avoid it.

see https://github.com/joyent/node/issues/6905
2014-02-01 01:02:37 +04:00
Dylan Cali
6c525df76d test: set getaddrinfo_fail timeout to 10000
getaddrinfo_fail can sometimes take slightly longer than the default
timeout of 5000. Set its timeout to 10000 to compensate, but leave the
timeout of all other tests at the default.
2014-02-01 00:50:40 +04:00
Dylan Cali
756087e017 test: support flexibly setting custom task options
Add a single TEST_ENTRY_CUSTOM hook that can be used to override task
entry defaults. Different tests can have different timeouts depending on
what is appropriate for each test. A separate TEST_OUTPUT_ENTRY hook is
no longer necessary.

In order to support per-task timeouts, the timeout field has been moved
into the task_entry_t struct. The default (5000) is now set as part of
TEST_ENTRY.
2014-02-01 00:50:40 +04:00
Fedor Indutny
3a4ec61d46 test: fix after merge 2014-01-22 23:00:49 +04:00
Bert Belder
53effc3dd8 Merge branch 'v0.10'
Conflicts:
	ChangeLog
	src/unix/process.c
	src/version.c
2014-01-22 19:49:24 +01:00
Fedor Indutny
e403a2c486 process: close stdio after dup2'ing it
Thus allow passing the same file descriptor as the source of multiple
stdios.

Committed with the help and code parts from:

  * Sam Roberts <sam@strongloop.com>

fix #1074
2014-01-22 22:39:08 +04:00
Fedor Indutny
8f15aae52f tcp: uv_tcp_dualstack()
Explicitly disable/enable dualstack depending on presence of flag set by
uv_tcp_dualstack() function.
2014-01-19 23:07:42 +00:00
Bert Belder
140c863ff0 Merge branch 'v0.10'
Conflicts:
	build.mk
	Makefile.am
	test/test-ipc.c
2013-12-21 02:42:48 -08:00
Bert Belder
16c4b21e4d test: make test-pipe-server-close pass on linux
When a server and a client are both part of the same event loop, and
the client connects to the server, the order in which the connect
callback and the connection callback are called is unspecified.
Apparently on linux the connection callback sometimes happens first,
which is not a bug, and should not make this test fail.
2013-12-21 02:34:44 -08:00
Bert Belder
c66340d59b test: add pipe-server-close test
Add a regression test for the pipe server close issue on Windows, which
was reported in joyent/node#6749 and fixed in 7b16a3f.
2013-12-20 19:40:02 -08:00
Bert Belder
562d7a49ac code style: strip trailing whitespace 2013-12-20 19:38:37 -08:00
Sam Roberts
ed36b85d3b unix, windows: add uv_loop_alive() function
Useful to know when the the event loop is empty, this can't be done with
uv_run() without possibly blocking, or running some events (which might
empty the event loop as a side-effect).
2013-12-19 15:35:03 -08:00
Joshua Neuheisel
b44edf313c test: allow UV_EACCES in spawn_fails
Allow UV_EACCES as a successful return value when uv_spawn fails.

When the PATH environment variable contains a directory which the
user cannot access, execvp may return EACCES instead of ENOENT.

fix #1045.
2013-12-18 14:02:51 +04:00
Fedor Indutny
17d60e3f94 stream: allow multiple buffers for uv_try_write 2013-12-13 22:59:47 +04:00
Fedor Indutny
7f65a74f8e test: remove C++ style comment 2013-12-13 22:37:14 +04:00
Fedor Indutny
b5e7798a89 stream: introduce uv_try_write(...)
`uv_try_write(stream, buf, size)` acts like `uv_write()`,
but without queueing actual write until UV_POLLOUT (or IOCP completion).
This is useful for doing writes using on-stack `uv_write_t` requests.

fix #1025
2013-12-13 22:29:00 +04:00
Yorkie
4ed6496b9c unix, windows: detect errors in uv_ip4/6_addr 2013-12-13 09:27:28 +01:00
Saúl Ibarra Corretgé
15af49a7a0 unix, windows: always update loop time
Fixes #846
2013-12-10 09:13:34 +01:00
Ben Noordhuis
a43537eead test: back-port EMFILE test from master branch
Back-port the test from commit 27795cf from the master branch ("unix:
fix accept() EMFILE error handling").
2013-11-25 12:58:39 +01:00
Ben Noordhuis
27795cfc0f unix: fix accept() EMFILE error handling
Fix a bug that was introduced in commit 3ee4d3f ("unix, windows:
return error codes directly") and add a regression test for good
measure.

Hat tip to Fedor for pointing out the issue.

Fixes #1007.
2013-11-25 01:54:47 +01:00
Ben Noordhuis
0c05532e13 test: don't connect to 0.0.0.0
OpenBSD won't let you do that, the connect() system call fails with
an EINVAL error.  Connect to 127.0.0.1 instead.
2013-11-16 21:58:03 +01:00
Fedor Indutny
86b5c1ef1c test: test fsevents error reporting
Create a lot of `FSEventStream`s to make `FSEventStreamStart()` fail.
Fetch the error code and verify that it is correct.
2013-11-13 18:18:56 +04:00
Ben Noordhuis
17711b9053 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	src/unix/darwin.c
	src/version.c
2013-11-13 13:52:53 +01:00
Fedor Indutny
6149b66ccb Merge branch 'v0.10'
Conflicts:
	build.mk
	src/unix/core.c
	src/unix/darwin.c
2013-11-12 15:30:54 +04:00
Fedor Indutny
bbccafbe70 unix: fix reopened fd bug
When fd is closed and new one (with the same number) is opened inside
kqueue/epoll/port loop's callback - stale events might invoke callbacks
on wrong watchers.

Check if watcher was changed after invocation and invalidate all events
with the same fd.

fix #826
2013-11-12 15:02:59 +04:00
Fedor Indutny
0f5c28b684 fsevents: use FlagNoDefer for FSEventStreamCreate
Otherwise `FSEventStreamCreate()` will coalesce events, even if they're
happening in the interval, bigger than supplied `latency`. In other
words, if this flag is not set events will happen in separate callback
only if there was a delay bigger than `latency` between two consecutive
events.
2013-11-10 13:05:27 +04:00
Ben Noordhuis
24bfef2ef4 linux: handle EPOLLHUP without EPOLLIN/EPOLLOUT
Work around an epoll quirk where it sometimes reports just the EPOLLERR
or EPOLLHUP event.  In order to force the event loop to move forward,
we merge in the read/write events that the watcher is interested in;
uv__read() and uv__write() will then deal with the error or hangup in
the usual fashion.

Fixes #982.
2013-11-08 05:16:55 +01:00
Ben Noordhuis
2bb3326c48 Merge remote-tracking branch 'origin/v0.10'
Drops commit 3780e12 ("fsevents: support japaneese characters in path")
for being quite inapplicable to the master branch.  Will be reworked
and applied in a follow-up commit.

Conflicts:
	README.md
	build.mk
	src/unix/fsevents.c
	src/unix/udp.c
2013-11-08 03:44:31 +01:00
Alex Crichton
f764bff699 unix: return exec errors from uv_spawn, not async
If spawning a process fails due to an exec() failure (but it succeeded
in forking), then this should be considered a spawn failure instead of
an asynchronous termination of the process. This allows to check for
common exec() failure conditions such as a bad path quickly instead of
having to rely on keeping track of the async callback.

Additionally, the meaning of the two fields returned in the callback are
now exactly what they advertise to be. The process exit argument is not
one of two values depending on what happened to the child.

Fixes #978.
2013-11-07 22:10:38 +01:00
Ben Noordhuis
7f44933c43 include: remove uv_strlcat() and uv_strlcpy()
It was pointed out that they don't quite work like their BSD namesakes
and they arguably shouldn't have been part of the API anyway.

Fixes #983.
2013-11-03 03:50:23 +01:00
Fedor Indutny
f9960184fd test: add regression test for 29fdb3471 2013-10-31 01:16:02 +04:00
Sean Farrell
ee434b3069 test: remove replacement snprintf for mingw
Mingw has a proper definition of snprintf.
2013-10-25 13:01:31 +02:00
Ben Noordhuis
147ab0c582 test: clean up signal_multiple_loops
The test uses some questionable binary math.  Rewrite it in a more
explicit fashion.
2013-10-20 13:57:16 +02:00
Saúl Ibarra Corretgé
9d44d786ad unix, windows: add uv_fs_event_start/stop functions
Make uv_fs_event behave like other handles, that is, it's inactive after
init, and it's active between start and stop.
2013-10-12 20:37:05 +02:00
Luca Bruno
a1e159f04e test: relax timing assumption of timer_again
timer_again test makes an implicit assumption on the triggering
timing of a repeating timer. However, this assumption may be not
true on slower or virtualized architecture due to delay accumulation,
which may fail the test as show in [0].
This commit makes explicit checks conforming to the asserted behavior.

[0] http://ur1.ca/fr5c4

Signed-off-by: Luca Bruno <lucab@debian.org>
2013-10-08 16:26:04 +02:00
Luca Bruno
bddf357baf test: relax timing assumption of loop_stop
The loop_stop test makes an implicit assumption about the triggering
timing of a repeating trigger, which may not hold true on slower or
virtualized machines, thus failing the test as shown at [0] and
discussed at [1].
This commit relaxes the assumption, without mandating the exact number
of runs.

[0] http://ur1.ca/fr5bw
[1] https://groups.google.com/d/msg/libuv/5-fNIC7hIAo/yqznDmwHDAIJ

Signed-off-by: Luca Bruno <lucab@debian.org>
2013-10-08 16:26:04 +02:00
Luca Bruno
6462eaf4dc test: relax TTY availability assumptions
test-tty.c currently assumes that a TTY is available to the test runner,
and fails hard if not. This may not be true on some autobuilding
environment, making the build fail as shown in [0].
Instead, let's properly skip the test in such cases.

[0] http://ur1.ca/fr5bd

Signed-off-by: Luca Bruno <lucab@debian.org>
2013-10-08 16:26:04 +02:00
Fedor Indutny
429bb804ed fsevents: fix clever rescheduling
There're could be a situation, where one fsevents handle gets created
and another one is destroyed simultaneously. In such cases
`fsevent_need_reschedule` will be set to 1 twice and reset only once,
leaving handle destructor hanging in uv_sem_wait().
2013-10-05 22:18:06 +04:00
Ben Noordhuis
359d667893 unix: sanity-check fds before closing
Ensure that close() system calls don't close stdio file descriptors
because that is almost never the intention.

This is also a partial workaround for a kernel bug that seems to affect
all Linux kernels when stdin is a pipe that gets closed: fd 0 keeps
signalling EPOLLHUP but a subsequent call to epoll_ctl(EPOLL_CTL_DEL)
fails with EBADF.  See joyent/node#6271 for details and a test case.
2013-10-01 03:55:54 +02:00
Ben Noordhuis
b460142451 bench: measure total/init/dispatch/cleanup times
* Add finer-grained measurements to the million_timers benchmark.
  Before this commit it only measured the total running time.

* Bump the number of inserted timers from 1M to 10M.  With one million
  timers, it finishes too quickly to get useful profiling data out of
  it with perf or oprofile.  The name of the benchmark is now a lie but
  such is life.
2013-09-13 00:17:52 +02:00
Ben Noordhuis
d7115f0677 unix, windows: make uv_is_*() always return 0 or 1
Ensure that the following API functions always return either 0 or 1:

  * uv_is_active()
  * uv_is_closing()
  * uv_is_readable()
  * uv_is_writable()
2013-09-12 13:30:06 +02:00
Ben Noordhuis
f5baf210df test: wrap long lines at 80 columns 2013-09-11 17:29:43 +02:00
Saúl Ibarra Corretgé
2b9c374c1c windows: run close callbacks after polling for i/o
Makes the uv-win behavior compatible with uv-unix.

Fixes #796.
2013-09-06 06:28:42 +02:00
Ben Noordhuis
08c6ddeefb include: merge uv_udp_send and uv_udp_send6
Merge uv_udp_send6() into uv_udp_send().  uv_udp_send() now takes a
const struct sockaddr*.
2013-09-04 03:17:29 +02:00
Ben Noordhuis
bcee403ed2 include: merge uv_udp_bind and uv_udp_bind6
Merge uv_udp_bind6() into uv_udp_bind().  uv_udp_bind() now takes a
const struct sockaddr*.
2013-09-04 03:17:04 +02:00
Ben Noordhuis
5c675c4a4e include: merge uv_tcp_connect and uv_tcp_connect6
Merge uv_tcp_connect6() into uv_tcp_connect().  uv_tcp_connect() now
takes a const struct sockaddr*.
2013-09-04 03:16:36 +02:00
Ben Noordhuis
5fceccc535 include: merge uv_tcp_bind and uv_tcp_bind6
Merge uv_tcp_bind6() into uv_tcp_bind().  uv_tcp_bind() now takes a
const struct sockaddr*.
2013-09-04 03:15:30 +02:00
Ben Noordhuis
8c6ea10502 include: uv_spawn takes const uv_process_options_t*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 08:25:00 +02:00
Ben Noordhuis
263da51967 include: uv_udp_send{6} now takes sockaddr_in*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 08:02:20 +02:00
Ben Noordhuis
525dbb5e31 include: uv_udp_bind{6} now takes sockaddr_in*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 08:02:18 +02:00
Ben Noordhuis
0f7b2963ad include: uv_udp_recv_cb now takes const uv_buf_t*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 08:02:17 +02:00
Ben Noordhuis
255671da74 include: uv_tcp_connect{6} now takes sockaddr_in*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 08:02:15 +02:00
Ben Noordhuis
daa229ace3 include: uv_tcp_bind{6} now takes sockaddr_in*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 08:02:13 +02:00
Ben Noordhuis
8184076879 include: uv_ip[46]_addr now takes sockaddr_in*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 08:02:07 +02:00
Ben Noordhuis
b7d027c3a8 include: uv_read{2}_cb now takes const uv_buf_t*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 08:01:34 +02:00
Ben Noordhuis
3fb6612233 include: uv_alloc_cb now takes uv_buf_t*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 07:57:31 +02:00
Ben Noordhuis
8c9f28b4ac test: fix epoll_wait() usage in test-embed.c
Passing 0 as the `maxevents` argument fails with EINVAL, passing NULL as
the `events` argument fails with EFAULT.

Fixes #915.
2013-08-31 22:09:53 +02:00
Ben Noordhuis
5d2434bf71 unix, windows: add thread-local storage API
Uses the pthread_key_{create,delete} and pthread_{get,set}specific
functions on UNIX platforms, Tls{Alloc,Free} and Tls{Get,Set}Value
on Windows.

Fixes #904.
2013-08-25 15:51:07 +02:00
Bert Belder
d8a3ed6cd0 test: strip trailing whitespace 2013-08-24 16:45:30 +02:00
Bert Belder
66ae0ff562 process: make the 'status' parameter for exit_cb an int64_t
This means we no longer have to strip the high bit from the process exit
code on Windows, which is problematic because an unhandled SEH exception
can make a process exit with a status code that has the high bit set.
2013-08-23 18:35:09 +02:00
Ben Noordhuis
dfce87c94f test: simplify test-ip6-addr.c
Drop the callback-driven approach in favor of a simple loop. Reduces
the line count and makes the flow of execution a little easier to
follow.
2013-08-19 22:37:48 +02:00
Ben Noordhuis
1510ce81fd unix, windows: allow NULL async callback
Allow a NULL callback so the user doesn't have to provide a dummy when
the actual event is processed by e.g. a check handle callback.
2013-08-12 08:55:51 +02:00
Ben Noordhuis
fd082901f1 test: add windows-only snprintf() function
Should fix the build after 96f32a2 inadvertently broke it.

There is no snprintf() on Windows because, hey, it's a C99 addition
and the people from Redmond, WA are still firmly stuck in 1989.
2013-08-05 14:14:02 +02:00
Ben Noordhuis
5af98d3843 test: replace strcpy() with strncpy() 2013-08-05 02:45:40 +02:00
Ben Noordhuis
96f32a206b test: replace sprintf() with snprintf()
There is zero risk of overflowing the buffer, it's just a good habit.
2013-08-05 01:16:34 +02:00
Brian White
e3a657c662 unix, windows: add MAC to uv_interface_addresses()
Make uv_interface_addresses() return the MAC address as a 48 bits
binary value in the phys_addr field of the uv_interface_address_t
struct.
2013-07-25 13:49:39 +02:00
Ben Noordhuis
4ce3a312aa test: fix signed/unsigned comparison warnings 2013-07-25 11:25:53 +02:00
Ben Noordhuis
3ee4d3f183 unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like this one:

    if (uv_foo(loop) < 0) {
      uv_err_t err = uv_last_error(loop);
      fprintf(stderr, "%s\n", uv_strerror(err));
    }

Should be rewritten like this:

    int err = uv_foo(loop);
    if (err < 0)
      fprintf(stderr, "%s\n", uv_strerror(err));

The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
2013-07-07 09:51:00 +02:00
Miroslav Bajtoš
fd45f876ff linux,darwin,win: link-local IPv6 addresses
Modified uv_ip6_addr() to fill sin6_scope_id for link-local addresses.

Fixes #271

Conflicts:
	build.mk
2013-07-04 15:43:20 +02:00
Ben Noordhuis
5a3b8f9fce test: fix spawn_setgid_fails and spawn_setuid_fails
Don't try to set a bogus UID or GID and expect to get a meaningful
error. The test expected EPERM but SunOS returns EINVAL because the
id is outside of the range of valid user/group ids.

Try to switch to UID/GID 0. Give up privileges first if we're root,
else the setuid/setgid system call will succeed when it's expected
to fail.
2013-07-02 16:32:42 +02:00
Ben Noordhuis
d0be852cb1 test: fix fs_chown when running as root
chown(2) to root is expected to fail - unless you're root, of course.
2013-07-02 13:39:28 +02:00
Ben Noordhuis
d4f6165346 test: fix fs_fstat test on sunos
The tests are no longer compiled with -D_XOPEN_SOURCE=500 when building
with autotools. Tell the test explicitly that SunOS systems are
expected to have nanosecond fstat(2) granularity.
2013-07-02 13:34:19 +02:00
Ben Noordhuis
ddd7e04fd6 build: switch to autotools
Switch to the build tool everyone loves to hate.  The Makefile has
served us well over the years but it's been acquiring more and more
features that autotools gives us for free, like easy static+shared
library building, sane install targets, and so on.

This commit drops MinGW support.  If there is demand for it, we'll
re-add it.
2013-07-02 01:21:16 +02:00
Saúl Ibarra Corretgé
f9e6029b82 unix, windows: add extra fields to uv_stat_t 2013-06-28 00:42:37 +02:00
Ben Noordhuis
ce2458c053 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	test/test-fs.c
	test/test-list.h
2013-06-26 10:35:41 +02:00
Ben Noordhuis
5841852703 test: add 'start timer from check handle' test
Check that a timer that is started from a check handle gets picked up
correctly, i.e. that it influences the timeout used in the next tick
of the event loop.
2013-06-26 13:56:32 +02:00
Ben Noordhuis
488b43ecc5 test: fix signed/unsigned compiler warning 2013-06-26 13:40:40 +02:00
Ben Noordhuis
6607e70253 test: open stdout fd in write-only mode
Fixes #771.
2013-06-18 23:53:03 +02:00
Ben Noordhuis
ede83188f3 test: don't use S_IREAD and S_IWRITE
They're BSD-isms and obsolete ones at that. Replace with S_IRUSR and
S_IWUSR. Alias as _S_IREAD and _S_IWRITE on Windows because the '90s
never ended in Redmond, WA.
2013-05-31 12:50:19 +02:00
Bert Belder
081f7018ec test: use c-style comments
Fixes a compilation problem on OS X caused by the use of c++-style
comments in test-osx-select.c.
2013-05-29 18:32:25 +03:00
Ben Noordhuis
f6d8ba3c9a unix, windows: run expired timers in run-once mode
Before this commit, creating an event loop, starting a timer and
calling uv_run(UV_RUN_ONCE) blocked in uv_run() until the timer
expired - but didn't actually run the timer.
2013-05-30 00:33:23 +02:00
Ben Noordhuis
8ef9592a95 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	ChangeLog
	src/unix/stream.c
	src/version.c
2013-05-29 23:32:07 +02:00
Bert Belder
b5cd78ea05 test: reflect new idle semantics in test
Update the `idle_starvation` test to verify not only that idle callbacks
are called, but also that they are called once per loop iteration.
2013-05-29 22:52:06 +02:00
Bert Belder
961202d1c2 Merge branch 'v0.10'
Conflicts:
	ChangeLog
	config-unix.mk
	src/version.c
2013-05-14 17:03:24 -07:00
Miroslav Bajtoš
0564ee4a66 test, sunos: disable process_title test
Disable unit test failing due to missing implementation
of uv_(set|get)_process_title for Sun OS (SmartOS).

Based on discussion with @tjfontaine, such implementation is difficult
if possible at all and it won't be done anytime soon. Thus there is
no point in keeping the failing test around.
2013-05-14 13:36:32 +02:00
Ben Noordhuis
7d9c5572b8 Merge remote-tracking branch 'origin/v0.10' 2013-05-12 14:53:19 +02:00
Miroslav Bajtoš
fe2a3150c0 test: add error logging to tty unit test 2013-05-08 17:20:20 -07:00
Miroslav Bajtoš
af6e865a07 test: fix process_title failing on linux
Shorten the test string from 40 to 38 characters because the title
length is limited to 39 characters.

Truncation of long titles was introduced intentionally by commit
a0c1d84 (see discussion in joyent/node#5006).
2013-05-08 17:20:20 -07:00
Ben Noordhuis
ce580cc057 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	ChangeLog
2013-05-08 15:46:54 -07:00
Miroslav Bajtoš
2c21050956 test: add RETURN_SKIP and RETURN_TODO macros
Added two new flags to identify tests that are intentionally ignored
(usually because we don't want to implement the tested functionality
on current platform) and test serving as TODO list (usually indicating
that the tested functionality should be implemented on current plaform
in the near future.)
2013-05-08 15:43:54 -07:00
Ben Noordhuis
ebdeaed2e3 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	ChangeLog
	src/version.c
2013-05-02 09:22:39 +02:00
Fedor Indutny
ac4e7e7ff2 stream: fix small nit in select hack, add test 2013-04-27 18:50:55 +02:00
Saúl Ibarra Corretgé
a92b66fe33 unix, windows: add uv_has_ref() function 2013-04-17 15:31:08 +02:00
Ben Kelly
14aa6153be unix, win: add netmask to uv_interface_address
Include the netmask when returning information about the OS network
interfaces.

This commit provides implementations for windows and those unix
platforms using getifaddrs().

AIX was not implemented because it requires the use of ioctls and I do
not have an AIX development/test environment.  The windows code was
developed using mingw on winxp as I do not have access to visual studio.

Tested on darwin (ipv4/ipv6) and winxp (ipv4 only).  Needs testing on
newer windows using ipv6 and other unix platforms.
2013-04-10 14:48:23 +02:00
Ben Noordhuis
f78bcfbd6a Merge remote-tracking branch 'origin/v0.10' 2013-04-10 14:24:18 +02:00
Fedor Indutny
895e77639e unix: don't write more than IOV_MAX iovecs
Write no more than `IOV_MAX` chunks with `writev()` at
once, otherwise `writev()` returns EINVAL.
2013-04-08 19:51:30 +04:00
Ben Noordhuis
23947fdabb Merge remote-tracking branch 'origin/v0.10' 2013-03-29 15:57:10 +01:00
Saúl Ibarra Corretgé
a9a23dc28e unix: don't clear flags after closing UDP handle 2013-03-28 16:08:42 +01:00
Ben Noordhuis
76d831e4c8 unix: getaddrinfo_cb status arg should be 0 or -1
The documentation in uv.h states that the status argument to the
uv_getaddrinfo() callback is either 0 or -1 but uv-unix actually
passed it the addrinfo error code. Rectify that and add a regression
test.

Fixes #754.
2013-03-26 22:30:46 +01:00
Ben Noordhuis
eca008a386 Merge remote-tracking branch 'origin/v0.10' 2013-03-23 19:15:45 +01:00
Ben Noordhuis
9b619396d9 unix: make timers handle large timeouts
This commit fixes two closely related integer overflow bugs:

* Timers with a timeout > INT_MAX cause uv__next_timeout() to return
  a negative value.

* Timers with very large timeouts (close or equal to ULLONG_MAX) run on
  the next tick.

In both cases, clamp the values to prevent the overflow from happening.

Fixes joyent/node#5101.
2013-03-21 14:54:36 +01:00
Brian Mazza
77cb29a723 unix: make uv_timer_init() initialize repeat
uv_timer_get_repeat() should return 0 for timers that haven't been
started.
2013-03-19 23:15:30 +01:00
Timothy J Fontaine
499c7976c6 unix, windows: nanosecond resolution for uv_fs_[fl]stat
Closes #739.
2013-03-19 21:48:15 +01:00
Timothy J Fontaine
2f84a57566 test: add tap output for windows 2013-03-11 18:12:25 +01:00
Timothy J Fontaine
49d2ae33ef test: fix tap output even when ok but have output 2013-02-27 22:48:54 +01:00
Ben Noordhuis
1821bba408 test: fix tap output check
Only report as an error when status != 0.

Stops the platform_output test from being reported as having failed
on Jenkins.
2013-02-27 22:20:14 +01:00
Ben Noordhuis
a924f79023 test: remove 'is root?' check
I debug tests regularly as root (because dtrace and dtruss require the
additional privileges). The 'is root?' check gets in the way more often
than it prevents me from doing something silly. Remove it.
2013-02-27 21:35:40 +01:00
Timothy J Fontaine
72bbf5d702 test: don't rewind_cursor when using tap_output 2013-02-25 19:00:16 +01:00
Saúl Ibarra Corretgé
4b957482ba windows: fix uv_stop in ONCE and NOWAIT modes
Same as the fix in 492efb9 but this time for uv-win.
2013-02-25 18:26:58 +01:00
Saúl Ibarra Corretgé
bb3d1e24da unix, windows: add uv_stop, stop running event loop 2013-02-25 16:21:37 +01:00
Timothy J Fontaine
bfe269b8a0 test: add tap output
Given UV_TAP_OUTPUT being set, test result output should use TAP formatting
2013-02-22 23:06:17 +01:00
Ben Noordhuis
da0b84d4e8 unix: auto-unref spawn handle on process exit
Consistent, for better or worse, with uv-win.

Fixes #718.
2013-02-22 14:39:40 +01:00
Ben Noordhuis
d6bfedb862 unix, windows: make uv_now() return uint64_t
Using int64_t doesn't make sense here because the return value is never
negative.
2013-02-20 16:58:45 +01:00
Ben Noordhuis
da71649991 unix, windows: make uv_fs_t.statbuf public
Make the statbuf field public. This means you no longer have to use
req->ptr - though that still works and will continue to work for the
foreseeable future.

Fixes #704.
2013-02-10 17:50:03 +01:00
Shigeki Ohtsu
fadfeaf6ec unix,windows: fix timer order in case of same timeout
Compare start_id of timer handles when they have the same timeout.
start_id is allocated with loop->timer_counter in uv_timer_start.
2013-02-10 17:46:22 +01:00
Andrius Bentkus
017e2d5fde unix, windows: make uv_*_bind() error codes consistent
Just like uv_tcp_connect() it should return an EINVAL when the handle
is of an invalid type or when the network address is faulty.
2013-01-18 12:18:23 +01:00
Ben Noordhuis
e7f384f853 test: make threadpool tests valgrind-compliant
Delete the event loop after the test to stop valgrind from complaining
about memory leaks.
2013-01-16 23:59:58 +01:00
Ben Noordhuis
4ba03ddd56 unix, windows: rename uv_run2 to uv_run
This changes the prototype of uv_run() from:

  int uv_run(uv_loop_t* loop);

To:

  int uv_run(uv_loop_t* loop, uv_run_mode mode);

Where `mode` is UV_RUN_DEFAULT, UV_RUN_ONCE or UV_RUN_NOWAIT.

Fixes #683.
2013-01-16 23:35:29 +01:00
Ben Noordhuis
4cbd5c7b32 test: remove bad tcp_write_error test
It makes the assumption that if you try to write to a localhost socket
often enough, eventually its send queue will fill up - which doesn't
happen if the machine it's running on is fast enough.
2013-01-16 00:31:21 +01:00
Ben Noordhuis
9aab5d4837 Revert "unix: improve uv_guess_handle() implementation"
This reverts commit 98bcddc8dd.

It's making a lot of tests in the node.js test suite fail.
2013-01-11 13:40:25 +01:00
Ben Leslie
98bcddc8dd unix: improve uv_guess_handle() implementation
uv_guess_handle is currently squelching both fifo and all
sockets on to the UV_NAMED_PIPE type. Rather than treating
all sockets as UV_NAMED_PIPE, use getsockopt() and
getsockaddr() to determine if the socket is an AF_UNIX
stream (in which case return UV_NAMED_PIPE), or an AF_INET
stream (in which case return UV_TCP), or an AF_INET datagram
socket (in which case return UV_UDP).

Additionally, currently all other file descriptor types are
squelched to the UV_FILE type. Instead, only file descriptors
that are marked as regular files are treated as UV_FILE. All
other types (such as directories, character and block devices)
are now treated as UV_UNKNOWN_HANDLE.
2013-01-08 05:26:58 +01:00
Ben Noordhuis
f24335d498 test: fix #if defined checks
Same as edd1007 but this time for the tests.
2013-01-06 22:36:54 +01:00
Ben Noordhuis
fb725c0893 test: simplify tcp_ref2b
Said test doesn't need its own close callback, it can piggyback on the
common close callback.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
ccb96b67df test: remove unused function declaration 2013-01-06 22:31:48 +01:00
Ben Noordhuis
847182cdf1 test, bench: make functions/variables static
Make functions and variables that are local to the compilation unit
static. Remove what turns out to be unused.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
7ff6f29b85 test, bench: ANSI-fy function prototypes
Replace `void f()` with `void f(void)`; the former means "a function
that takes any number of arguments, including none" while the latter
is what is actually intended: a function taking no arguments.

The first form also isn't strictly conforming ANSI/ISO C.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
1f52fc1c5a test: remove consumer_producer test
It fails intermittently on Travis for no other reason than that Travis
is occasionally slow. Reduce the number of false positives, remove the
test.
2013-01-06 19:19:23 +01:00
Ben Noordhuis
92a19a19dd unix: ensure done_cb gets called after uv_cancel()
Wake up the event loop with uv_async_send() when a request is cancelled.
Ensures the done_cb is run on the next tick of the event loop.

Not sending a wakeup signal results in the done_cb not getting called until
another request completes, which may be a long time coming when it's the only
request in the queue or when other requests are executing long-running jobs.

Fixes #669.
2012-12-28 18:09:39 +01:00
Saúl Ibarra Corretgé
33d5c497a6 prepare/idle/check: don't allow NULL callback 2012-12-24 17:05:01 +01:00
Ben Noordhuis
5af43ba446 bench: add 'million async handles' benchmark 2012-12-24 12:19:10 +01:00
Ben Noordhuis
1c722d6c22 test: make fmt() not leak memory 2012-12-24 12:03:25 +01:00
Saúl Ibarra Corretgé
0820be7008 Implemented uv_run2
Allows for running the event loop in 3 modes:
  * default: loop runs until the refcount drops to zero
  * once: poll for events only once and block until one is handled
  * nowait: poll for events only once but don't block if there are
    no pending events
2012-12-18 16:11:23 +01:00
Ben Noordhuis
c6c5b7a901 Merge branch 'v0.8' 2012-12-14 12:07:31 +01:00
Andrew Shaffer
49977386e9 sunos: properly disarm PORT_LOADED fsevent watcher
Fixes a segmentation fault when the watched entity is changed after the watcher
has been closed.
2012-12-14 12:02:57 +01:00
Ben Noordhuis
a3b57dd598 test, bench: remove unused includes 2012-12-14 11:48:04 +01:00
Ben Noordhuis
f5b6374948 test, bench: replace strlen() with sizeof() 2012-12-14 11:47:54 +01:00
Ben Noordhuis
0a05b31a93 test: fix -Wunused-result warnings 2012-12-14 11:34:17 +01:00
Ben Noordhuis
e079a99abd unix: fix event loop stall
Fix a rather obscure bug where the event loop stalls when an I/O watcher is
stopped while an artificial event, generated with uv__io_feed(), is pending.
2012-12-13 20:17:12 +01:00
Ben Noordhuis
92fb84b751 unix: rework uv_cancel() api
Bert Belder informs me the current approach where a request is immediately
cancelled, is impossible to implement on Windows.

Rework the API to always invoke the "done" callback with an UV_ECANCELED error
code.
2012-12-13 13:46:38 +01:00
Ben Noordhuis
52c8a8617d unix: add uv_cancel() 2012-12-09 15:12:42 +01:00
Shigeki Ohtsu
fa11db905a test: fix finished consumer number check 2012-11-29 15:40:00 +01:00
Ben Noordhuis
4a69c4bb5f unix: change uv_backend_timeout() prototype
* change return value to signed int
* constify loop argument
2012-11-28 17:02:30 +01:00
Fedor Indutny
09a7f85b70 unix: add uv_backend_fd() and uv_backend_timeout()
This can be used in conjuction with uv_run_once() to poll in one thread and run
the event loop's event callbacks in another.

Useful for embedding libuv's event loop in another event loop.
2012-11-28 16:30:50 +01:00
Shigeki Ohtsu
0cca5391ba unix, windows: disallow NULL worker in thread pool
See #629.
2012-11-24 01:09:49 +01:00
Ben Noordhuis
d8a8379751 test: disable fs event test on dragonflybsd
Disable the fs_event_close_in_callback test on DragonFlyBSD, like we do on the
other BSDs.

The test doesn't work with kqueue-based file notifications, the event is
generated before the file is watched. Maybe we should remove it altogether.
2012-11-20 00:46:12 +01:00
Ben Noordhuis
190db15638 unix: set proper loop errno for udp write req cb
Harmonize with stream.c and tcp.c: when a handle is closed that has pending
writes queued up, run the callbacks with loop->err.code set to UV_ECANCELED,
not UV_EINTR.
2012-11-19 04:02:42 +01:00
Ben Noordhuis
59a2c63931 bench: remove dead and buggy code
Pipe accept benchmarks have never been implemented, remove the code path.

Said code path also contained a bug: it tried to bind to the same pipe that is
bound to a few lines down.
2012-11-16 02:24:23 +01:00
Ben Noordhuis
a28bc88708 bench: print benchmark name in async/async_pummel 2012-11-16 02:24:22 +01:00
Ben Noordhuis
c252bcb3f0 bench: fix loop starvation bug
Don't keep writing until the write queue fills up. On fast systems (mine), that
never happens - the data is sent out as fast as the benchmark generates it.
2012-11-15 01:02:07 +01:00
Ben Noordhuis
09b022232a bench: report proper benchmark name 2012-11-13 17:47:47 +01:00
Ben Noordhuis
b9c8d19637 bench: close timer handles before deleting loop
Fixes a segmentation fault / use-after-free.
2012-11-13 15:56:55 +01:00
Ben Noordhuis
3243e9ae67 test: fix (harmless) typo in function name 2012-11-12 18:17:13 +01:00
Ben Noordhuis
625340066e test: fix close of uninitialized handle
The test closes all handles after 1000 ms but the remote peer handle may not
have been initialized by then (very unlikely but not quite impossible).
2012-11-11 03:24:25 +01:00
Ben Noordhuis
0a7e36dcf1 test: add UV_RUN_AS_ROOT check 2012-11-11 03:24:22 +01:00
Ben Noordhuis
bef3ea4818 bench: squelch -Wstrict-aliasing warnings 2012-11-09 03:51:47 +01:00
Ben Noordhuis
2d1f17fecb test: work around valgrind bug 2012-11-09 01:57:58 +01:00
Ben Noordhuis
91faa3e688 test: fix compiler warning
Fix the following warning by not using a static variable:

  test/test-fs-poll.c:79: warning: ‘static’ is not at beginning of declaration
2012-11-07 16:20:18 +01:00
Ben Noordhuis
a320d46440 test: fix type casting style issue 2012-11-07 05:50:30 +01:00
Ben Noordhuis
2affa60e19 test: remove unnecessary #ifdef _WIN32
This is a back-port of commit 4d17337 from the master branch.
2012-11-06 00:35:39 +01:00
Ben Noordhuis
7759bd63cd test: remove unnecessary #ifdef _WIN32 2012-11-06 00:32:04 +01:00
Bert Belder
4c9e42d0e6 windows: un-break the build
It was broken in fb64948.
2012-11-05 22:13:38 +01:00
Bert Belder
6620e614ac windows: un-break the build
It was broken in 1d85815.
2012-11-05 22:11:22 +01:00
Charlie McConnell
fb64948746 unix: do not set environ unless one is provided
Currently, `uv_spawn` will set `environ` to the value of `options.env`, even if
`options.env` is `NULL`.  This results in child processes for whom `environ ==
NULL`, which can cause a variety of unexpected issues.

This is a back-port of commit 1d85815 from the master branch.
2012-11-03 01:41:10 +01:00
Charlie McConnell
1d858156b4 unix: do not set environ unless one is provided
Currently, `uv_spawn` will set `environ` to the value of `options.env`, even if
`options.env` is `NULL`.  This results in child processes for whom `environ ==
NULL`, which can cause a variety of unexpected issues.
2012-11-03 01:37:22 +01:00
Ben Noordhuis
dcce1eab3b test: fix -Wmissing-field-initializers warnings 2012-11-02 14:34:28 +01:00
Ben Noordhuis
894a8523cb test: fix signed/unsigned comparison warnings 2012-11-02 14:32:14 +01:00
Ben Noordhuis
b8aa5b9bf2 test: don't assert on UV_EPIPE in echo-server.c
UV_EPIPE is not an error per se, it simply indicates that the other end of the
connection - i.e. the test case - has gone away.

Pro-actively ignore UV_ECANCELED errors. They're not actually emitted right now
because there's only ever one pending write but let's be forward compatible.
2012-11-01 15:39:11 +01:00
Bert Belder
149b16f123 windows: closing handles should always keep the loop alive
This makes the tcp-ref2 and udp-ref2 tests pass again.
Also adds another reference count test.
2012-10-25 15:10:29 +02:00
Bert Belder
0dbab84529 benchmark: async_pummel should not call uv_async_send on closed handle
This fixes an assertion that triggered in debug builds on Windows.
2012-10-24 21:36:57 +02:00
Bert Belder
a54b9e2921 benchmark: timed_udp_pummel should not write to closed udp handle
This fixes intermittent assertion failures when running the benchmark.
2012-10-24 21:36:57 +02:00
saghul
61ecb3415d win: support compilation with Visual Studio 2008 2012-10-23 22:55:25 +02:00
Bert Belder
1e32cb01b5 unix: support signal handlers outside the main loop 2012-10-17 01:25:02 +02:00
Bert Belder
47eb03490a test: move loop cleanup code to the individual tests 2012-10-17 01:24:49 +02:00
Bert Belder
28eb619c65 windows: don't run signal tests
They are dummy tests on windows, running them is misleading.
Also remove duplicate 'test-signal.c' entry from uv.gyp.
2012-10-16 17:23:04 +02:00
Bert Belder
c5e1140779 tests: fix some compile warnings on windows 2012-10-16 17:22:54 +02:00
Hiroaki Nakamura
36b1e1a57c test: change 10e8 to 1e9
It is clearer and used everywhere else.
2012-10-16 00:07:46 +02:00
Bert Belder
4900912d44 windows: fix application crashed popup in debug version
This is a backport of 2 patches by Ting-Yu Lin and Hiroaki Nakamura.
2012-10-10 17:15:25 +02:00
Hiroaki Nakamura
acea3028c5 unix, windows: add thread barrier support 2012-10-09 17:30:52 +02:00
Hiroaki Nakamura
2684f876a9 windows: don't set CRT debug mode on MinGW 2012-10-09 17:00:02 +02:00
Shigeki Ohtsu
f7c991f1ce test: add consumer-producer test for condvar 2012-10-07 23:17:31 +02:00
Ting-Yu Lin
8f1ec32865 windows: fix application crashed popup in debug version 2012-10-07 15:43:03 +02:00
Hiroaki Nakamura
976c8a4387 Add support for condition variables on all platforms 2012-10-05 13:03:55 +02:00
Shigeki Ohtsu
01337af65d test, windows: fix duplicated windows.h
including windows.h before winsock2.h cause build error
2012-10-03 03:46:49 +02:00
Ben Noordhuis
d796c3b6f4 test: fix windows #include bug
Fixes a "'AF_IPX' : macro redefinition" warning when compiling test/runner.c.
2012-10-03 00:58:04 +02:00
Ben Noordhuis
b88f8b40d6 test: fix uninitialized memory warning, use calloc
Fixes the following valgrind warning:

  ==29019== Syscall param writev(vector[...]) points to uninitialised byte(s)
  ==29019==    at 0x584270B: writev (writev.c:51)
  ==29019==    by 0x449BB2: uv__write (stream.c:733)
  ==29019==    by 0x44AE91: uv_write2 (stream.c:1159)
  ==29019==    by 0x44AF25: uv_write (stream.c:1180)
  ==29019==    by 0x42CCAA: connect_cb (test-tcp-writealot.c:129)
  ==29019==    by 0x44AC05: uv__stream_connect (stream.c:1097)
  ==29019==    by 0x44AA25: uv__stream_io (stream.c:1050)
  ==29019==    by 0x437430: uv__io_rw (core.c:539)
  ==29019==    by 0x43C3D9: ev_invoke_pending (ev.c:2145)
  ==29019==    by 0x436EC5: uv__poll (core.c:260)
  ==29019==    by 0x436F0F: uv__run (core.c:269)
  ==29019==    by 0x436F6E: uv_run (core.c:277)
  ==29019==  Address 0x5f15040 is 0 bytes inside a block of size 94,371,840 alloc'd
  ==29019==    at 0x4C2C5EF: malloc (vg_replace_malloc.c:270)
  ==29019==    by 0x42CDED: run_test_tcp_writealot (test-tcp-writealot.c:148)
  ==29019==    by 0x406551: run_test_part (runner.c:302)
  ==29019==    by 0x405384: main (run-tests.c:57)
2012-10-03 00:23:38 +02:00
Ben Noordhuis
c6c691f323 test: join worker thread at exit in test-async.c 2012-10-02 23:54:19 +02:00
Ben Noordhuis
5135cfc45b test: fix memory leak in test-getsockname.c 2012-10-02 23:45:27 +02:00
Ben Noordhuis
f89986b153 test: fix memory leaks in test-fs-event.c 2012-10-02 23:19:53 +02:00
Ben Noordhuis
e474a2a420 test: fix memory leak in test-fs.c 2012-10-02 23:10:59 +02:00
Ben Noordhuis
8399cb1fc3 test: fix memory leaks in fs_symlink test 2012-10-01 23:54:34 +02:00
Ben Noordhuis
7320633c4b unix: remove uv_fs_stat windows compat hack
uv_fs_stat and uv_fs_lstat removed the trailing backslash (if any) from the path
in order to please a test case that was written for Windows. Remove the
compatibility hack and fix the test.
2012-10-01 22:53:59 +02:00
Ben Noordhuis
678e95a443 test: close handle in ref tests
Everything that gets reported by valgrind now is an actual memory leak.
2012-10-01 22:53:59 +02:00
Ben Noordhuis
45b5e79f8e test: fix memory leak in tcp_ping_pong 2012-10-01 22:53:59 +02:00
Ben Noordhuis
f090297f62 test: delete default loop after test run
Delete the default event loop after the test completes. Keeps valgrind happy.
2012-10-01 22:53:59 +02:00
Ben Noordhuis
4e268f7718 test: add valgrind support
Run tests through valgrind when UV_USE_VALGRIND=1 is set in the environment.
2012-10-01 22:53:59 +02:00
Ben Noordhuis
48f98424bd test: fix error message in runner 2012-10-01 22:53:59 +02:00
Ben Noordhuis
1923abda94 test: add uv_fs_readlink test 2012-10-01 22:53:59 +02:00
Fedor Indutny
778144f0b5 darwin: emit relative path in fsevents 2012-09-18 00:29:29 +02:00
Ben Noordhuis
37dc7472d7 test: fix aliasing warning in dns-server.c 2012-09-17 23:48:19 +02:00
Ben Noordhuis
29f44c7564 bench: let client close connection in tcp_multi_accept{2,4,8} 2012-09-17 23:22:04 +02:00
Ben Noordhuis
a8c6da8dfa bench: add idle delay to tcp_multi_accept{2,4,8} 2012-09-17 23:22:04 +02:00
Ben Noordhuis
b74b1c4c56 bench: add tcp accept benchmarks 2012-09-17 23:22:04 +02:00
Saúl Ibarra Corretgé
cc1c1912ca unix, windows: add uv_tcp_open and uv_udp_open 2012-09-17 18:09:51 +02:00
Andrew Paprocki
900ad30b43 aix: add initial platform support for aix using gcc/gxlc
Adds initial libuv build/platform support for AIX. Builds work using gcc or the
IBM XL C compiler using its gxlc wrapper. Platform support is added for
uv_hrtime, uv_exepath, uv_get_free_memory, uv_get_total_memory, uv_loadavg,
uv_uptime, uv_cpu_info, uv_interface_addresses.
2012-09-14 01:23:28 +02:00
Fedor Indutny
f8e7513a06 darwin: use FSEvents to watch directory changes 2012-09-12 23:38:57 +02:00
Shigeki Ohtsu
09faee40eb windows: fix environment_creation test
abc945bc04 fails environment_creation test
2012-08-29 04:31:25 +02:00
Bert Belder
621a4e36f7 test: add test for uv_is_active and uv_is_closing 2012-08-27 23:57:48 +02:00
Ben Noordhuis
c77d08eb92 bench: add timed and non-timed udp pummel benchmarks 2012-08-25 22:37:18 +02:00
Ben Noordhuis
28ff1422e8 Merge branch 'v0.8'
Conflicts:
	src/fs-poll.c
2012-08-20 18:11:43 +02:00
Ben Noordhuis
b5ad44d103 test: add uv_fs_poll_t to benchmark-sizes.c 2012-08-20 16:31:54 +02:00
Bert Belder
7c3ba514e7 windows: use WCHAR consistently 2012-08-13 22:31:48 +02:00
Bert Belder
aa69f34d53 windows: report spawn errors to the exit callback
Formerly spawn errors would be reported as a message printed to the
process' stderr, to match unix behaviour. Unix has now been fixed to
be more sensible, so this hack can now be removed.

This also fixes a race condition that could occur when the user closes
a process handle before the exit callback has been made.
2012-08-13 22:31:47 +02:00
Bert Belder
80eae82104 test: spawn failures are reported by setting the exit code to -1 2012-08-13 22:31:47 +02:00
Bert Belder
1b8307637b test: fix intermittent failure of tcp_unexpected_read on windows 2012-08-13 22:31:46 +02:00
Bert Belder
c85672eb13 test: avoid compiler complaints about implicit double-to-int cast 2012-08-13 22:31:45 +02:00
Bert Belder
762c85c3ef windows: un-break the build 2012-08-13 22:31:45 +02:00
Ben Noordhuis
837edf4c0f unix, windows: remove handle init counters
Remove the handle init counters, no one uses them.
2012-08-10 02:00:11 +02:00
Ben Noordhuis
ee50db6e36 unix, windows: preliminary signal handler support
* a no-op on Windows for now
* only supports the main loop on UNIX (again, for now)
2012-08-10 02:00:07 +02:00
Ben Noordhuis
13467a40d4 unix: retrieve execve() errors in process.c
Make the forked child process send the errno to its parent process when it
fails to spawn a new process.
2012-08-08 23:19:50 +02:00
Bert Belder
35c4858231 Remove c-ares tests and benchmarks 2012-08-07 01:03:51 +02:00
Bert Belder
32da23988b Merge branch 'v0.8'
Conflicts:
	src/unix/sunos.c
2012-08-05 23:51:04 +02:00
Bert Belder
1d5eb91474 Avoid compiler warning 2012-07-30 11:00:37 +02:00
Ben Noordhuis
be1032431d Merge branch 'v0.8' 2012-07-29 03:13:21 +02:00
Ben Noordhuis
ec76a42515 test: add uv_loop_t to benchmark-sizes.c 2012-07-28 14:56:36 +02:00
Ben Noordhuis
4fe369b179 test: add uv_fs_event_t to benchmark-sizes.c 2012-07-28 14:48:47 +02:00
Ben Noordhuis
b5b8ead808 test: add failing fs_event test
Watches the same file twice. Fails on Linux with a segmentation fault.
2012-07-28 14:40:03 +02:00
Ben Noordhuis
cf05c5f0d6 Raise UV_ECANCELED on premature close.
Set the error code to the more appropriate UV_ECANCELED instead of UV_EINTR
when the handle is closed and there are in-flight requests.
2012-07-27 15:13:29 +02:00
Ben Noordhuis
94355e4718 unix: fix format string vulnerability in freebsd.c
uv_set_process_title() was susceptible to a format string vulnerability:

  $ node -e 'process.title = Array(42).join("%s")'
  Segmentation fault: 11 (core dumped)

The fix is trivial - call setproctitle("%s", s) instead of setproctitle(s) -
but valgrind complains loudly about reads from and writes to uninitialized
memory in libc. It's not a libuv bug because the test case below triggers the
same warnings:

  #include <sys/types.h>
  #include <unistd.h>

  int main(void)
  {
    setproctitle("%s", "test");
    return 0;
  }

That's why this commit replaces setproctitle() with sysctl(KERN_PROC_ARGS).

This commit reapplies commit a9f6f06, which got reverted in 69a6afe. The revert
turned out to be unnecessary.
2012-07-19 16:26:54 +02:00
Ben Noordhuis
69a6afea63 unix: undo changes to uv_set_process_title()
It's making node.js crash when run as root. Backtrace:

  (gdb) bt
  #0  0x00007fff856e3ff9 in __findenv ()
  #1  0x00007fff856e404c in getenv ()
  #2  0x000000010004c850 in loop_init (loop=0x10045a792, flags=8) at ev.c:1707
  #3  0x000000010004cb3b in ev_backend [inlined] () at /Users/tjfontaine/Development/node/deps/uv/src/unix/ev/ev.c:2090
  #4  0x000000010004cb3b in ev_default_loop (flags=1606417108) at ev.c:2092
  #5  0x000000010004e5c6 in uv__loop_init (loop=0x10066e330, default_loop=1) at loop.c:52
  #6  0x0000000100044367 in uv_default_loop () at core.c:196
  #7  0x0000000100004625 in node::Init (argc=1606417456, argv=0x100b0f490) at node.cc:2761
  #8  0x000000010000797d in node::Start (argc=1606417600, argv=0x0) at node.cc:2888
  #9  0x0000000100000ca4 in start ()

This reverts commits:

  b49d6f7 unix: fix uv_set_process_title()
  a9f6f06 unix: fix format string vulnerability in freebsd.c
  a87abc7 unix: avoid buffer overflow in proctitle.c
  dc97d44 unix: move uv_set_process_title() to proctitle.c
2012-07-18 22:54:39 +02:00
Ben Noordhuis
a9f6f06fea unix: fix format string vulnerability in freebsd.c
uv_set_process_title() was susceptible to a format string vulnerability:

  $ node -e 'process.title = Array(42).join("%s")'
  Segmentation fault: 11 (core dumped)

The fix is trivial - call setproctitle("%s", s) instead of setproctitle(s) -
but valgrind complains loudly about reads from and writes to uninitialized
memory in libc. It's not a libuv bug because the test case below triggers the
same warnings:

  #include <stdio.h>
  #include <stdlib.h>
  #include <sys/types.h>
  #include <unistd.h>

  int main(void)
  {
    setproctitle("%s", "test");
    return 0;
  }

That's why this commit replaces setproctitle() with sysctl(KERN_PROC_ARGS).
2012-07-13 17:16:38 +02:00
Ben Noordhuis
ad382bcac0 test: add missing return statement 2012-07-09 18:46:57 +02:00
Ben Noordhuis
68b0c85c09 test: allow 80 ms intervals in hrtime test
The hrtimer functionality on my FreeBSD 9 system is fairly coarse, it's usually
just over the 60 ms that we tested for before this commit.
2012-07-03 22:33:10 +02:00
Ben Noordhuis
a2204abc8e bench: improve async_pummel benchmark
Benchmark the performance of uv_async_send() when the handle is contended for
by 1, 2, 4 or 8 threads.
2012-07-02 03:57:15 +02:00
Ben Noordhuis
1d1dd9bb7d test: add 'unexpected read' tcp test
Regression test that verifies that the event loop doesn't busy loop when
the server sends a message and the client isn't reading.
2012-06-30 03:25:52 +02:00
Bert Belder
7628b6597e test: fix test-gethostbyname to not use a DNS server on localhost
Because, you know, not everybody has one.
2012-06-29 05:44:20 +02:00
Bert Belder
e9b17bcc65 Revert "test: improve clean-up in test-fs-event"
There were too many errors in this commits; it totally broke on
Windows. Besides, when the moon is dark, the cleanup code could delete
some random files from my hard drive.

This reverts commit 7573f4a4c4.
2012-06-29 05:29:26 +02:00
Bert Belder
937d2c93ea test: fix test-gethostbyname to not use a DNS server on localhost
Because, you know, not everybody has one.
2012-06-29 05:28:26 +02:00
Ben Noordhuis
c89df5b990 bench: add another async handle benchmark 2012-06-29 03:16:06 +02:00
Ben Noordhuis
f90d428b29 test: fix unused function warning
exit_cb_unexpected() is only used on Windows.
2012-06-29 02:34:12 +02:00
Ben Noordhuis
13747033f8 test: remove unused function poll_cb_fail() 2012-06-29 02:34:09 +02:00
Ben Noordhuis
3b209e7642 bench: add async handle benchmark 2012-06-29 02:29:50 +02:00
Ben Noordhuis
123ca8b87e test: make fmt() function global 2012-06-29 02:29:21 +02:00
Charlie McConnell
f3fd8e3c1b test: prevent running the tests as root 2012-06-26 00:42:11 +02:00
Charlie McConnell
7573f4a4c4 test: improve clean-up in test-fs-event
Failed tests would leave behind extra files, and some tests weren't cleaning up
properly in the first place - this adds a cleanup_watch_dir() helper method to
make all the fs-event tests more consistent.
2012-06-26 00:42:07 +02:00
saghul
431d61af31 win: map ERROR_PRIVILEGE_NOT_HELD to UV_EPERM 2012-06-25 16:37:08 +02:00
Bert Belder
d169ba1a1b Make the stat benchmark run shorter
Man, Windows is so slow...
2012-06-22 01:16:52 +02:00
Ben Noordhuis
5dc024f676 bench: add thread pool I/O benchmark 2012-06-21 22:40:17 +02:00
Ben Noordhuis
14ffaa668d unix, windows: stat: never pass NULL to cb
Never pass NULL to the fs_poll callback, use a zeroed out statbuf instead.

Makes the interface a little more convenient to use.
2012-06-20 17:56:37 +02:00
Ben Noordhuis
6d67cf1952 unix, windows: update uv_fs_poll API
* the callback gets called only once on error, not repeatedly...

* ...unless the error reason changes from e.g. UV_ENOENT to UV_EACCES

* the callback receives pointers to uv_statbuf_t objects so it can inspect what
  changed
2012-06-16 04:54:25 +02:00
Ben Noordhuis
cc7c8542a5 unix, windows: add stat() based file watcher
Monitors a file path for changes. Supersedes ev_stat.
2012-05-31 20:32:24 +02:00
Bert Belder
9a3dff35c0 test: make the test-hrtime less likely to time out 2012-06-14 22:41:41 +02:00
Ben Noordhuis
0ae026dc84 bench: add lots-of-timers benchmark 2012-06-09 18:42:06 +02:00
Maciej Małecki
c92788e503 test: fix test runner progress bar
Make % completed indicator actually show % completed instead of 0 %.
2012-06-09 18:09:26 +02:00
Bert Belder
b5a15f5cdf test: fix test-tcp-shutdown-after-write bug
It was calling uv_read_start before the uv_connect call had completed.
Although we want to allow this in the future, right now it's not
supported.
2012-06-08 03:11:53 +02:00
Ben Noordhuis
59cda86709 unix, test: make NANOSEC a 64 bits unsigned int
Avoids accidental overflow / truncation when it's used in 32 bits arithmetic.
2012-06-07 17:00:01 +02:00
Shigeki Ohtsu
e2aa39aecf test: change uv_hrtime() test to iterate upto 100 2012-06-07 15:42:35 +02:00
Iñaki Baz Castillo
b47af98e00 test: add tcp 'close on failed connect' test
Demonstrates temporary event loop stall with uv-unix. The issue is that pending
requests aren't processed until the next event (I/O, timeout, etc.) happens.

See #446, #447 and #448.
2012-06-07 00:06:24 +02:00
Ben Noordhuis
7d2ea31618 unix: fix event loop stall
Stop libev from entering the epoll_wait/kevent/port_getn/etc. syscall when
there are no active handles left, that will block indefinitely.
2012-06-04 23:36:50 +02:00
Bert Belder
0dff0e7d47 test: avoid compiler warnings due to size_t truncation 2012-06-04 18:04:49 +02:00
Ben Noordhuis
d08070435d test: rename test tcp_dont_connect_after_write
Rename test tcp_dont_connect_after_write to tcp_connect_error_after_write,
teensy tad more descriptive.
2012-06-04 17:35:56 +02:00
Ben Noordhuis
76fa163117 test: add a 'write before connect' test 2012-06-04 17:12:20 +02:00
Ben Noordhuis
97801c6315 test: disable tcp_dont_connect_after_write on windows
For now. See #444.
2012-06-04 16:07:50 +02:00
Ben Noordhuis
b96ed68f46 test: add TCP connect error + write test
Original test contributed by Iñaki Baz Castillo. See #443.
2012-06-04 15:58:32 +02:00
Ben Noordhuis
c76c2066c6 unix, windows: add semaphore functions 2012-06-03 04:04:05 +02:00
Ben Noordhuis
28ed730bfb test: fix implicit function declaration warnings
Fixes the two following compiler warnings:

  ../test/run-tests.c: In function ‘maybe_run_test’:
  ../test/run-tests.c:117: warning: implicit declaration of function ‘write’
  ../test/run-tests.c:118: warning: implicit declaration of function ‘fsync’
2012-06-03 01:17:24 +02:00
Fedor Indutny
1cd9642cbb test: stdin/out/err should be set to /dev/null when ignored 2012-06-02 21:38:39 +02:00
Bert Belder
4a07b8b7bd test-poll: make spurious wakeup detection slightly less strict 2012-06-02 21:12:10 +02:00
Bert Belder
38a6f9f0d9 test: fix windows-ism in test-poll-close.c 2012-06-01 18:53:11 +02:00
Bert Belder
9759c20e90 test: verify that closing an active poll handle doesn't hang 2012-06-01 18:39:47 +02:00
Bert Belder
87dbffbd8f windows: fix undefined function warning in run-tests.c 2012-06-01 17:49:29 +02:00
Fedor Indutny
dc7a62d114 test: test for uv_spawn with stdio_count == 3 2012-06-01 17:32:34 +02:00
Fedor Indutny
f5b5127db0 change spawn() api to allow using existing streams for stdio
This commit also adds support for this api on Unix.
2012-06-01 17:32:27 +02:00
Bert Belder
04a7e5c274 test-spawn.c: remove unused variable 2012-06-01 02:26:25 +02:00
Charlie McConnell
69a923bf93 process: implement UV_PROCESS_DETACHED flag for uv_spawn 2012-06-01 02:24:05 +02:00
Ben Noordhuis
3f37ba859f bench: add new idle loop count benchmark 2012-05-31 02:46:18 +02:00
Ben Noordhuis
171ad8567d unix, windows: add uv_walk()
Lets the libuv user iterate over the open handles. Mostly intended as a
debugging tool or a post-hoc cleanup mechanism.
2012-05-30 02:33:39 +02:00
Ben Noordhuis
12ee388cd9 test: clean up test-loop-handles.c 2012-05-29 17:35:30 +02:00
Ben Noordhuis
ec0c7b8958 test: fix double close in test-loop-handles.c 2012-05-29 17:35:30 +02:00
Fedor Indutny
c0081f0e66 unix: allow specifying FDs to be inherited by a child process
Previously the only option was to create a pipe or an ipc channel. This
patch makes it possible to inherit a handle that is already open in the
parent process. It also makes it possible to set more than just stdin,
stdout and stderr.
2012-05-29 00:05:12 +02:00
Igor Zinkovsky
5a34f19970 windows: allow specifying FDs to be inherited by a child process
Previously the only option was to create a pipe or an ipc channel. This
patch makes it possible to inherit a handle that is already open in the
parent process. There is also room for setting more than just stdin,
stdout and stderr, although this is not supported yet.
2012-05-28 23:59:58 +02:00
Ben Noordhuis
028fef84b8 unix: update timer if already active
uv_timer_start() no longer returns an error when the timer is already active,
now it just updates the timer. Consistent with the uv-win implementation.

Fixes #425.
2012-05-26 02:09:59 +02:00
Ben Noordhuis
ae9d4c2aab test: add 'is active?' checks to test-timer.c 2012-05-26 01:57:49 +02:00
Ben Noordhuis
34445d0741 test: remove stale UNIX socket before running test
Fixes spurious test and benchmark failures.
2012-05-26 01:42:40 +02:00
Ben Noordhuis
28766dcf55 test: remove test-eio-overflow.c
Unreliable, it's timing / system load sensitive.
2012-05-25 01:33:44 +02:00
Ben Noordhuis
890d443558 unix: shave about 100 bytes off uv_udp_send_t 2012-05-23 23:21:08 +02:00
Ben Noordhuis
b69f8efee1 test: remove stale socket in ipc_send_recv_pipe
Fixes spurious test failures.
2012-05-23 21:18:40 +02:00
Ben Noordhuis
cd2a9b4d59 bench: measure ticks per second of idle event loop 2012-05-23 21:05:43 +02:00
Ben Noordhuis
7c8313bd0f unix, windows: make uv_run_once() return a bool
The return value of uv_run_once() now signals if it needs to be called again.

Fixes #427.
2012-05-23 20:49:03 +02:00