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>
If CreateFileW succeeds, but _open_osfhandle fails, the handle must be closed.
PR-URL: https://github.com/libuv/libuv/pull/278
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Several windows .c files are including malloc.h unnecessarily.
This commit removes #includes that should have been removed
when we switched over to uv__malloc and uv__free (in commit
c272f1f1bc).
PR-URL: https://github.com/libuv/libuv/pull/270
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Previously to build successfully for iOS, you needed to specify OS=mac
at gyp time. This treats ios and mac as exactly the same.
PR-URL: https://github.com/libuv/libuv/pull/262
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
In the code path for pipe blocking writes, WriteFile is already
posting a completion packet to the I/O completion port.
POST_COMPLETION_FOR_REQ was causing the same request to get
returned twice by GetCompletionStatusEx.
Also on the same code path, we were waiting on the wrong event.
PR-URL: https://github.com/libuv/libuv/pull/238
Reviewed-By: Bert Belder <bertbelder@gmail.com>
uv_tty_reset_mode() is designed to be async signal-safe and is therefore
not allowed to clobber errno.
PR-URL: https://github.com/libuv/libuv/pull/259
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The UV_TTY_MODE_* enumeration values were introduced in commit 025602d
("tty: implement binary I/O terminal mode") but the test was not updated
to use them. This commit rectifies that.
PR-URL: https://github.com/libuv/libuv/pull/259
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
On Solaris and derivatives such as SmartOS, the length of socket options
for multicast and ttl options is not always sizeof(char).
This fixes the udp_options and udp_options6 tests.
PR-URL: https://github.com/libuv/libuv/pull/243
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Apple's `fd_set` stores its bits in an array of 32-bit integers, which
means `FD_ISSET()` may read out of bounds if we allocate storage at
byte granularity. There's also a chance that the `select()` call could
corrupt the heap, although I didn't investigate that.
This issue was discovered by LLVM's AddressSanitizer which caught
`FD_ISSET()` trying to read out of bounds.
PR-URL: https://github.com/libuv/libuv/pull/241
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
With uv_replace_allocator, it's possible to override the default
memory allocator's malloc and free calls with functions of the user's
choosing. This allows libuv to interoperate with projects requiring a
custom memory allocator.
Internally, all calls to malloc and free have been replaced with
uv__malloc and uv__free, respectively. The uv__malloc and uv__free
functions call malloc and free unless they have been overridden by a
previous call to uv_replace_allocator.
As part of this change, the special aligned memory allocations
performed in src/win/fs-event.c have been replaced with standard
allocations. The 4-byte alignment being requested in this file was
unnecessary, since standard allocators already guarantee at least an
8-byte alignment.
PR-URL: https://github.com/libuv/libuv/pull/231
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Work around a bug in kernels 3.10 to 3.19 where passing a struct that
has the EPOLLWAKEUP flag set generates spurious syslog audit warnings.
A bad check makes the kernel read the events field when it should not
and complain when the process lacks the CAP_BLOCK_SUSPEND capability.
PR-URL: https://github.com/libuv/libuv/pull/245
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
All the public structs and unions in the private fields in uv-win.h have
been named and all code accessing them updated, to comply to the C89
spec (which were previously causing warnings with the -pedantic flag).
PR-URL: https://github.com/libuv/libuv/pull/239
Reviewed-By: Andrius Bentkus <andrius.bentkus@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
In debugging test-tls-ocsp-callback.js for the 0.12.0 Node on
AIX we discovered that there was code missing in
uv__platform_invalidate_fd() in aix.c which removes the file
descriptor from the pollset when needed. We based the
impelementation in aix.c on the unix version in linux-core.cc.
We can see that this issue was addressed for linux in commit
780d8ad.
PR-URL: https://github.com/libuv/libuv/pull/221
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Calling `setsockopt()` on shutdown fds/stdio will result in EINVAL.
There is not much problem here as the OOB data can't be sent to already
shutdown fds. Just ignore it and go on.
PR-URL: https://github.com/libuv/libuv/pull/228
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
In the collaboration with Ben Noordhuis <info@bnoordhuis.nl> and
Saúl Ibarra Corretgé <saghul@gmail.com>.
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
There's a data race in the consuming side of uv_async. The "pending"
flag could be trampled by producing thread causing an async send
event to be missed.
PR-URL: https://github.com/libuv/libuv/pull/189
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
On Solaris derivatives, cfmakeraw is not available. Instead, set the
termios flags manually. The set of flags to use so that the behavior of
the terminal is similar to what it is after a call to cfmakeraw was
taken from
http://www.perkin.org.uk/posts/solaris-portability-cfmakeraw.html.
PR-URL: https://github.com/libuv/libuv/pull/210
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Before this commit, UNIX returned -1 on failure. Windows sometimes
returned a UV_E* error code and sometimes a bogus status code, courtesy
of errno values not mapping to UV_E* error codes on that platform.
PR-URL: https://github.com/libuv/libuv/pull/204
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
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>
The reported bug is arguably a compiler bug - a non-static inline
function should be inlined inside the compilation unit but still
have external linkage - but the abundant use of 'inline' isn't
really necessary in the first place. Remove it.
Fixes: https://github.com/libuv/libuv/issues/191
PR-URL: https://github.com/libuv/libuv/pull/194
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Changes since version 1.3.0:
* unix: check Android support for pthread_cond_timedwait_monotonic_np
(Leith Bade)
* test: use modified path in test (cjihrig)
* unix: implement uv_stream_set_blocking() (Ben Noordhuis)
Commit 393c1c5 ("unix: set non-block mode in uv_{pipe,tcp,udp}_open")
causes a regression in the io.js cluster module.
The io.js documentation states that `worker.send()` and `process.send()`
are synchronous but they no longer were after upgrading to libuv v1.2.1.
The reason they are synchronous is because of backpressure - or rather,
lack of backpressure: a slow consumer eventually causes a fast producer
to run out of memory because the backlog of pending messages in the
producer can grow unchecked.
Ergo, implement uv_stream_set_blocking() on UNIX platforms to let io.js
enable the old blocking behavior for pipes again.
Refs: https://github.com/iojs/io.js/issues/760
PR-URL: https://github.com/libuv/libuv/pull/187
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The Windows spawn_with_an_odd_path test builds a PATH variable that
starts with ";.;". However, the old path is then used to run the test.
This commit updates the test to use the new path.
PR: https://github.com/libuv/libuv/pull/184
Reviewed-by: Bert Belder <bertbelder@gmail.com>
Since API level 21 (Android 5.0) the non-standard pthread function
pthread_cond_timedwait_monotonic_np has been removed in favour of
the standard pthread_cond_timedwait which libuv normally uses on
Linux.
This commit changes the detection of the Android OS to account for
the removal of the function via the #define
HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC which is only present in older
API levels.
Fixes: https://github.com/libuv/libuv/issues/172
PR-URL: https://github.com/libuv/libuv/pull/176
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>