Commit Graph

1532 Commits

Author SHA1 Message Date
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
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
Ben Noordhuis
f38869898d netbsd, openbsd: enable futimes() wrapper
OpenBSD and NetBSD have working futimes() implementations.  This commit
makes uv_fs_futime() work on those platforms.
2013-11-16 23:01:14 +01:00
Ben Noordhuis
e9f75fb146 unix: set close-on-exec flag on received fds
Set the close-on-exec flag on file descriptors that we've received with
recvmsg() so we don't leak them when calling fork() afterwards.

On Linux, we use the MSG_CMSG_CLOEXEC flag when supported (2.6.23 and
up.)

On older Linux versions and other platforms, we walk the received file
descriptors and set the close-on-exec flag for each fd manually.  That
won't entirely avoid race conditions when other threads call fork() or
clone() but at least we're less likely to leak file descriptors now.
2013-11-15 23:13:06 +01:00
Ben Noordhuis
17711b9053 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	src/unix/darwin.c
	src/version.c
2013-11-13 13:52:53 +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
6149b66ccb Merge branch 'v0.10'
Conflicts:
	build.mk
	src/unix/core.c
	src/unix/darwin.c
2013-11-12 15:30:54 +04: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
Fedor Indutny
0f5c28b684 fsevents: use FlagNoDefer for FSEventStreamCreate
Otherwise `FSEventStreamCreate()` will coalesce events, even if they're
happening in the interval, bigger than supplied `latency`. In other
words, if this flag is not set events will happen in separate callback
only if there was a delay bigger than `latency` between two consecutive
events.
2013-11-10 13:05:27 +04:00
Ben Noordhuis
c6ecf97aaf windows: use _snwprintf(), not swprintf()
Drop the _CRT_NON_CONFORMING_SWPRINTFS hack and just use _snwprintf().

It's a long and complicated story but the gist of it is that the MS CRT
had a swprintf() function before ISO C did, with a different function
prototype to boot: the ISO C one takes a |size| argument, the MS one
does not.

The function prototype that's exported by mingw and mingw-w64 depends
on the mingw version and the _CRT_NON_CONFORMING_SWPRINTFS define.
If they don't match up, you get the wrong prototype and things will
crash at run-time.

Reduce the phase space by sidestepping the whole issue: drop swprintf()
altogether and use _snwprintf() from now on.

Fixes #990.
2013-11-08 12:39:59 +01: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
24bfef2ef4 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.
2013-11-08 05:16:55 +01:00
Ben Noordhuis
b1b931de4e fsevents: use native character encoding file paths
Create file paths with CFStringCreateWithFileSystemRepresentation(),
not CFStringCreateWithCString().

Reapplies 3780e12 ("fsevents: support japaneese characters in path")
from the v0.10 branch.  Was dropped in the last v0.10 -> master merge
for failing to apply.
2013-11-08 14:03:57 +01:00
Ben Noordhuis
2bb3326c48 Merge remote-tracking branch 'origin/v0.10'
Drops commit 3780e12 ("fsevents: support japaneese characters in path")
for being quite inapplicable to the master branch.  Will be reworked
and applied in a follow-up commit.

Conflicts:
	README.md
	build.mk
	src/unix/fsevents.c
	src/unix/udp.c
2013-11-08 03:44:31 +01:00
Alex Crichton
f764bff699 unix: return exec errors from uv_spawn, not async
If spawning a process fails due to an exec() failure (but it succeeded
in forking), then this should be considered a spawn failure instead of
an asynchronous termination of the process. This allows to check for
common exec() failure conditions such as a bad path quickly instead of
having to rely on keeping track of the async callback.

Additionally, the meaning of the two fields returned in the callback are
now exactly what they advertise to be. The process exit argument is not
one of two values depending on what happened to the child.

Fixes #978.
2013-11-07 22:10:38 +01:00
Ben Noordhuis
7f44933c43 include: remove uv_strlcat() and uv_strlcpy()
It was pointed out that they don't quite work like their BSD namesakes
and they arguably shouldn't have been part of the API anyway.

Fixes #983.
2013-11-03 03:50:23 +01:00
Ben Noordhuis
0520464870 queue: strengthen type checks
Rewrite some of the macros in a way that:

  a) makes them more likely to trigger compile-time errors if used
     inappropriately, and

  b) makes C++ compilers happy
2013-11-02 13:55:57 +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
Ben Noordhuis
21c37a7db8 linux: use CLOCK_MONOTONIC_COARSE if available
On some systems, clock_gettime(CLOCK_MONOTONIC) is only serviced from
the vDSO when the __vdso_clock_gettime() wrapper is confident enough
that the vDSO timestamp is highly accurate.  When in doubt, it falls
back to making a traditional SYS_clock_gettime system call with all
the overhead that entails.

While a commendable approach, it's overkill for our purposes because we
don't usually need high precision time. That's why this commit switches
to CLOCK_MONOTONIC_COARSE for low-precision timekeeping, provided said
clock has at least a one millisecond resolution.

