Commit Graph

2245 Commits

Author SHA1 Message Date
Ben Noordhuis
88a2c7ff20 build: all now builds static and dynamic lib
The `make all` target now builds both libuv.a and libuv.{so,dylib}
rather than just libuv.a.
2013-06-26 10:32:18 +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
a0bc4cca74 build: darwin: disable -fstrict-aliasing warnings
gcc 4.2.1 as shipped with Xcode complains incessantly about aliasing
warnings, which, while technically true, disregards the fact that the
aliased types have the same layout in memory. Squelch the warnings.
2013-06-26 13:13:53 +02:00
Ben Noordhuis
c8c775bd97 windows: use WSAGetLastError(), not errno
setsockopt() doesn't touch errno on failure. Use WSAGetLastError()
instead.

This is a back-port of commit 30a8b44 from the master branch.
2013-06-26 01:09:18 +02:00
Bert Belder
495d1a09fb windows: uv_spawn shouldn't reject reparse points
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
2013-06-19 00:15:20 +02:00
Ben Noordhuis
6607e70253 test: open stdout fd in write-only mode
Fixes #771.
2013-06-18 23:53:03 +02:00
Andrei Sedoi
5096f1e096 linux: add support for MIPS 2013-06-13 09:04:15 +02:00
Ben Noordhuis
72e440d7e1 Now working on v0.10.12 2013-06-12 21:52:05 +02:00
Ben Noordhuis
c3b75406a6 2013.06.13, Version 0.10.11 (Stable)
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)
2013-06-12 21:52:01 +02:00
Ben Noordhuis
12210fe578 unix: fix busy loop, write if POLLERR or POLLHUP
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.

Fixes joyent/node#5504.
2013-06-08 04:09:42 +02:00
Ben Noordhuis
536c5f8661 unix: clear UV_STREAM_SHUTTING after shutdown()
Fix a state machine buglet where the UV_STREAM_SHUTTING flag didn't get
cleared.
2013-06-08 03:14:33 +02:00
Ben Noordhuis
3ab354367b unix: remove overzealous assert
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.
2013-06-07 11:28:32 +02:00
Timothy J Fontaine
f84becc64e build: make HAVE_DTRACE=0 should disable dtrace 2013-06-06 20:32:52 +02:00
Brian White
c8ffee3460 freebsd: don't enable dtrace if it's not available 2013-06-05 22:50:08 +02:00
Ben Noordhuis
8e4b248ca6 unix: unconditionally stop handle on close
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.

Fixes joyent/node#5622.
2013-06-05 15:17:01 +02:00
isaacs
e9ae62d13a Now working on v0.10.11 2013-06-04 12:00:31 -07:00
isaacs
0d95a88bd3 2013.06.05, Version 0.10.10 (Stable)
Changes since version 0.10.9:

* include: document uv_update_time() and uv_now() (Ben Noordhuis)

* linux: fix cpu model parsing on newer arm kernels (Ben Noordhuis)

* linux: fix memory leak in uv_cpu_info() error path (Ben Noordhuis)

* linux: don't ignore OOM errors in uv_cpu_info() (Ben Noordhuis)

* unix, windows: move uv_now() to uv-common.c (Ben Noordhuis)

* darwin: make uv_fs_sendfile() respect length param (Wynn Wilkes)
2013-06-04 12:00:29 -07:00
Bert Belder
b9eb402fb0 include: remove lame comment from uv.h 2013-05-30 22:54:44 +02:00
Wynn Wilkes
b4c658c3c0 darwin: make uv_fs_sendfile() respect length param
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).
2013-05-29 22:25:43 +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
e0bdb3dbc9 unix, windows: move uv_now() to uv-common.c 2013-05-29 16:13:34 +02:00
Ben Noordhuis
b93cf8b594 linux: don't ignore OOM errors in uv_cpu_info() 2013-05-29 01:43:05 +02:00
Ben Noordhuis
31282a97e7 linux: fix memory leak in uv_cpu_info() error path
Any memory allocated to hold CPU model strings wasn't freed on error.
2013-05-29 01:43:05 +02:00
Ben Noordhuis
92c72f58bf linux: fix cpu model parsing on newer arm kernels
The format of /proc/cpuinfo on ARM kernels >= 3.8 has changed. Scan for
the string "model name" (like x86) first, "Processor" second.

Fixes #812.
2013-05-29 01:40:09 +02:00
Ben Noordhuis
dfff2e9e23 include: document uv_update_time() and uv_now() 2013-05-28 23:49:09 +02:00
isaacs
21c12b824a Now working on v0.10.10 2013-05-28 12:08:49 -07:00
isaacs
a195f9ace2 2013.05.29, Version 0.10.9 (Stable)
Changes since version 0.10.8:

