Commit Graph

2509 Commits

Author SHA1 Message Date
Fedor Indutny
0fdd99f02b fsevents: increase stack size for OSX 10.9
Otherwise it fails with `EXC_BAD_ACCESS`.
2013-10-23 12:44:16 +04:00
Ben Noordhuis
9ab5ee2f39 include: document pipe path truncation behavior
Document the fact that the maximum path length for UNIX domain socket
paths is much less than _POSIX_PATH_MAX.

For most file systems, _POSIX_PATH_MAX is 1024 or 4096 bytes while
`sizeof(sockaddr_un.sun_path)` is typically between 92 and 108 bytes.
2013-10-22 12:12:59 +02:00
Saúl Ibarra Corretgé
20edfc76ad windows: remove unneeded check
Cheking if the loop is alive is covered in the while loop afterwards.
Also, the stop flag will be cleared if necessary, which didn't happen
before this patch.
2013-10-22 11:38:25 +02:00
Ben Noordhuis
16fb1291a0 windows: fix duplicate case build error
Mea culpa, the previous commit added another ERROR_FILENAME_EXCED_RANGE
case to the switch statement in uv_translate_sys_error().  This commit
fixes up the build error.
2013-10-20 15:38:20 +02:00
Ben Noordhuis
f2ab62ec10 include: add E2BIG status code mapping
Forgotten in commit 3ee4d3f.  Add it now and renumber the other status
codes.  The Windows status code mappings may not be exhaustive.

Fixes #959.
2013-10-20 14:00:29 +02:00
Ben Noordhuis
777019b768 unix: make uv_tty_reset_mode() async signal-safe
Make it possible to call uv_tty_reset_mode() from inside a signal
handler.  The primary motivation is to make it possible to restore
the TTY from inside a SIGINT or SIGTERM signal handler.

Fixes #954.
2013-10-20 13:58:34 +02:00
Ben Noordhuis
372e9229ad unix: clean up uv_tty_set_mode() a little 2013-10-20 13:58:34 +02:00
Ben Noordhuis
150b6a71c9 unix: add spinlock.h
Add an atomic, non-blocking spinlock type.  The primary use case is to
have a mutex type that we can use while inside a signal handler.
2013-10-20 13:58:34 +02:00
Ben Noordhuis
a3c3b37bfb unix: add atomic-ops.h
Add cmpxchgi(), cmpxchgl() and cpu_relax() functions that we can use
as simple primitives to build spinlocks out of.
2013-10-20 13:58:34 +02:00
Ben Noordhuis
147ab0c582 test: clean up signal_multiple_loops
The test uses some questionable binary math.  Rewrite it in a more
explicit fashion.
2013-10-20 13:57:16 +02:00
Ben Noordhuis
fe4f06261e Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	include/uv-darwin.h
	src/unix/fsevents.c
	src/unix/process.c
2013-10-18 17:29:19 +02: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
Saúl Ibarra Corretgé
9d44d786ad unix, windows: add uv_fs_event_start/stop functions
Make uv_fs_event behave like other handles, that is, it's inactive after
init, and it's active between start and stop.
2013-10-12 20:37:05 +02:00
Reini Urban
b0bb8deb17 .gitignore: fix .deps/, add .dirstamp 2013-10-09 18:02:11 +02:00
Ben Noordhuis
5c00a0ee33 unix: fix SIGCHLD waitpid() race in process.c
Before this commit, multiple event loops raced with each other when a
SIGCHLD signal was received.  More concretely, it was possible for
event loop A to consume waitpid() events that should have been
delivered to event loop B.

This commit addresses that by doing a linear scan over the list of
child processes.  An O(n) scan is not terribly efficient but the
actual performance impact is not measurable in a benchmark that spawns
rounds of several thousands instances of /bin/false.  For the time
being, this patch will suffice; we can always revisit it later.

Fixes #887.
2013-10-09 11:18:13 +02:00
Ben Noordhuis
556fe1a659 linux: ignore fractional time in uv_uptime()
Before this commit, uv_uptime() returned the nanoseconds as the
fractional part of the uptime.  It's a bit inconsistent with the
output on other platforms because those only return whole seconds
(with the possible exception of Windows.)

This commit changes linux-core.c to only return whole seconds.
2013-10-08 23:18:00 +02:00
Luca Bruno
a1e159f04e test: relax timing assumption of timer_again
timer_again test makes an implicit assumption on the triggering
timing of a repeating timer. However, this assumption may be not
true on slower or virtualized architecture due to delay accumulation,
which may fail the test as show in [0].
This commit makes explicit checks conforming to the asserted behavior.

[0] http://ur1.ca/fr5c4

Signed-off-by: Luca Bruno <lucab@debian.org>
2013-10-08 16:26:04 +02:00
Luca Bruno
bddf357baf test: relax timing assumption of loop_stop
The loop_stop test makes an implicit assumption about the triggering
timing of a repeating trigger, which may not hold true on slower or
virtualized machines, thus failing the test as shown at [0] and
discussed at [1].
This commit relaxes the assumption, without mandating the exact number
of runs.

[0] http://ur1.ca/fr5bw
[1] https://groups.google.com/d/msg/libuv/5-fNIC7hIAo/yqznDmwHDAIJ

Signed-off-by: Luca Bruno <lucab@debian.org>
2013-10-08 16:26:04 +02:00
Luca Bruno
6462eaf4dc test: relax TTY availability assumptions
test-tty.c currently assumes that a TTY is available to the test runner,
and fails hard if not. This may not be true on some autobuilding
environment, making the build fail as shown in [0].
Instead, let's properly skip the test in such cases.

