Commit Graph

1575 Commits

Author SHA1 Message Date
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
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
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
46a0602141 Merge branch 'v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	src/version.c
2013-12-20 17:48:28 -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
Sam Roberts
ed36b85d3b unix, windows: add uv_loop_alive() function
Useful to know when the the event loop is empty, this can't be done with
uv_run() without possibly blocking, or running some events (which might
empty the event loop as a side-effect).
2013-12-19 15:35:03 -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
Fedor Indutny
17d60e3f94 stream: allow multiple buffers for uv_try_write 2013-12-13 22:59:47 +04:00
Timothy J Fontaine
333a5b730f Now working on v0.11.17 2013-12-13 10:32:35 -08:00
Timothy J Fontaine
ae0ed8c49d 2013.12.14, Version 0.11.16 (Unstable)
Changes since version 0.11.15:

* fsevents: remove kFSEventStreamCreateFlagNoDefer polyfill (ci-innoq)

* libuv: add more getaddrinfo errors (Steven Kabbes)

* unix: fix accept() EMFILE error handling (Ben Noordhuis)

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

* fsevents: fix subfolder check (Fedor Indutny)

* fsevents: fix invalid memory access (huxingyi)

* windows/timer: fix uv_hrtime discontinuity (Bert Belder)

* unix: fix various memory leaks and undef behavior (Fedor Indutny)

* unix, windows: always update loop time (Saúl Ibarra Corretgé)

* windows: translate system errors in uv_spawn (Alexis Campailla)

* windows: uv_spawn code refactor (Alexis Campailla)

* unix, windows: detect errors in uv_ip4/6_addr (Yorkie)

* stream: introduce uv_try_write(...) (Fedor Indutny)
2013-12-13 10:32:32 -08:00
Fedor Indutny
b5e7798a89 stream: introduce uv_try_write(...)
`uv_try_write(stream, buf, size)` acts like `uv_write()`,
but without queueing actual write until UV_POLLOUT (or IOCP completion).
This is useful for doing writes using on-stack `uv_write_t` requests.

fix #1025
2013-12-13 22:29:00 +04:00
Yorkie
4ed6496b9c unix, windows: detect errors in uv_ip4/6_addr 2013-12-13 09:27:28 +01:00
Alexis Campailla
b83caf8624 windows: uv_spawn code refactor 2013-12-12 09:53:14 -08:00
Alexis Campailla
b65b74741e windows: translate system errors in uv_spawn
We weren't always translating system errors for in uv_spawn.

This is half a fix for node's unit test
 test-child-process-cwd.js on win.
 The rest will go into node lib.
 It also fixes test-child-process-exec-error
2013-12-12 09:53:10 -08: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
Saúl Ibarra Corretgé
15af49a7a0 unix, windows: always update loop time
Fixes #846
2013-12-10 09:13:34 +01:00
Fedor Indutny
646de34f5e unix: fix various memory leaks and undef behavior
Kindly suggested by `cppcheck`.
2013-12-07 02:29:43 +04:00
Bert Belder
f6c1a270ed Merge branch 'v0.10' 2013-11-29 21:42:18 -08:00
Bert Belder
44ecaa7c98 windows/timer: fix uv_hrtime discontinuity
Large performance counter frequency values would cause overflows, even
when 64-bit integers were used to do the multiplication with NANOSEC.
Fix this by using floating point math instead.

Fixes #850
2013-11-29 21:38:53 -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
isaacs
5812e19bf6 Merge branch 'v0.10' 2013-11-29 16:25:58 -08:00
Alex Gaynor
47d98b64c4 doc: Removed use of gendered pronouns 2013-11-29 16:25:01 -08:00
Fedor Indutny
bf5038df40 fsevents: fix subfolder check
First of all, a bit of explanation of what happens there:

1. FSEvents emits absolute paths to changed files or directories
2. We cut off the first part of such paths, which is equal to handle's
   real path ('/dir/subdir/subsubdir`, without trailing slash)
3. Then, if we are running in non-recursive mode, we discard paths that
   have slashes ('/') as a non-first character in them
2013-11-26 13:24:57 +04: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
27795cfc0f unix: fix accept() EMFILE error handling
Fix a bug that was introduced in commit 3ee4d3f ("unix, windows:
return error codes directly") and add a regression test for good
measure.

Hat tip to Fedor for pointing out the issue.

Fixes #1007.
2013-11-25 01:54:47 +01:00
Steven Kabbes
dbe9905799 libuv: add more getaddrinfo errors 2013-11-25 00:53:07 +01:00
ci-innoq
c438e739a8 fsevents: remove kFSEventStreamCreateFlagNoDefer polyfill
The kFSEventStreamCreateFlagNoDefer flag is already
defined in CarbonCore/FSEvents.h since OS X 10.5.

Fixes #1000.
2013-11-23 12:20:30 +04:00
Timothy J Fontaine
3a01e68385 Now working on v0.11.16 2013-11-20 08:22:28 -08:00
Timothy J Fontaine
bfe645ed7e 2013.11.21, Version 0.11.15 (Unstable)
Changes since version 0.11.14:

* fsevents: report errors to user (Fedor Indutny)

* include: UV_FS_EVENT_RECURSIVE is a flag (Fedor Indutny)

* linux: use CLOCK_MONOTONIC_COARSE if available (Ben Noordhuis)

* build: make systemtap probes work with gyp build (Ben Noordhuis)

* 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)

* queue: strengthen type checks (Ben Noordhuis)

* include: remove uv_strlcat() and uv_strlcpy() (Ben Noordhuis)

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

* unix: return exec errors from uv_spawn, not async (Alex Crichton)

* fsevents: use native character encoding file paths (Ben Noordhuis)

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

* windows: use _snwprintf(), not swprintf() (Ben Noordhuis)

* fsevents: use FlagNoDefer for FSEventStreamCreate (Fedor Indutny)

* unix: fix reopened fd bug (Fedor Indutny)

* core: fix fake watcher list and count preservation (Fedor Indutny)

* unix: set close-on-exec flag on received fds (Ben Noordhuis)

* netbsd, openbsd: enable futimes() wrapper (Ben Noordhuis)

* unix: nicer error message when kqueue() fails (Ben Noordhuis)

* samples: add socks5 proxy sample application (Ben Noordhuis)
2013-11-20 08:22:25 -08:00
Ben Noordhuis
ab37249975 unix: nicer error message when kqueue() fails
Print the error message rather than just the errno.  The fact that the
errno is 24 is only informative to people that have their operating
system's error codes memorized.
2013-11-18 21:00:14 +01:00