* unix: fix stream refcounting buglet (Ben Noordhuis)

* unix: remove erroneous asserts (Ben Noordhuis)

* unix: add uv__is_closing() macro (Ben Noordhuis)

* unix: stop stream POLLOUT watcher on write error (Ben Noordhuis)
2013-05-28 12:08:46 -07:00
Ben Noordhuis
b329d51ef4 unix: stop stream POLLOUT watcher on write error
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.
2013-05-27 00:28:37 +02:00
Ben Noordhuis
8e16f8e056 unix: add uv__is_closing() macro 2013-05-26 23:02:17 +02:00
Ben Noordhuis
b38c9c1004 unix: remove erroneous asserts
As of commit c53fe81, it's legal for write_queue_size > 0 when the
write_queue itself is empty. Sounds illogical but it means there are
error-state write requests in the write_completed_queue that will touch
up the write_queue_size on the next tick of the event loop.

Remove a few stray asserts that still checked for the old situation.
2013-05-25 02:36:58 +02:00
Ben Noordhuis
636a13b8c4 unix: fix stream refcounting buglet
Fix a buglet where uv_read_stop() would mark the handle as stopped even
when there are in-progress write requests.

This bug is unlikely to have affected anyone, the only case where it
has a user-visible effect is when:

  a) the handle has been stopped for reading but not writing, and
  b) it's the last active handle in the event loop's pollset

If both conditions are met, it's possible for the event loop to
terminate prematurely.

This reapplies commit 80f2f82 which was temporarily reverted in fe7b154
because it was making a lot of node.js tests fail on OS X with the
following assertion:

    Assertion failed: (!uv__is_active(handle)), function
    uv__finish_close, file ../../deps/uv/src/unix/core.c, line 165.

Expecting that the handle is inactive when the state is UV_CLOSING
turns out to be a bad assumption: it's possible that the handle is
executing (for example) a shutdown request when uv__finish_close()
is called. That's okay, uv__stream_destroy() takes care of that.

The issue wasn't specific to OS X, it was just more visible on that
platform. (Slow) debug builds on Linux exhibited the same behavior.
2013-05-25 01:30:05 +02:00
isaacs
7d5024e7e6 Now working on v0.10.9 2013-05-24 14:37:56 -07:00
isaacs
0f39be1292 2013.05.25, Version 0.10.8 (Stable)
Changes since version 0.10.7:

* windows: make uv_spawn not fail under job control (Bert Belder)

* darwin: assume CFRunLoopStop() isn't thread-safe (Fedor Indutny)

* win: fix UV_EALREADY incorrectly set (Bert Belder)

* darwin: make two uv__cf_*() functions static (Ben Noordhuis)

* darwin: task_info() cannot fail (Ben Noordhuis)

* unix: add mapping for ENETDOWN (Ben Noordhuis)

* unix: implicitly signal write errors to libuv user (Ben Noordhuis)

* unix: fix assert on signal pipe overflow (Bert Belder)

* unix: turn off POLLOUT after stream connect (Ben Noordhuis)
2013-05-24 14:37:53 -07:00
Ben Noordhuis
fe7b154476 Revert "unix: fix stream refcounting buglet"
This change is making 45 out of 527 node.js tests fail on OS X with the
following assertion:

    Assertion failed: (!uv__is_active(handle)), function
    uv__finish_close, file ../../deps/uv/src/unix/core.c, line 165.

It's likely a manifestation of a bug elsewhere but, because there's a
new node.js release going out tonight, I'm reverting it for now.

This reverts commit 80f2f826bf.

Conflicts:
	src/unix/stream.c
2013-05-24 21:23:41 +02:00
Ben Noordhuis
4146805074 unix: turn off POLLOUT after stream connect
Clear the POLLOUT flag after we're done connecting. Not doing so isn't
really harmful but it may cause the event loop to wake up more often
than it has to.
2013-05-24 20:35:42 +02:00
Ben Noordhuis
80f2f826bf unix: fix stream refcounting buglet
Fix a buglet where uv_read_stop() would mark the handle as stopped even
when there are in-progress write requests.

This bug is unlikely to have affected anyone, the only case where it
has a user-visible effect is when:

  a) the handle has been stopped for reading but not writing, and
  b) it's the last active handle in the event loop's pollset