[0] http://ur1.ca/fr5bd

Signed-off-by: Luca Bruno <lucab@debian.org>
2013-10-08 16:26:04 +02:00
Fedor Indutny
429bb804ed fsevents: fix clever rescheduling
There're could be a situation, where one fsevents handle gets created
and another one is destroyed simultaneously. In such cases
`fsevent_need_reschedule` will be set to 1 twice and reset only once,
leaving handle destructor hanging in uv_sem_wait().
2013-10-05 22:18:06 +04: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
0d435a5662 unix: remove uv__pipe_accept()
It's basically a less advanced version of uv__server_io().  Drop the
former in favor of the latter.
2013-10-01 04:14:36 +02:00
Ben Noordhuis
359d667893 unix: sanity-check fds before closing
Ensure that close() system calls don't close stdio file descriptors
because that is almost never the intention.

This is also a partial workaround for a kernel bug that seems to affect
all Linux kernels when stdin is a pipe that gets closed: fd 0 keeps
signalling EPOLLHUP but a subsequent call to epoll_ctl(EPOLL_CTL_DEL)
fails with EBADF.  See joyent/node#6271 for details and a test case.
2013-10-01 03:55:54 +02:00
Ben Noordhuis
636f2056a7 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	ChangeLog
	include/uv-darwin.h
	src/unix/darwin.c
	src/unix/fsevents.c
	src/version.c
	src/win/fs.c
2013-10-01 13:20:21 +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
Ben Noordhuis
7c7717c6b2 windows: remove duplicate check in stream.c
Fixes #937.
2013-09-25 23:07:10 +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
Bert Belder
581e8c9266 doc: update readme
Update the intro blurb and spend a few more words on libuv's features.
2013-09-23 11:38:03 +02:00
Timothy J Fontaine
717e0e5635 build: use -pthread on sunos
When building on sunos with autoconf make sure to specify -pthread
otherwise there will be race conditions with errno and etc
2013-09-20 10:50:19 -07:00
Ben Noordhuis
b460142451 bench: measure total/init/dispatch/cleanup times
* Add finer-grained measurements to the million_timers benchmark.
  Before this commit it only measured the total running time.

* Bump the number of inserted timers from 1M to 10M.  With one million
  timers, it finishes too quickly to get useful profiling data out of
  it with perf or oprofile.  The name of the benchmark is now a lie but
  such is life.
2013-09-13 00:17:52 +02:00
Ben Noordhuis
d7115f0677 unix, windows: make uv_is_*() always return 0 or 1
Ensure that the following API functions always return either 0 or 1:

  * uv_is_active()
  * uv_is_closing()
  * uv_is_readable()
  * uv_is_writable()
2013-09-12 13:30:06 +02:00
Ben Noordhuis
05822a5507 unix: wrap long lines at 80 columns 2013-09-11 17:29:43 +02:00
Ben Noordhuis
f5baf210df test: wrap long lines at 80 columns 2013-09-11 17:29:43 +02:00
Ben Noordhuis
ce3c38a5d8 include: make uv_process_options_t.cwd const
There is no reason for it to be non-const, libuv treats it as a
read-only input.  Make it a pointer to a const string.
2013-09-10 23:29:35 +02:00
Ben Noordhuis
adcc2273f4 include: update uv_is_active() documentation
Seems to have been overlooked in the reference counting refactor back
in May 2012 in commit 9efa8b3.  Clarify what "active" means for
different kinds of handles.
2013-09-08 23:25:31 +02:00
Ben Noordhuis
b83109c524 include: fix typo in comment in uv.h 2013-09-08 23:25:07 +02:00
Ben Noordhuis
9e4982f5c9 include: remove UV_IO_PRIVATE_FIELDS macro
It's an alias for UV_IO_PRIVATE_PLATFORM_FIELDS.  Remove the macro and
use UV_IO_PRIVATE_PLATFORM_FIELDS directly.
2013-09-08 20:21:24 +02:00
Ben Noordhuis
b7d333fc91 include: clean up includes in uv.h
* size_t is defined in <stddef.h>, not <sys/types.h>

* Simplify the platform check.
2013-09-08 20:14:30 +02:00
Ben Noordhuis
02e8c8ef65 include: clarify uv_tcp_bind() behavior
On BSD-like platforms, EADDRINUSE is returned by the bind() system call.
On other platforms, it's returned by the listen() system call.

In other words, some platforms are 'first to bind wins', others are
'first to listen wins' - but only with TCP sockets: UNIX domain sockets
always return EADDRINUSE from the bind() system call, UDP sockets don't
call listen() in the first place.

Fixes #769.
2013-09-06 15:15:36 +02:00
Saúl Ibarra Corretgé
2b9c374c1c windows: run close callbacks after polling for i/o
Makes the uv-win behavior compatible with uv-unix.

Fixes #796.
2013-09-06 06:28:42 +02: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
Ben Noordhuis
712835a673 build: remove GCC_WARN_ABOUT_MISSING_NEWLINE
Not compatible with non-Apple gcc builds.  Fixes the following build
error:

    gcc-4.8: error: unrecognized command line option '-Wnewline-eof'
2013-09-05 21:33:59 +02:00
Brian Kaisner
8e23b046a6 build: clarify instructions for Windows
Clarified up front that Python must be installed for all Windows builds
and it must be in the path. Simplified the Windows instructions by
removing the redundant msbuild guidance.

Also added subheadings for each unique build environment.
2013-09-05 21:17:58 +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
20e774c62a 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 09:05:28 +02:00