Commit Graph

1606 Commits

Author SHA1 Message Date
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
Ben Noordhuis
f17c535b73 unix: use a heap for timers
Replace the red-black tree with a heap.  The most common operation that
libuv performs on timers is looking up the first timer to expire.  With
a red-black tree, that operation is O(log n).  With a heap, it's O(1).
2014-02-19 13:36:14 +01:00
Fedor Indutny
fc40836f9a Merge branch 'v0.10'
Conflicts:
	src/unix/sunos.c
2014-02-19 00:18:25 +04:00
Fedor Indutny
703a9e601e sunos: handle rearm errors
fix #1078
2014-02-19 00:14:13 +04:00
Bert Belder
d9872ae2ad Merge branch 'v0.10'
Conflicts:
	build.mk
	test/test-shutdown-twice.c
2014-02-18 19:19:52 +01:00
Alexis Campailla
4f913b669a windows: freeze in uv_tcp_endgame
The event_handle field of unused accept requests was not being
initialized properly. As a result, uv_tcp_endgame would try to close
an invalid handle and this could lead to unexpected behavior.

This fixes node.js test test-cluster-disconnect.js on Windows.
2014-02-18 19:16:47 +01: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
Saúl Ibarra Corretgé
d7c8cffecb windows: fixed compilation warning 2014-02-18 11:35:01 +01: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é
d4c12adff6 include: expose libuv version in header files 2014-02-17 20:53:20 +01:00
Alex Crichton
6f62d62c90 windows: always initialize uv_process_t
The unix implementation of uv_spawn always starts out with a
uv__handle_init, but the windows implementation sometimes bails out
early before calling uv__handle_init. This means that uv_close on a
failed uv_spawn will always succeed on unix but sometimes fail on
windows.

This commit lifts the initialization of the uv_process_t above all of
the error checking to ensure that uv_close will always work when
uv_spawn returns an error.
2014-02-16 13:09:54 +01:00
Alex Crichton
8692bbc254 windows: fix building on MinGW
The crtdbg.h header was added in c0716b3d, but MinGW does not have this
header present on the system. This commit takes the same approach of
2684f876a and just ignores this header and functionality on MinGW
2014-02-16 13:02:02 +01: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é
66ab38918c unix: call setgoups before calling setuid/setgid
Partial fix for #1093
2014-02-10 22:38:40 +01:00
Saúl Ibarra Corretgé
3901ec4976 unix: fix uv_tcp_nodelay return value in case of error
Fixes #1102
2014-02-10 09:00:46 +01:00
Austin Foxley
451de61b72 unix, win: add uv_udp_set_multicast_interface() 2014-02-07 09:07:11 +01: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
Fedor Indutny
513ce625ba Merge branch 'v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	src/unix/stream.c
	src/version.c
2014-01-31 20:59:49 +04:00
Oguz Bastemur
a6ff04d2c4 stream: start thread after assignments
Changed the order of the member assignments since the thread
may start before the parameters are assigned. This especially
happens when the osx scheduler is very busy.
2014-01-31 20:53:06 +04:00
Timothy J Fontaine
b0ec132aab Now working on v0.11.20 2014-01-29 09:43:38 -08:00
Timothy J Fontaine
336a182530 2014.01.30, Version 0.11.19 (Unstable)
Changes since version 0.11.18:

* linux: move sscanf() out of the assert() (Trevor Norris)

* linux: fix C99/C++ comment (Fedor Indutny)
2014-01-29 09:43:38 -08:00
Timothy J Fontaine
79ffe2fb95 Now working on v0.10.25 2014-01-29 09:41:41 -08:00
Timothy J Fontaine
aecd296b6b 2014.01.30, Version 0.10.24 (Stable)
Changes since version 0.10.23:

* linux: move sscanf() out of the assert() (Trevor Norris)

* linux: fix C99/C++ comment (Fedor Indutny)
2014-01-29 09:41:36 -08:00
Fedor Indutny
923e4ec619 Merge branch 'v0.10'
Conflicts:
	ChangeLog
	src/unix/linux-core.c
	src/version.c
2014-01-29 17:02:25 +04:00
Fedor Indutny
3e2446d18d linux: fix C99/C++ comment 2014-01-29 17:01:35 +04:00
Trevor Norris
7c8ff3bc25 linux: move sscanf() out of the assert()
If asserts are turned off then the sscanf() wouldn't have run, being
placed directly in the assert() itself.
2014-01-29 17:01:26 +04:00
Bert Belder
666aa2f068 Now working on v0.11.19 2014-01-22 21:37:37 +01:00
Bert Belder
d47962e9d9 2014.01.23, Version 0.11.18 (Unstable)
Changes since version 0.11.17:

* osx: Fix a possible segfault in uv__io_poll (Alex Crichton)

* windows: improved handling of invalid FDs (Alexis Campailla)

* doc: adding ARCHS flag to OS X build command (Nathan Sweet)

* tcp: reveal bind-time errors before listen (Alexis Campailla)

* tcp: uv_tcp_dualstack() (Fedor Indutny)

* linux: relax assumption on /proc/stat parsing (Luca Bruno)

* openbsd: fix obvious bug in uv_cpu_info (Fedor Indutny)

* process: close stdio after dup2'ing it (Fedor Indutny)

* linux: move sscanf() out of the assert() (Trevor Norris)
2014-01-22 21:37:34 +01:00
Trevor Norris
74b29000be linux: move sscanf() out of the assert()
If asserts are turned off then the sscanf() wouldn't have run, being
placed directly in the assert() itself.
2014-01-23 00:21:44 +04:00
Fedor Indutny
37e12bdafb Revert "linux: silence uninitialized variable warning"
This reverts commit 5008f8de08.
2014-01-23 00:06:07 +04:00
Trevor Norris
5008f8de08 linux: silence uninitialized variable warning
When building using gyp and BUILDTYPE=Release using clang 3.4 received
this warning:

