Commit Graph

2102 Commits

Author SHA1 Message Date
Saúl Ibarra Corretgé
ae2b30a48f windows: initialize stop_flag explicitly
The default loop lives in the bss section so it's zeroed on startup
but loops created with uv_loop_new() live on the heap and contain
random garbage. Initialize the stop_flag explicitly to avoid spurious
bugs.
2013-02-26 15:26:27 +01:00
Timothy J Fontaine
72bbf5d702 test: don't rewind_cursor when using tap_output 2013-02-25 19:00:16 +01:00
Saúl Ibarra Corretgé
4b957482ba windows: fix uv_stop in ONCE and NOWAIT modes
Same as the fix in 492efb9 but this time for uv-win.
2013-02-25 18:26:58 +01:00
Ben Noordhuis
492efb95ff unix: make uv_stop work when embedded
* Make uv_stop() work when libuv is embedded in another event loop.

* Fix a small bug where loop->stop_flag was not reset when mode ==
  UV_RUN_ONCE or UV_RUN_NOWAIT. The next call to uv_run() would return
  immediately without doing any work.
2013-02-25 17:01:02 +01:00
Saúl Ibarra Corretgé
bb3d1e24da unix, windows: add uv_stop, stop running event loop 2013-02-25 16:21:37 +01:00
Saúl Ibarra Corretgé
79880121ce windows: align uv_run code with unix 2013-02-25 16:21:28 +01:00
Marc Schlaich
ce1a266c05 build: fix misleading vcbuild.bat error message 2013-02-25 16:01:55 +01:00
Ben Noordhuis
6ba6f4b4d6 build: turn on strict aliasing in release builds 2013-02-25 03:43:03 +01:00
Ben Noordhuis
39c8a90a91 unix: set errno in sendfile emulation
The sendfile emulation in src/unix/fs.c polls the file descriptor for
write readiness. If POLLERR or POLLHUP is set, it bails out but doesn't
set errno (hence it doesn't report a useful error code). Rectify that.

Fixes #620.
2013-02-25 03:22:11 +01:00
Ben Noordhuis
b04fc33ef7 linux: use eventfds for async handles
Use eventfds to drive async handles, fall back to regular pipes on older
kernels (pre-2.6.22).

Gives a nice boost on the async handle benchmarks. Before:

  12,516,113 async events in 5.0 seconds (2,503,222/s, 1,048,576 unique
  async1: 11.95 sec (83,701/sec)
  async2: 11.65 sec (85,862/sec)
  async4: 5.20 sec (192,154/sec)
  async8: 9.97 sec (100,315/sec)
  async_pummel_1: 1,000,000 callbacks in 2.56 seconds (389,919/sec)
  async_pummel_2: 1,000,000 callbacks in 2.65 seconds (377,205/sec)
  async_pummel_4: 1,000,000 callbacks in 2.18 seconds (457,704/sec)
  async_pummel_8: 1,000,000 callbacks in 4.19 seconds (238,632/sec)

After:

  16,168,081 async events in 5.0 seconds (3,233,616/s, 1,048,576 unique
  async1: 11.08 sec (90,213/sec)
  async2: 10.17 sec (98,297/sec)
  async4: 4.81 sec (207,789/sec)
  async8: 8.98 sec (111,419/sec)
  async_pummel_1: 1,000,000 callbacks in 1.16 seconds (863,296/sec)
  async_pummel_2: 1,000,000 callbacks in 1.45 seconds (691,459/sec)
  async_pummel_4: 1,000,000 callbacks in 0.66 seconds (1,514,770/sec)
  async_pummel_8: 1,000,000 callbacks in 1.42 seconds (704,549/sec)

That's a speedup from anywhere between 10% to 330%.
2013-02-25 02:55:24 +01:00
Ben Noordhuis
92151658eb unix: abstract away async pipe infrastructure
This commit lays the groundwork for the switch to eventfds on Linux.
2013-02-25 02:36:52 +01:00
Ben Noordhuis
e89aced8d6 darwin: implement uv_set_process_title, part 2
Make changes to the process title visible to tools like `ps`.

The argv clobber technique is reasonably portable across Unices;
the common code has been moved into src/unix/proctitle.c and is used
on Linux and OS X. Other platforms will probably follow in the future.
2013-02-24 03:56:02 +01:00
Ben Noordhuis
14eb8b0391 darwin: implement uv_set_process_title, part 1
Apply undocumented Carbon magic to change the process title in a way
that's visible in the Activity Monitor.
2013-02-24 03:54:02 +01:00
Ben Noordhuis
0761fb51b2 build: support 64 bits darwin builds
Before this commit, gyp built 32 bits versions of libuv exclusively.

Enable with:

  $ ./gyp_uv -Dtarget_arch=x64
2013-02-24 02:24:09 +01:00
Timothy J Fontaine
bfe269b8a0 test: add tap output
Given UV_TAP_OUTPUT being set, test result output should use TAP formatting
2013-02-22 23:06:17 +01:00
Ben Noordhuis
c98083ef26 unix: short-circuit on no-op io watcher changes
Don't add the io watcher to the watcher queue if the requested change
is effectively a no-op, that is, when the event mask doesn't change.

The exception here is sunos because the event ports backend requires
that watched file descriptors are re-added on every turn of the event
loop.

This commit is a micro-optimization, it does not change the event
loop's observable behavior in any way.
2013-02-22 17:02:05 +01:00
Ben Noordhuis
da0b84d4e8 unix: auto-unref spawn handle on process exit
Consistent, for better or worse, with uv-win.

Fixes #718.
2013-02-22 14:39:40 +01:00
Ben Noordhuis
3348cd7407 unix: handle EINPROGRESS for unix sockets
Before this commit, it was assumed that connect() on UNIX sockets never
returns EINPROGRESS. It turned out to be a bad assumption: Dave Pacheco
reports sporadic hangups on SmartOS because of that.

It's not clear to me _why_ the Illumos kernel returns that error but
that's inconsequential: whatever the cause, libuv needs to handle it
and now it does.

Fixes joyent/node#4785.
2013-02-21 23:21:29 +01:00
Ben Noordhuis
1d64c8284d unix: use uv__set_artificial_error in uv_write2
* Use uv__set_artificial_error(), slightly more efficient than
  uv__set_sys_error().

* Return UV_EINVAL instead of UV_EOPNOTSUPP.

* Fix up style.
2013-02-21 10:29:17 +01:00
Saúl Ibarra Corretgé
9a8db3c0cb unix: reduce line count, return uv__set_sys_error 2013-02-21 10:26:12 +01:00
Saúl Ibarra Corretgé
3f47a2da5c unix: fail early on bad send_handle in uv_write2
Return UV_EBADF if send_handle doesn't have a valid fd.
2013-02-21 10:25:20 +01:00
Ben Noordhuis
26fa6f8031 linux: fix abort() on epoll_ctl() race condition
Don't check the return value of epoll_ctl(EPOLL_CTL_DEL). When the
file descriptor is closed, we're potentially racing with another
thread and that means the errno is not a reliable indicator of
the actual error.

The other event mechanisms (kqueue, event ports) are not affected
because:

* kqueue returns either EBADF or ENOENT. Both are handled by libuv.
* event ports rearms all file descriptors on each call to port_getn().

Fixes joyent/node#4558.
2013-02-20 21:28:39 +01:00
Ben Noordhuis
fd24a69c52 build: fix shared-after-static build
Executing `make libuv.so` after `make libuv.a` failed because the
libuv.a target compiled the files in src/ without -fPIC.

Make the libuv.so target depend on files with a different suffix to
keep them separated.
2013-02-20 19:53:17 +01:00
Ben Noordhuis
7048a80613 doc: document _LARGEFILE_SOURCE + _FILE_OFFSET_BITS 2013-02-20 17:11:54 +01:00
Ben Noordhuis
30f6288347 unix, windows: make uv_timer_get_repeat() const correct 2013-02-20 17:01:00 +01:00
Ben Noordhuis
0cb9fbfe18 unix, windows: change timer intervals to uint64_t 2013-02-20 16:59:33 +01:00
Ben Noordhuis
d6bfedb862 unix, windows: make uv_now() return uint64_t
Using int64_t doesn't make sense here because the return value is never
negative.
2013-02-20 16:58:45 +01:00
Andrius Bentkus
6bf1a56e9d Return the errorcode provided by uv_set_artificial_error.
This reduces the line count.
2013-02-20 16:36:22 +01:00
Andrius Bentkus
7480974efe Adhere to the naming conventions in uv_timer_* functions.
In the src/*/timer.c code the first argument is called handle, not timer.
We should be consistent in the interface definition file.
2013-02-20 16:33:56 +01:00
Ben Noordhuis
b6f72e54c4 linux: fix O_CLOEXEC/O_NONBLOCK defines 2013-02-12 16:18:38 +01:00
Ben Noordhuis
da71649991 unix, windows: make uv_fs_t.statbuf public
Make the statbuf field public. This means you no longer have to use
req->ptr - though that still works and will continue to work for the
foreseeable future.

Fixes #704.
2013-02-10 17:50:03 +01:00
Shigeki Ohtsu
fadfeaf6ec unix,windows: fix timer order in case of same timeout
Compare start_id of timer handles when they have the same timeout.
start_id is allocated with loop->timer_counter in uv_timer_start.
2013-02-10 17:46:22 +01:00
Fedor Indutny
c15d4a7c62 stream: use kevent() information before accept()
Limit number of syscalls by using backlog length information provided by
kevent().
2013-02-09 00:54:08 +04:00
Ben Noordhuis
da33bba7c0 darwin: make uv_cond_timedwait() clock skew safe
Use pthread_cond_timedwait_relative_np() so we're not prone to spurious
bugs caused by clock skew.
2013-02-06 23:28:09 +01:00
Saúl Ibarra Corretgé
5fa690397a win: Avoid using subversion to download gyp 2013-02-06 23:03:09 +01:00
Ben Noordhuis
d5dd7d0758 darwin: merge uv_cond_timedwait implementation
This is a revised version of commit 8311390.
2013-02-06 20:38:21 +01:00
Ben Noordhuis
8d746ff72d unix: remove scandir prototype workaround in fs.c
It's not necessary for newer OS X releases and I don't care enough
about OpenBSD to squelch the warning.
2013-02-06 16:32:05 +01:00
Ben Noordhuis
60dd395a5b Revert "darwin: merge uv_cond_timedwait implementation"
Using mach_absolute_time() for the pthread_cond_timedwait() timeout
breaks a number of tests on OS X 10.8.2.

This reverts commit 8311390f13.
2013-02-06 16:09:07 +01:00
Ben Noordhuis
8311390f13 darwin: merge uv_cond_timedwait implementation
Merge the OS X specific implementation of uv_cond_timedwait() with the
generic one. The only difference is that it now uses mach_absolute_time
instead of gettimeofday.
2013-02-04 20:24:21 +01:00
Ben Noordhuis
b271b0686d build: fix up WIN_SRCS 2013-02-02 01:16:37 +01:00
Ben Noordhuis
7f3c783583 unix: don't clobber errno in signal handler 2013-01-31 15:28:16 +01:00
Bert Belder
3759d71269 win: get rid of early ipv6 support detection
No longer explictly check wheter an IPv6 stack is present when the user
tries to use IPV6 sockets. Instead realy on the operating system
to report the lack of protocol support via appropriate error messages.
2013-01-30 18:27:45 +01:00
Bert Belder
f21d94125e win/udp: DRY up setting SO_REUSEADDR
This patch makes sure that only uv_udp_set_socket sets the SO_REUSEADDR
bit for UDP sockets.
2013-01-30 18:27:44 +01:00
Bert Belder
3d779000b1 win/udp: fix bug in getsockopt() return value check 2013-01-30 18:27:44 +01:00
Bert Belder
4f54053517 win/udp: make uv_udp_set_socket set UV_HANDLE_IPV6
This patch makes uv_udp_set_socket responsible for setting the
UV_HANDLE_IPV6 flag. It also fixes the problem that uv_udp_open would
never set this flag at all.

In addition, this patch fixes some minor style issues.
2013-01-30 18:27:43 +01:00
Bert Belder
40c60cfc54 win/tcp: make uv_tcp_set_socket set UV_HANDLE_IPV6
This makes uv_tcp_set_socket responsible for setting the UV_HANDLE_IPV6
flag. This fixes a couple of situations where the the fact that a socket
is an IPv6 socket is not taken into account when deciding whether a call
to SetFileCompletionNotificationModes is appropriate.

It also fixes the issue that uv_tcp_open would never set this flag at
all.
2013-01-30 18:27:43 +01:00
Bert Belder
cfe14452ae win: fix uv_winsock_init crash when no IPv4 stack present
uv_winsock_init() tries to create an IPv4 socket in order to detect
if the system has any layered service providers (LSPs) installed.
When creating this socket failed it would call uv_fatal_error and exit
with the following message:

  socket: (10047) An address incompatible with the requested protocol was used.

This patch fixes that. It also includes some minor style tweaks.
2013-01-30 18:27:42 +01:00
Bert Belder
00503d6067 win: add error mappings related to unsupported protocols 2013-01-30 18:27:42 +01:00
Bert Belder
98c79f3e0d win: sort error code mappings 2013-01-30 18:27:41 +01:00
Ben Noordhuis
40a9e119ff build: fix up dependency rules
* Auto-create build subdirectories.

* Add coarse dependencies on header files so make rebuilds the sources
  whenever the headers change.
2013-01-29 17:07:41 +01:00