* add a very simple Makefile.mingw that builds libuv.a
* apply a couple of fixes to src/win so it actually builds with mingw
(mostly missing includes)
Fixes#847.
Make it possible for the libuv user to handle out of memory conditions
gracefully. When alloc_cb() returns a buffer with len==0, call the read
or recv callback with nread=UV_ENOBUFS. It's up to the user to stop or
close the handle.
Fixes#752.
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.
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.
Changes since version 0.11.4:
* build: remove CSTDFLAG, use only CFLAGS (Ben Noordhuis)
* unix: support for android builds (Linus Mårtensson)
* unix: avoid extra read, short-circuit on POLLHUP (Ben Noordhuis)
* uv: support android libuv standalone build (Linus Mårtensson)
* src: make queue.h c++ compatible (Ben Noordhuis)
* unix: s/ngx-queue.h/queue.h/ in checksparse.sh (Ben Noordhuis)
* unix: unconditionally stop handle on close (Ben Noordhuis)
* freebsd: don't enable dtrace if it's not available (Brian White)
* build: make HAVE_DTRACE=0 should disable dtrace (Timothy J. Fontaine)
* unix: remove overzealous assert (Ben Noordhuis)
* unix: remove unused function uv_fatal_error() (Ben Noordhuis)
* unix, windows: clean up uv_thread_create() (Ben Noordhuis)
* queue: fix pointer truncation on LLP64 platforms (Bert Belder)
* build: set OS=="android" for android builds (Linus Mårtensson)
* windows: don't use uppercase in include filename (Ben Noordhuis)
* stream: add an API to make streams do blocking writes (Henry Rawas)
* windows: use WSAGetLastError(), not errno (Ben Noordhuis)
This patch adds the `uv_stream_set_blocking` API which makes all
uv_write calls to that stream blocking. It currently only works for
pipes, on windows.
This fixes an issue where uv_spawn would not try to run a reparse point,
and continue to scan the PATH instead. Effectively, it was impossible to
spawn a symlinked binary. This commit fixes that.
Also see #748
QUEUE_DATA used to cast a pointer to long and back to pointer. This can
corrupt pointers on systems where the long type isn't large enough to
store pointer, like Windows x64. This commit fixes that.
Fixes#835
Changes since version 0.10.10:
* unix: unconditionally stop handle on close (Ben Noordhuis)
* freebsd: don't enable dtrace if it's not available (Brian White)
* build: make HAVE_DTRACE=0 should disable dtrace (Timothy J. Fontaine)
* unix: remove overzealous assert (Ben Noordhuis)
* unix: clear UV_STREAM_SHUTTING after shutdown() (Ben Noordhuis)
* unix: fix busy loop, write if POLLERR or POLLHUP (Ben Noordhuis)
This fixes a busy loop by working around a quirk with Linux kernels
<= 2.6.32 where an EPIPE or ECONNRESET error on a file descriptor that
is polled for EPOLLOUT but not EPOLLIN gets reported by epoll_wait() as
just EPOLLERR|EPOLLHUP, like this:
epoll_wait(5, {{EPOLLERR|EPOLLHUP, {u32=12, u64=12}}}, 1024, 433) = 1
Before this commit, libuv called uv__read() which attempts to read from
the file descriptor. With newer kernels and on other operating systems
that fails like this:
read(12, "", 65536) = -1 EPIPE (Broken pipe)
Which tells libuv there is a connection error and it should notify the
user of that. On the affected Linux kernels however, the read succeeds
with an EOF:
read(12, "", 65536) = 0
Which is subsequently passed on to the user. In most cases, the user
will close the handle and everything is fine.
Node.js however sometimes keeps the handle open in an attempt to flush
pending write requests. While libuv doesn't officially support this,
unofficially it works...
...except on those older kernels. Because the kernel keeps waking up
the event loop without setting POLLOUT and because the read calls EOF
but don't error, libuv's I/O state machine doesn't progress.
That's why this commit changes uv__stream_io() to also write pending
data. While the read() system call doesn't error, the write() system
call will.
Fixesjoyent/node#5504.
Several node.js users are hitting this assert under what appear to be
mostly benign conditions. In other words, it's unclear whether it's
catching real bugs or just has wrong expectations.
An aborting process is rather disruptive so I'm removing the assert
from the stable branch and relanding it in the master branch.
Make sure the handle is fully stopped by the time uv__stream_close()
calls uv_read_stop(). Fixes the following assertion:
Assertion failed: (!uv__io_active(&stream->io_watcher, UV__POLLOUT)
|| !ngx_queue_empty(&stream->write_completed_queue)
|| !ngx_queue_empty(&stream->write_queue)
|| stream->shutdown_req != NULL
|| stream->connect_req != NULL), function uv_read_stop,
file ../deps/uv/src/unix/stream.c, line 1329.
Fixesjoyent/node#5622.
Tested most of my compilation in the previous patch on NodeJS
and extracted the patches from there. This patch ensures libuv
will be capable of building standalone as well, both with gyp
and Makefiles.
Build documentation was added to the README.md file.
Some tests are failing, and I have not heavily investigated
the reasons. The failures are generally on errors, and are
likely related to differences between fully POSIX-compatible
systems and android.
The darwin sendfile implementation uses the &len parameter as input
and output. The code was sending 0 (not using the value of req->len)
so the behavior wasn't what the caller was expecting.
This makes sure to initialize len with req->len to ensure that the
caller can send portions of a file (not always everything to the
end of the file).
The node.js test suite sometimes hits the assert that was added in
commit 4146805 that checks if there are connect, write or shutdown
requests pending when the user calls uv_read_stop() while the stream
is primed for writing.
The libuv user (i.e. node.js) is supposed to close the stream on error.
Because uv__stream_close() calls uv_read_stop(), it's possible that the
POLLOUT watcher is still active.
Changes since version 0.11.3:
* windows: make uv_spawn not fail when the libuv embedding application
is run under external job control (Bert Belder)
* darwin: assume CFRunLoopStop() isn't thread-safe, fixing a race
condition when stopping the 'stdin select hack' thread (Fedor Indutny)
* win: fix UV_EALREADY not being reported correctly to the libuv user in
some cases (Bert Belder)
* darwin: make the uv__cf_loop_runner and uv__cf_loop_cb functions
static (Ben Noordhuis)
* darwin: task_info() cannot fail (Ben Noordhuis)
* unix: add error mapping for ENETDOWN (Ben Noordhuis)
* unix: implicitly signal write errors to the libuv user (Ben Noordhuis)
* unix: fix assertion error on signal pipe overflow (Bert Belder)
* unix: turn off POLLOUT after stream connect (Ben Noordhuis)
* unix: fix stream refcounting buglet (Ben Noordhuis)
* unix: remove assert statements that are no longer correct (Ben
Noordhuis)
* unix: appease warning about non-standard `inline` (Sean Silva)
* unix: add uv__is_closing() macro (Ben Noordhuis)
* unix: stop stream POLLOUT watcher on write error (Ben Noordhuis)
* include: document uv_update_time() and uv_now() (Ben Noordhuis)
* linux: fix cpu model parsing on newer arm kernels (Ben Noordhuis)
* linux: fix a memory leak in uv_cpu_info() error path (Ben Noordhuis)
* linux: don't ignore out-of-memory errors in uv_cpu_info() (Ben
Noordhuis)
* unix, windows: move uv_now() to uv-common.c (Ben Noordhuis)
* test: fix a compilation problem in test-osx-select.c that was caused
by the use of c-style comments (Bert Belder)
* darwin: use uv_fs_sendfile() use the sendfile api correctly (Wynn
Wilkes)
* windows: call idle handles on every loop iteration, something the unix
implementation already did (Bert Belder)
* test: update the idle-starvation test to verify that idle handles are
called in every loop iteration (Bert Belder)
* unix, windows: ensure that uv_run() in RUN_ONCE mode calls timers that
expire after blocking (Ben Noordhuis)
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.