../src/unix/linux-core.c:640:34: warning: variable 'n' is uninitialized
      for (len = sizeof("cpu0"); n /= 10; len++);
                                 ^

Initializing n = 0 silences this build warning.
2014-01-22 20:59:23 +01:00
Bert Belder
b8b6588dbe Now working on v0.10.24 2014-01-22 20:30:26 +01:00
Bert Belder
dbd218e699 2014.01.23, Version 0.10.23 (Stable)
Changes since version 0.10.22:

* linux: relax assumption on /proc/stat parsing (Luca Bruno)

* openbsd: fix obvious bug in uv_cpu_info (Fedor Indutny)

* process: close stdio after dup2'ing it (Fedor Indutny)
2014-01-22 20:30:14 +01: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
8bc29b6f5f openbsd: fix obvious bug in uv_cpu_info
`int which[]` should not be static here, as the function itself is
changing it

fix joyent/node#6878
2014-01-21 15:06:30 +04:00
Luca Bruno
993151bc40 linux: relax assumption on /proc/stat parsing
CPU entries in /proc/stat are not guaranteed to be monotonically
increasing, asserting on this assumption can break in cases such
as the UltraSparc II machine shown in #1080.

Signed-off-by: Luca Bruno <lucab@debian.org>
2014-01-20 08:45:34 -08: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
Alexis Campailla
d1e6be1460 tcp: reveal bind-time errors before listen
Changed uv_tcp_duplicate_socket to reveal any bind-time errors
before calling listen().

This fix is 100% windows specific.

It helps fix Node.js unite test test-cluster-bind-twice on Windows.
2014-01-16 15:48:30 +00:00
Alexis Campailla
c0716b3d9f windows: improved handling of invalid FDs
If passed and invalid FD, _get_osfhandle() sets an error code
through errno, not _doserrno. Hence we need to use
SET_REQ_WIN32_ERROR insted of SET_REQ_RESULT.

In debug builds, _get_osfhandle() also raises a superfluous
assert. I implemented a wrapper that disables all asserts
around the call to _get_osfhandle().

This fixes node.js unit tests test-fs-read-stream.js and
test-listen-fd-ebadf.js.
2014-01-09 18:29:18 +01:00
Timothy J Fontaine
97eda7fd62 Now working on v0.10.23 2014-01-07 14:03:18 -08:00
Timothy J Fontaine
f526c90eef 2014.01.08, Version 0.10.22 (Stable)
Changes since version 0.10.21:

* windows: avoid assertion failure when pipe server is closed (Bert
  Belder)
2014-01-07 14:03:15 -08:00
Timothy J Fontaine
4ce9c39dd8 Now working on v0.11.18 2013-12-31 10:27:43 -08:00
Timothy J Fontaine
589c224d4c 2013.12.32, Version 0.11.17 (Unstable)
Changes since version 0.11.16:

* stream: allow multiple buffers for uv_try_write (Fedor Indutny)

* unix: fix a possible memory leak in uv_fs_readdir (Alex Crichton)

* unix, windows: add uv_loop_alive() function (Sam Roberts)

* windows: avoid assertion failure when pipe server is closed (Bert
  Belder)

* osx: Fix a possible segfault in uv__io_poll (Alex Crichton)

* stream: fix uv__stream_osx_select (Fedor Indutny)
2013-12-31 10:27:39 -08:00
River Tarnell
17648be234 unix: fix non-OSX builds
uv__stream_osx_interrupt_select was only defined on OS X, but is used
elsewhere on all platforms.  The intention was to implement it as a
no-op on other platforms, but the entire definition was inside
"#ifdef __APPLE__", so this didn't actually work.

Fix: move it above the #ifdef.
2013-12-28 22:17:03 +04:00
Fedor Indutny
08cafd091b stream: fix uv__stream_osx_select
Relying on `readable`/`writable` when polling will lead to the select
thread spinning in the loop and calling `uv_async_send()`, because
stream may never become not `readable`/`writable`.

We should rely on `uv__io_active()` instead and interruprt select thread
every time it changes.
2013-12-27 19:57:44 +04:00
Fedor Indutny
8b6c19e219 Revert "pipe: allow queueing pending handles"
The commit is quite broken and must be refactored before going into.

This reverts commit 08aeaf6193.
2013-12-24 02:17:12 +04:00
Fedor Indutny
08aeaf6193 pipe: allow queueing pending handles
If multiple handles arrive to the IPC pipe at the same time (happens on
some platforms), libuv will queue them internally, and call `read2_cb`
multiple times with a null-buffer and proper `handle_type`.
2013-12-23 14:15:32 +04:00
Alex Crichton
f166d6d705 osx: Fix a possible segfault in uv__io_poll
In our build infrastructure, I've seen a lot of segfaults recently that
were all only happening on OSX. Upon inspecting the coredumps, it
appearded that all segfaults happened at the same instruction, and upon
translating the assembly back to the source, I found that an array could
be indexed with a -1 index before the index was checked to be not -1.

As concrete evidence, here is the situation that I found caused the
segfault.  The instruction in question along with the relevant register
values was:

    mov    (%r8,%r15,8),%r12

    r8  = 0x7fb0ba800000
    r15 = 0xffffffffffffffff

    r8 + r15 * 8 == 0x7fb0ba7ffff8

It appears that the base of loop->watchers was page aligned, and by
going back one word I guess that the page wasn't mapped, causing our
segfaults.
2013-12-22 15:54:08 +04:00