Commit Graph

47 Commits

Author SHA1 Message Date
Ben Noordhuis
c76c2066c6 unix, windows: add semaphore functions 2012-06-03 04:04:05 +02:00
Ben Noordhuis
c9396dd57e unix: implement timers in libuv
* replace libev backed timers with a pure libuv implementation
* gut ev_run() and make it take a timeout instead of flags

Incidentally speeds up the loop_count_timed benchmark by about 100%.
2012-05-31 03:08:34 +02:00
Ben Noordhuis
58a272e556 unix: rework pending handle/req logic 2012-05-30 00:08:22 +02:00
Ben Noordhuis
793a52f5df unix: pack uv structs more
Try to avoid alignment holes on x86_64. Shaves off 4-8 bytes from most structs.
2012-05-24 16:04:01 +02:00
Ben Noordhuis
890d443558 unix: shave about 100 bytes off uv_udp_send_t 2012-05-23 23:21:08 +02:00
Ben Noordhuis
e71495c84a unix: turn field stream->blocking into a flag
Saves 4 bytes.
2012-05-23 22:48:57 +02:00
Ben Noordhuis
5b9c45120a unix: fold uv__io_cb into ev_io struct
Makes the uv__io code a little more obscure but has the advantage that
sizeof(uv__io_t) == sizeof(ev_io), i.e. the sizes of embedding handles
don't change.
2012-05-23 03:57:08 +02:00
Ben Noordhuis
3bc9707054 unix: replace ev_io with uv__io_t
Replace ev_io usage with wrapper constructs.

This is preliminary work for the transition to a libev-less linux backend.
2012-05-23 03:42:32 +02:00
Bert Belder
d1665792ca Get rid of UV_HANDLE_TYPE_PRIVATE 2012-05-22 16:11:24 +02:00
Bert Belder
c06edd4c88 windows, unix: share c-ares glue code 2012-05-22 16:11:22 +02:00
Ben Noordhuis
80b554129b unix: reactive new idle watcher implementation
The new idle watcher was temporarily disabled in 073a48d due to some semantic
incompatibilities with the previous implementation. This commit resolves those
issues and reactivates the new implementation.

One outstanding bug is that idle watchers can run in a different order
(relative to other handle types) than the old implementation, e.g. (timer, idle)
instead of the expected (idle, timer). This will be fixed in an upcoming commit.
2012-05-22 15:13:52 +02:00
Frank Denis
d27a62deff unix: fix build on dragonfly bsd
Unbreak compilation on Dragonfly BSD, that uses kqueue, too.
2012-05-21 15:44:20 +02:00
Ben Noordhuis
073a48d6bf unix: back out new idle watcher for now
Its semantics don't quite match what node.js expects. This breaks the
stdio_over_pipes and shutdown_close_pipe tests but that can't be helped.
2012-05-18 01:19:56 +02:00
Ben Noordhuis
9efa8b3571 unix, windows: rework reference counting scheme
This commit changes how the event loop determines if it needs to stay alive.

Previously, an internal counter was increased whenever a handle got created
and decreased again when the handle was closed.

While conceptually simple, it turned out hard to work with: you often want
to keep the event loop alive only if the handle is actually doing something.
Stopped or inactive handles were a frequent source of hanging event loops.

That's why this commit changes the reference counting scheme to a model where
a handle only references the event loop when it's active. 'Active' means
different things for different handle types, e.g.:

 * timers: ticking
 * sockets: reading, writing or listening
 * processes: always active (for now, subject to change)
 * idle, check, prepare: only active when started

This commit also changes how the uv_ref() and uv_unref() functions work: they
now operate on the level of individual handles, not the whole event loop.

The Windows implementation was done by Bert Belder.
2012-05-17 07:07:53 +02:00
Ben Noordhuis
b5f9bc861f sunos: make fs.watch scale better
Instead of using one port per watch, use one port for all the watches.
This is a cherry-pick of commit 7326962 from v0.6 into master.

Conflicts:

	include/uv-private/uv-unix.h
	src/unix/core.c
	src/unix/sunos.c
2012-05-05 00:51:32 +00:00
Ben Noordhuis
5d19aa84f0 unix, win: rework uv_dlopen() API 2012-05-03 19:36:40 +02:00
Bert Belder
b9504f7987 Rename uv_platform_socket_t to uv_os_sock_t 2012-05-03 16:05:05 +02:00
Bert Belder
d60d94e0c3 Unix: implement uv_poll 2012-05-03 15:52:56 +02:00
Bert Belder
99a995a6b8 uv_spawn: support setting the child process' user and group id 2012-04-28 02:38:41 +02:00
Ben Noordhuis
3c415975d9 unix: don't conditionally compile kqueue fs watcher
Always compile in the kqueue-based fs event watcher and handle it at run-time
if the kernel doesn't actually support it.

Works around build issues when -mmacosx-version-min is not set properly.