This change should eliminate the system call on almost all systems,
including virtualized ones, provided the kernel is >= 2.6.32 and glibc
is new enough to find and parse the vDSO.
2013-10-29 21:24:42 +01:00
Fedor Indutny
43bef41031 fsevents: report errors to user 2013-10-31 01:06:37 +04:00
Timothy J Fontaine
b45e3cca6b Now working on v0.11.15 2013-10-29 14:59:02 -07:00
Timothy J Fontaine
d7a6482f45 2013.10.30, Version 0.11.14 (Unstable)
Changes since version 0.11.13:

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

* fsevents: FSEvents is most likely not thread-safe (Fedor Indutny)

* fsevents: use shared FSEventStream (Fedor Indutny)

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

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

* windows/fs: wrap multi-statement macros in do..while block (Bert
  Belder)

* windows/fs: make uv_fs_open() report EINVAL correctly (Bert Belder)

* windows/fs: handle _open_osfhandle() failure correctly (Bert Belder)

* windows/fs: wrap multi-statement macros in do..while block (Bert
  Belder)

* windows/fs: make uv_fs_open() report EINVAL correctly (Bert Belder)

* windows/fs: handle _open_osfhandle() failure correctly (Bert Belder)

* build: clarify instructions for Windows (Brian Kaisner)

* build: remove GCC_WARN_ABOUT_MISSING_NEWLINE (Ben Noordhuis)

* darwin: fix 10.6 build error in fsevents.c (Ben Noordhuis)

* windows: run close callbacks after polling for i/o (Saúl Ibarra
  Corretgé)

* include: clarify uv_tcp_bind() behavior (Ben Noordhuis)

* include: clean up includes in uv.h (Ben Noordhuis)

* include: remove UV_IO_PRIVATE_FIELDS macro (Ben Noordhuis)

* include: fix typo in comment in uv.h (Ben Noordhuis)

* include: update uv_is_active() documentation (Ben Noordhuis)

* include: make uv_process_options_t.cwd const (Ben Noordhuis)

* unix: wrap long lines at 80 columns (Ben Noordhuis)

* unix, windows: make uv_is_*() always return 0 or 1 (Ben Noordhuis)

* bench: measure total/init/dispatch/cleanup times (Ben Noordhuis)

* build: use -pthread on sunos (Timothy J. Fontaine)

* windows: remove duplicate check in stream.c (Ben Noordhuis)

* unix: sanity-check fds before closing (Ben Noordhuis)

* unix: remove uv__pipe_accept() (Ben Noordhuis)

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

* fsevents: fix clever rescheduling (Fedor Indutny)

* linux: ignore fractional time in uv_uptime() (Ben Noordhuis)

* unix: fix SIGCHLD waitpid() race in process.c (Ben Noordhuis)

* unix, windows: add uv_fs_event_start/stop functions (Saúl Ibarra
  Corretgé)

* unix: fix non-synchronized access in signal.c (Ben Noordhuis)

* unix: add atomic-ops.h (Ben Noordhuis)

* unix: add spinlock.h (Ben Noordhuis)

* unix: clean up uv_tty_set_mode() a little (Ben Noordhuis)

* unix: make uv_tty_reset_mode() async signal-safe (Ben Noordhuis)

* include: add E2BIG status code mapping (Ben Noordhuis)

* windows: fix duplicate case build error (Ben Noordhuis)

* windows: remove unneeded check (Saúl Ibarra Corretgé)

* include: document pipe path truncation behavior (Ben Noordhuis)

* fsevents: increase stack size for OSX 10.9 (Fedor Indutny)

* windows: _snprintf expected wrong parameter type in string (Maks
  Naumov)

* windows: "else" keyword is missing (Maks Naumov)

* windows: incorrect check for SOCKET_ERROR (Maks Naumov)

* windows: add stdlib.h to satisfy reference to abort (Sean Farrell)

* build: fix check target for mingw (Sean Farrell)

* unix: move uv_shutdown() assertion (Keno Fischer)

* darwin: avoid calling GetCurrentProcess (Fedor Indutny)
2013-10-29 14:58:57 -07:00
Fedor Indutny
ab0225277b Merge branch 'v0.10'
Conflicts:
	src/unix/darwin-proctitle.c
	src/version.c
2013-10-28 20:59:10 +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
Keno Fischer
fb36c09966 unix: move uv_shutdown() assertion
Allows uv_shutdown() to return an error as intended if the stream has
already been closed.

Fixes #972, refs JuliaLang/julia#4229.
2013-10-27 11:39:23 +01:00
Sean Farrell
63cd99eddc windows: add stdlib.h to satisfy reference to abort 2013-10-25 13:01:06 +02:00
Maks Naumov
d170c915c9 windows: incorrect check for SOCKET_ERROR 2013-10-24 17:46:21 +02:00
Maks Naumov
1ab3e3f1dd windows: "else" keyword is missing 2013-10-24 17:46:21 +02:00
Maks Naumov
68795b7d6f windows: _snprintf expected wrong parameter type in string 2013-10-24 17:46:21 +02:00
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
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
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
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