If both conditions are met, it's possible for the event loop to
terminate prematurely.
2013-05-23 07:33:12 +02:00
Bert Belder
c5d570ddba unix: fix assert on signal pipe overflow
An incorrect assert() statement was causing libuv to crash when writing
to an internal signal pipe would result in EAGAIN/EWOULDBLOCK.

This commit doesn't solve the underlying issue that the signal pipe can
overflow.

This should fix joyent/node#5538
2013-05-23 14:44:45 +02:00
Ben Noordhuis
c53fe81544 unix: implicitly signal write errors to libuv user
Fix an infinite loop in the example below when the stream encounters
an EPIPE/ECONNRESET/etc. error:

    // keep writing until we start buffering
    while (stream->write_queue_size == 0) {
      uv_write_t* req = make_write_req();
      uv_buf_t buf = uv_buf_init("PING", 4);
      uv_write(req, stream, &buf, 1, write_cb);
    }

uv_write() does not return an error code on write errors, the error is
only reported to the callback.

Before this commit, uv_write() left stream->write_queue_size untouched
on error, meaning the caller had no way to find out about that error
until the next tick of the event loop - which in the example above
leads to an infinite loop because that next tick is indefinitely
postponed.

This commit works around that at the cost of some added internal
complexity.

Fixes joyent/node#5516.
2013-05-22 17:00:17 +02:00
Ben Noordhuis
739a5b25b5 unix: add mapping for ENETDOWN 2013-05-20 20:05:33 +02:00
Ben Noordhuis
a1cb52a3eb darwin: task_info() cannot fail
And if it does: assert, don't return errno. It's a mach function, it
doesn't set errno.
2013-05-20 14:36:50 +02:00
Ben Noordhuis
e515d71592 darwin: make two uv__cf_*() functions static 2013-05-19 19:53:24 +02:00
Bert Belder
db7dc6899d win: fix UV_EALREADY incorrectly set
UV_EALREADY itself is already a libuv error, it should be set with
uv__set_artifical_error and not with uv__set_sys_error.

Closes #802
2013-05-18 20:45:36 +02:00
Fedor Indutny
d5fa633ef2 darwin: assume CFRunLoopStop() isn't thread-safe
Use signaling mechanism for loop termination, because CFRunLoopStop() is
most likely not a thread-safe function and invoking it from other thread
may sometimes result in a "dead-lock".

fix #799
2013-05-17 20:31:39 +04:00
Bert Belder
4f61ab2058 windows: make uv_spawn not fail under job control
* Fix a potential issue introduced with 415f4d3, namely that uv_spawn
  can fail when the current process is under job control. This would
  happen on Windows versions that don't support nested jobs (versions
  prior to Windows 8 / Server 2012).

* Change the `uv__init_global_job_handle` function signature to match
  what `uv_once` expects.

* Add a bunch of comments that clarify how we're using job control,
  and how we're dealing with job control that might be established by
  our parent process.
2013-05-16 21:29:40 +02:00
Bert Belder
13496e9c1a Now working on v0.10.8 2013-05-14 16:50:22 -07:00
Bert Belder
028baaf084 2013.05.15, Version 0.10.7 (Stable)
Changes since version 0.10.6:

* windows: kill child processes when the parent dies (Bert Belder)
2013-05-14 16:50:19 -07:00
Bert Belder
415f4d3e4c windows: kill child processes when the parent dies
This makes Windows behave just like Unix. This does not affect
processes that are spawned with the UV_PROCESS_DETACHED flag set.
2013-05-14 16:48:03 -07:00
isaacs
1fd10deec4 Now working on v0.10.7 2013-05-14 14:40:01 -07:00
isaacs
11e6613e62 2013.05.15, Version 0.10.6 (Stable)
Changes since version 0.10.5:

* stream: fix osx select hack (Fedor Indutny)

* stream: fix small nit in select hack, add test (Fedor Indutny)

* build: link with libkvm on openbsd (Ben Noordhuis)

* stream: use harder sync restrictions for osx-hack (Fedor Indutny)

* unix: fix EMFILE error handling (Ben Noordhuis)

* darwin: fix unnecessary include headers (Daisuke Murase)

* darwin: rename darwin-getproctitle.m (Ben Noordhuis)

* build: convert predefined $PLATFORM to lower case (Elliot Saba)

* build: set soname in shared library (Ben Noordhuis)

* build: make `make test` link against .a again (Ben Noordhuis)

* darwin: fix ios build, don't require ApplicationServices (Ben
  Noordhuis)

* build: only set soname on shared object builds (Timothy J. Fontaine)
2013-05-14 14:39:58 -07:00