Commit Graph

2287 Commits

Author SHA1 Message Date
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
Geert Jansen
991409e461 build: fix windows smp build with gyp
Gyp will try a parallel build if it detect the system has >1 processor.
This functionality depends on the Python "multiprocessing" package. The
multiprocessing package on Windows requires that the top-level module is
importable as a module, see:

  http://docs.python.org/2/library/multiprocessing.html#windows

This fixes issue #984.

This is a back-port of commit 2445467 from the master branch.
2013-11-05 14:32:45 +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
f9960184fd test: add regression test for 29fdb3471 2013-10-31 01:16:02 +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
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
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
Bert Belder
39bef32906 windows/fs: wrap multi-statement macros in do..while block 2013-09-05 08:52:03 +02:00
Bert Belder
61b20e8d46 windows: make uv_shutdown() for write-only pipes work
A couple of issues prevented uv_shutdown() from working correctly with
write-only pipes.

  * The pipe handle wasn't opened with the right permissions, so an
    attempt to probe the state of the write buffer would fail with
    ERROR_ACCESS_DENIED.

  * The pipe flags for child process stdio pipes were always set to
    UV_HANDLE_READABLE and UV_HANDLE_WRITABLE, even in cases where it
    was actually half-duplex.

  * There was no code path that lead to closing the pipe handle if the
    pipe was write-only.
2013-08-29 15:19:18 +02:00
Bert Belder
851a662416 windows: make uv_fs_chmod() report errors correctly
Before this patch libuv would attempt to use GetLastError() to retrieve
the cause of NtQueryInformationFile failure, but that's not how it
should be done.
2013-08-24 16:42:55 +02:00
Bert Belder
c8b6895eaf Now working on v0.10.16 2013-08-23 18:57:14 +02:00
Bert Belder
221078a8fd 2013.08.24, Version 0.10.15 (Stable)
Changes since version 0.10.14:

* fsevents: create FSEvents thread on demand (Ben Noordhuis)

* fsevents: use a single thread for interacting with FSEvents, because
  it's not thread-safe. (Fedor Indutny)

* fsevents: share FSEventStream between multiple FS watchers, which
  removes a limit on the maximum number of file watchers that can be
  created on OS X. (Fedor Indutny)
2013-08-23 18:57:10 +02:00
Fedor Indutny
684e2124e7 fsevents: use shared FSEventStream
It seems that number of simultaneously opened FSEventStreams is
limited on OSX (i.e. you can have only fixed number of them on
one running system), getting past through this limit will cause
`FSEventStreamCreate` to return false and write following message
to stderr:

    (CarbonCore.framework) FSEventStreamStart: register_with_server:
    ERROR: f2d_register_rpc() => (null) (-21)

To prevent this, we must use only one shared FSEventStream with a
paths for all uv_fsevent_t handles, and then filter out events for
each handle using this paths again.

See https://github.com/joyent/node/issues/5463

Conflicts:
	include/uv-private/uv-darwin.h
	src/unix/fsevents.c
2013-08-22 16:57:54 +04:00
Fedor Indutny
ea4cb77814 fsevents: FSEvents is most likely not thread-safe
Perform all operation with FSEventStream in the same thread, where it'll
be used.

Conflicts:
	src/unix/fsevents.c
2013-08-22 16:50:42 +04:00
Ben Noordhuis
9bae606d41 darwin: create fsevents thread on demand
* Move CF run loop code to fsevents.c.

* Create the fsevents thread on demand rather than at startup.

* Remove use of ACCESS_ONCE. All accesses to loop->cf_loop are
  protected by full memory barriers so no reordering can take place.

Fixes #872.

Conflicts:
	src/unix/darwin.c
2013-08-22 16:48:53 +04:00
Timothy J Fontaine
24a42a406a Now working on v0.10.15 2013-08-21 14:41:26 -07:00
Timothy J Fontaine
15d6413215 2013.08.22, Version 0.10.14 (Stable)
Changes since version 0.10.13:

* unix: retry waitpid() on EINTR (Ben Noordhuis)
2013-08-21 14:41:23 -07:00
Ben Noordhuis
b2ac4d3bf4 unix: retry waitpid() on EINTR
Before this commit, libuv would abort() if waitpid() failed with EINTR.

It's unlikely that anyone actually hit this error condition: the major
UNIX platforms - with the possible exception of Solaris - don't return
EINTR when the WNOHANG flag is specified, as libuv does.

However, POSIX allows for an implementation to do whatever here: unless
explicitly forbidden, it's allowed and POSIX doesn't restrict
implementers in this particular area.

Let's opt for robustness and handle EINTR.
2013-08-18 17:45:52 +02:00
Timothy J Fontaine
2744e1e009 Now working on v0.10.14 2013-07-25 10:34:41 -07:00
Timothy J Fontaine
381312e1fe 2013.07.26, Version 0.10.13 (Stable)
Changes since version 0.10.12:

* unix, windows: fix uv_fs_chown() function prototype (Ben Noordhuis)
2013-07-25 10:31:28 -07:00
Ben Noordhuis
d779eb53d5 unix, windows: fix uv_fs_chown() function prototype
Before this commit, uv_fs_chown() and uv_fs_fchown() took the uid and
gid as signed integers which is wrong because uid_t and gid_t are
unsigned on most all platforms and IDs that don't fit in a signed
integer do exist.

This is not an ABI change because the size of the uid and gid arguments
do not change, only their sign.

On Windows, uv_uid_t and uv_gid_t are typedef'd as unsigned char for
reasons that are unclear. It doesn't matter: they get cast to ints when
used as function arguments. The arguments themselves are unused.

Partial fix for joyent/node#5890.
2013-07-23 13:24:37 +02:00
isaacs
3b4e0a216f Now working on v0.10.13 2013-07-09 13:18:53 -07:00
isaacs
58a46221bb 2013.07.10, Version 0.10.12 (Stable)
Changes since version 0.10.11:

* linux: add support for MIPS (Andrei Sedoi)

* windows: uv_spawn shouldn't reject reparse points (Bert Belder)

* windows: use WSAGetLastError(), not errno (Ben Noordhuis)

* build: darwin: disable -fstrict-aliasing warnings (Ben Noordhuis)

* build: `all` now builds static and dynamic lib (Ben Noordhuis)

* unix: fix build when !defined(PTHREAD_MUTEX_ERRORCHECK) (Ben
  Noordhuis)
2013-07-09 13:18:50 -07:00
Ben Noordhuis
37d0209c89 unix: fix build when !defined(PTHREAD_MUTEX_ERRORCHECK)
Ancient versions of glibc (<= 2.3.1) don't have error-checking mutexes.
2013-07-05 12:15:08 +02:00
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