Commit Graph

1358 Commits

Author SHA1 Message Date
Fedor Indutny
703a9e601e sunos: handle rearm errors
fix #1078
2014-02-19 00:14:13 +04: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
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
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
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
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
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
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
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
Alex Crichton
f6422af80a 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 03:53:49 -08:00
Bert Belder
7b16a3f508 windows: avoid assertion failure when pipe server is closed
When a pipe server is closed, all pending accept requests and their
associated HANDLEs are closed to force windows to cancel the
ConnectNamedPipe IRP. The returned request has the `pipeHandle` field
set to INVALID_HANDLE_VALUE, which trips an assert in
uv_pipe_process_accept_req. This patch fixes that.
2013-12-20 17:45:49 -08:00
Timothy J Fontaine
9d60214b3a Now working on v0.10.22 2013-12-18 15:37:33 -08:00
Timothy J Fontaine
375ebce068 2013.12.19, Version 0.10.21 (Stable)
Changes since version 0.10.20:

* unix: fix a possible memory leak in uv_fs_readdir (Alex Crichton)
2013-12-18 15:37:25 -08:00
Alex Crichton
7c6bddbe2a unix: fix a possible memory leak in uv_fs_readdir
Some scandir implementations allocate the dirent struct even if the
directory is empty, so if `scandir` returns 0 there may still be memory
that needs to get deallocated. I have altered uv__fs_readdir to go to
the "deallocation exit area" when 0 files are found in the directory
and continue to return early on a return value of -1.

I went to add a test for this functionality, but it appears that one
already exists (reading an empty directory), so I imagine that the
valgrind builds must only be happening on linux instead of OSX as well?
I have confirmed manually that a program without this fix will
infinitely leak memory, and with this fix the memory usage stays
constant.
2013-12-18 12:05:47 +04:00
Timothy J Fontaine
f3d311edc4 Now working on v0.10.21 2013-12-11 20:22:00 -08:00
Timothy J Fontaine
04141464dd 2013.12.13, Version 0.10.20 (Stable)
Changes since version 0.10.19:

* linux: fix up SO_REUSEPORT back-port (Ben Noordhuis)

* fs-event: fix invalid memory access (huxingyi)
2013-12-11 20:21:57 -08:00
huxingyi
da32344730 fs-event: fix invalid memory access
file_info->FileName is not null terminated.
2013-11-29 20:57:35 -08:00
Alex Gaynor
47d98b64c4 doc: Removed use of gendered pronouns 2013-11-29 16:25:01 -08:00
Ben Noordhuis
74457d08ba linux: fix up SO_REUSEPORT back-port
Commit 3d2c820 back-ports a patch from the master branch that disables
the use of SO_REUSEPORT on Linux for reasons mentioned in the commit
log.

Unfortunately, the back-port was incomplete; another setsockopt() call
site in src/unix/udp.c was overlooked.  This commit rectifies that.

Hat tip to Luca Bruno for helping troubleshoot the issue.
2013-11-25 16:18:01 +01:00
Ben Noordhuis
026241ca67 unix: unbreak bsd build after bbccafb
Unbreak the build on the BSDs after commit bbccafb.  Move the new
uv__platform_invalidate_fd() function from src/unix/darwin.c to
src/unix/kqueue.c.
2013-11-13 12:20:09 +01:00
Timothy J Fontaine
1578a5a371 Now working on v0.10.20 2013-11-12 10:54:29 -08:00
Timothy J Fontaine
33959f7524 2013.11.13, Version 0.10.19 (Stable)
Changes since version 0.10.18:

* darwin: avoid calling GetCurrentProcess (Fedor Indutny)

* unix: update events from pevents between polls (Fedor Indutny)

* fsevents: support japaneese characters in path (Chris Bank)

* linux: don't turn on SO_REUSEPORT socket option (Ben Noordhuis)

* build: fix windows smp build with gyp (Geert Jansen)

* linux: handle EPOLLHUP without EPOLLIN/EPOLLOUT (Ben Noordhuis)

* unix: fix reopened fd bug (Fedor Indutny)

* core: fix fake watcher list and count preservation (Fedor Indutny)
2013-11-12 10:54:25 -08:00
Fedor Indutny
f50ccd5238 core: fix fake watcher list and count preservation
Fake watcher list and count should be preserved only if
`loop->watchers` was already allocated.
2013-11-12 15:24:33 +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
Ben Noordhuis
0c76cdb98f 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.