Fixes joyent/node#3075.
2012-04-10 23:22:32 +02:00
Bert Belder
5f38ba1a89 Move private req and handle fields to platform headers
And fix other problems introduced with UV_HANDLE_TYPE_MAP and UV_REQ_TYPE_MAP.
2012-04-05 01:28:24 +02:00
Ben Noordhuis
ed395e0619 unix: replace handle->next_watcher
Remove the next_watcher and replace it with a linked list. Said list is named
endgame_handles (because the uv-win calls it that) and contains all the handles
that are in the UV_CLOSING state.

The goal of this commit is two-fold:

a) remove a dependency on libev, and
b) share more code with uv-win in the future

A nice side effect is that it shaves a few bytes off a uv_handle_t.
2012-04-04 05:22:20 -07:00
Ben Noordhuis
8895c9e672 unix: use uv_timer_t for c-ares' timeout timer 2012-04-03 03:23:57 +02:00
Ben Noordhuis
42095c85a0 Remove UV_ARES_TASK_PRIVATE_FIELDS.
It's only used internally, it doesn't have to be part of a public header file.
2012-04-03 02:44:50 +02:00
Ben Noordhuis
ef47a627ad unix: move libeio specific fields to uv-unix.h 2012-03-21 02:11:18 +01:00
Ben Noordhuis
d3efefb043 linux: share inotify fd across event loop
Previously, a new inotify fd was created for each watcher, making it quite easy
to run into the system-wide fs.inotify.max_user_instances limit (usually 128).

Fixes #300.
2012-02-23 09:21:30 -08:00
Ben Noordhuis
c5aa86bd39 Remove uv_import() and uv_export().
Not needed anymore now that support for isolates has been removed from Node.

This commit reverts the following commits:

  812e410 test: fix up stream import/export test
  e34dc13 unix: implement uv_import() and uv_export()
  d1a0e8e test: fix undefined macro error
  2ce0058 import/export streams accross loops
2012-02-12 15:49:54 +01:00
Ben Noordhuis
e34dc13496 unix: implement uv_import() and uv_export() 2012-01-30 21:44:47 +01:00
Igor Zinkovsky
2ce0058251 import/export streams accross loops 2012-01-30 21:44:27 +01:00
Ben Noordhuis
85f6b7952b Fix Windows build, uv_eio_channel is Unix only. 2011-12-28 14:42:46 +01:00
Ben Noordhuis
69ce0145f6 Wrap platform "thread-safe run once" APIs. 2011-12-20 20:34:55 +01:00
Ben Noordhuis
8e4ed88bbe Wrap platform thread APIs. 2011-11-21 21:04:16 +01:00
Ben Noordhuis
1fc1f28093 Wrap platform mutex and rwlock APIs.
Read/write locks are emulated with critical sections on Windows XP and Vista
because those platforms don't have a (complete) native read/write lock API.
2011-11-18 12:42:08 +01:00
Ben Noordhuis
224584c53e sunos: check that event ports supports fs watching 2011-11-10 20:04:55 +01:00
Bert Belder
90e15f1110 Implement uv_dlopen and friends 2011-10-29 00:52:34 +02:00
Ben Noordhuis
3e4af533ae sunos: implement file watcher API 2011-10-26 03:49:34 +00:00
Ryan Dahl
5656e3c8bd Prepare for writable TTY to be blocking 2011-10-10 13:25:46 -07:00
Ryan Dahl
bb6b629e6a make test-ipc accept the pending tcp server 2011-10-06 10:17:18 -07:00
Ben Noordhuis
8e9a3384c9 unix: implement kqueue file watcher API
kqueue fds are not embeddable into other pollsets (select, poll, kqueue).
Hack the libev event loop to receive kqueue events with filter flags intact.
2011-10-04 23:28:36 +02:00
Ryan Dahl
153d3c7c57 unix: allow tty raw mode to be turned off 2011-09-30 11:21:51 -07:00
Igor Zinkovsky
a1f98d55b1 fix c-ares on windows 2011-09-27 16:09:57 -07:00
Ben Noordhuis
3368d6c1a2 unix: stub file watcher implementation
The file watcher API has not been implemented on all Unices yet.
Provide stubs on those platforms so libuv at least compiles.
2011-09-22 23:55:05 +02:00
Ben Noordhuis
2a1c32a60c linux: implement file watcher API 2011-09-21 13:23:49 -07:00
Ben Noordhuis
bca49960fb unix: handle stream write errors properly
1. Ensure that failed writes don't leave the write queue in an inconsistent
   state. Before, write requests were handed back to the user but were not
   removed from the write queue. The cause of at least one use-after-free bug.

2. Pass the error to the callback on the next iteration of the event loop
   instead of returning it immediately.
2011-09-14 04:16:45 +02:00
Ryan Dahl
4484d61fe1 Add interfaces for uv_pipe_open, uv_tty_init, uv_tty_set_mode
Nothing works - no tests. This is just to coordinate efforts between Bert
and I.
2011-09-12 14:32:14 -07:00
Ben Noordhuis
52eca75152 unix: uv_pipe_t should not depend on UV_TCP_PRIVATE_FIELDS 2011-09-10 01:39:46 +02:00
Ryan Dahl
b47c474cfd Move private headers into include/uv-private 2011-08-31 00:43:55 -07:00