This is a back-port of commit 24bfef2 from the master branch.
2013-11-08 05:38:55 +01:00
Ben Noordhuis
3d2c820a4e linux: don't turn on SO_REUSEPORT socket option
On the BSDs, SO_REUSEPORT is pretty much SO_REUSEADDR with some special
casing for IP multicast.  When two processes (that don't do multicast)
bind to the same address, only the last one receives traffic.  It allows
one to "steal" the bound address from another process.  (Both processes
have to enable SO_REUSEPORT though, so it only works in a cooperative
setting.)

On Linux however, it enables port sharing, not stealing - both processes
receive a share of the traffic.  This is a desirable trait but pre-3.9
kernels don't support the socket option and a libuv program therefore
behaves differently with older kernels or on another platform.

This is a back-port of commit 9d60f1e from the master branch.

Fixes joyent/node#6454.
2013-10-30 09:41:52 +01:00
Chris Bank
3780e12823 fsevents: support japaneese characters in path 2013-11-02 05:00:50 +04:00
Fedor Indutny
29fdb3471b unix: update events from pevents between polls
Watchers could be stopped between two `kevent()`/`epoll_wait()` calls
(which may happen in the same loop in `uv__io_poll()`), in such cases
`watcher->events` could be stale and won't be updated to
`watcher->pevents`.

Try to use and rely on `watcher->pevents` instead of blindly expecting
`watcher->events` to be always correct.
2013-10-30 12:40:25 +04:00
Fedor Indutny
08e0e63f3a darwin: avoid calling GetCurrentProcess
Use some black-magic from Apple to change process name without getting
a "Not responding" tag from Activity Manager.

fix #966
2013-10-28 20:51:50 +04:00
Timothy J Fontaine
939560b6db Now working on v0.10.19 2013-10-18 13:17:52 -07:00
Timothy J Fontaine
9ec52963b5 2013.10.19, Version 0.10.18 (Stable)
Changes since version 0.10.17:

* unix: fix uv_spawn() NULL pointer deref on ENOMEM (Ben Noordhuis)

* unix: don't close inherited fds on uv_spawn() fail (Ben Noordhuis)

* unix: revert recent FSEvent changes (Ben Noordhuis)

* unix: fix non-synchronized access in signal.c (Ben Noordhuis)
2013-10-18 13:17:48 -07:00
Ben Noordhuis
1800efc138 unix: fix non-synchronized access in signal.c
Check the return value of uv__signal_lock(); don't mutate the signal
watcher tree in the signal handler if we failed to acquire the lock.
2013-10-18 17:10:04 +02:00
Ben Noordhuis
38df93cfed unix: revert recent FSEvent changes
This commit reverts the following commits:

    983fa68 darwin: fix 10.6 build error in fsevents.c
    684e212 fsevents: use shared FSEventStream
    ea4cb77 fsevents: FSEvents is most likely not thread-safe
    9bae606 darwin: create fsevents thread on demand

Several people have reported stability issues on OS X 10.8 and bus
errors on the 10.9 developer preview.

See also joyent/node#6296 and joyent/node#6251.
2013-10-05 18:24:33 +02:00
Ben Noordhuis
11d8011793 unix: don't close inherited fds on uv_spawn() fail
The cleanup-after-error code path in uv_spawn() was closing file
descriptors indiscriminately.  Only close file descriptors that we
created ourselves, not the ones that are passed in by the user.

Fixes joyent/node#6297.
2013-10-02 11:17:20 +02:00
Ben Noordhuis
fc3a21f943 unix: fix uv_spawn() NULL pointer deref on ENOMEM
In the cleanup-after-error section of uv_spawn(), check that the pointer
is non-NULL - we might end up in said section due to a malloc() failure.
2013-10-02 10:56:56 +02:00
Ben Noordhuis
8c9cbee1b1 Revert "unix: set O_NONBLOCK in uv_pipe_open()"
It turns out that node.js relies on the blocking behavior of pipes in
some cases, notably when forking worker processes.  Reopens #941.

This reverts commit 8fe4ca686b.
2013-09-28 20:50:45 +02:00
Ben Noordhuis
8fe4ca686b unix: set O_NONBLOCK in uv_pipe_open()
Don't rely on the caller to set the O_NONBLOCK flag on the file
descriptor.

Prevents sporadic stalls when the file descriptor is in blocking mode
and exactly as many bytes are read as there are available; in that case,
libuv will try to read again and block.  Node.js was guilty of this.

Fixes #941.
2013-09-28 10:30:09 +02:00
Timothy J Fontaine
e9df7cbcbb Now working on v0.10.18 2013-09-24 13:40:44 -07:00
Timothy J Fontaine
9670e0a935 2013.09.25, Version 0.10.17 (Stable)
Changes since version 0.10.16:

* build: remove GCC_WARN_ABOUT_MISSING_NEWLINE (Ben Noordhuis)

* darwin: fix 10.6 build error in fsevents.c (Ben Noordhuis)
2013-09-24 13:40:40 -07:00
Ben Noordhuis
983fa68e9f darwin: fix 10.6 build error in fsevents.c
Work around an 'initializer element is not constant' build error in
src/unix/fsevents.c by turning the const int flags into #defines.

Only an issue on OS X 10.6 due to the old compiler it uses.

Fixes #908.

This is a back-port of commit 82f2472 from the master branch.
2013-09-05 21:33:59 +02:00
Bert Belder
7e5c63c88d Now working on v0.10.17 2013-09-05 16:45:51 +02:00
Bert Belder
2bce230d81 2013.09.06, Version 0.10.16 (Stable)
Changes since version 0.10.15:

* windows: make uv_shutdown() for write-only pipes work (Bert Belder)

* windows: make uv_fs_open() report EINVAL when invalid arguments are
  passed (Bert Belder)

* windows: make uv_fs_open() report _open_osfhandle() failure correctly
  (Bert Belder)

* windows: make uv_fs_chmod() report errors correctly (Bert Belder)

* windows: wrap multi-statement macros in do..while block (Bert Belder)
2013-09-05 16:45:45 +02:00
Bert Belder
faf2c5932c windows/fs: handle _open_osfhandle() failure correctly
Until now we assumed that _open_osfhandle() would set _doserrno on
failure. This assumption was very wrong in one obvious case, namely when
the CRT file descriptor table would fill up. In that case errno is set
to EMFILE, but GetLastError() returns zero - which makes sense because
it's not a win32 error but rather a CRT problem.
2013-09-05 08:52:14 +02:00
Bert Belder
812717d0dd windows/fs: make uv_fs_open() report EINVAL correctly
Before, when the user passed an invalid paramter to uv_fs_open, libuv
would detect this and call SET_REQ_RESULT to set the result value to -1.
SET_REQ_RESULT then stored whatever error code was returned by
GetLastError(), which would have no relationship to the actual problem,
and might as well be zero.
2013-09-05 08:52:11 +02:00