Commit Graph

88 Commits

Author SHA1 Message Date
Ben Noordhuis
58a272e556 unix: rework pending handle/req logic 2012-05-30 00:08:22 +02:00
Ben Noordhuis
4690204682 unix: fix getaddrinfo bad pointer deref 2012-05-29 00:06:11 +02:00
Bert Belder
e4f23aacec Get rid of UV_LEAN_AND_MEAN 2012-05-28 01:53:22 +02:00
isaacs
604802ad47 Fix sunos build: undeclared variable 'handle' 2012-05-24 23:00:31 +02:00
Ben Noordhuis
752ac30ec8 unix: don't pass sockaddr to accept()
Shaves a few nanoseconds off the accept() syscall.
2012-05-24 14:31:53 +02:00
Ben Noordhuis
5fd2c406f1 unix: fix up asserts in core.c and stream.c 2012-05-23 22:19:12 +02:00
Ben Noordhuis
7c8313bd0f unix, windows: make uv_run_once() return a bool
The return value of uv_run_once() now signals if it needs to be called again.

Fixes #427.
2012-05-23 20:49:03 +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
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
Ben Noordhuis
6fd9bfb7b0 unix: fix event loop block, prepare/check invoke
Don't block in epoll_wait() / kevent() / etc. syscall unless there are active
handles. If there are only active requests, do a non-blocking poll.

Likewise, don't run the prepare and check watchers unless there are active
handles *or* requests.
2012-05-21 17:41:52 +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
Frank Denis
07622e767d unix: change #if FIONBIO to #ifdef FIONBIO
Fixes compilation on Debian/ppc 6.0.4.
2012-05-16 16:59:42 +02:00
Bert Belder
d60d94e0c3 Unix: implement uv_poll 2012-05-03 15:52:56 +02:00
Ben Noordhuis
ab3b307df3 unix: clean up uv__req_init() 2012-04-18 22:30:20 +02:00
Ben Noordhuis
edb39b2499 const-ify handle argument to uv_is_closing() 2012-04-18 03:11:25 +02:00
Ben Noordhuis
fb6c9eef2a const-ify handle argument to uv_is_active() 2012-04-18 03:09:53 +02:00
Ben Noordhuis
68bed698fc unix: move loop init logic out of core.c 2012-04-04 05:54:39 -07:00
Ben Noordhuis
5a8446c309 unix: move handle specific close logic out of core.c 2012-04-04 05:30:15 -07: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
5fbe0aab33 unix: move active checks out of core.c
Move active checks out of core.c and into their respective compilation units:
check, idle, prepare, timer.
2012-04-04 06:52:29 +02:00
Ben Noordhuis
5a59e4924a unix: move idle code from core.c to idle.c 2012-04-04 05:25:34 +02:00
Ben Noordhuis
dd31265751 unix: move check code from core.c to check.c 2012-04-04 05:25:34 +02:00
Ben Noordhuis
f1a19e6d34 unix: move prepare code from core.c to prepare.c 2012-04-04 05:25:34 +02:00
Ben Noordhuis
f7359a335c unix: move async code from core.c to async.c 2012-04-04 05:25:34 +02:00
Ben Noordhuis
fd987a26fe unix: move timer code from core.c to timer.c 2012-04-04 05:25:27 +02:00
Vladimir Dronnikov
b309f2e2e6 Add uv_is_closing()
Closes #367.
2012-04-01 21:05:50 +02:00
Ben Noordhuis
685b36ba66 linux: tidy up syscall code 2012-03-31 00:19:01 +00:00
Ben Noordhuis
4ff0898c5f unix: replace uv__close() with close()
uv__close() was deprecated a while ago. It's been an alias for close() ever
since. Remove it.
2012-03-21 02:11:18 +01:00
Ben Noordhuis
dfda5009c2 unix, win: store ares handles in a binary tree
Store the uv_ares_task_t handles in a red-black tree, not a linked list.

Fixes #72.
2012-03-16 00:49:29 +01:00
Ben Noordhuis
2f886c892e unix: don't rely on libev to track timer state
An obscure libev bug sometimes makes it miss state changes. Keep track of the
state ourselves.

Fixes joyent/node#2515.
2012-02-28 17:24:50 +01:00
Ben Noordhuis
ec0eff955e Revert b3e0ad4, 149d32c, e99fdf0 and ea9baef.
Detaching doesn't work yet, the setsid() call fails and leaves the child process
attached to the parent's session.

Revert "test: Add test case for spawning detached child processes."
Revert "win: Implement options.detached for uv_spawn() for Windows."
Revert "unix: Implement options.detached for uv_spawn() for unix."
Revert "Add "detached" member to uv_process_options_t to denote whether a child
        process should spawn detached from its parent."

This reverts commit ea9baef95c.
This reverts commit e99fdf0df6.
This reverts commit 149d32cb96.
This reverts commit b3e0ad4db8.
2012-02-28 15:29:05 +01:00
Charlie McConnell
149d32cb96 unix: Implement options.detached for uv_spawn() for unix. 2012-02-24 15:15:00 +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
abdc3efffe unix: add uv__dup() 2012-01-30 21:44:27 +01:00
Ben Noordhuis
28b0867f03 unix: clean up udp shutdown sequence 2012-01-18 20:18:57 +01:00
Ben Noordhuis
ee10cb77bd unix: use container_of() instead of w->data 2012-01-18 19:34:22 +01:00
Ben Noordhuis
dee86dd5b0 unix: don't retry close() on EINTR
Linux 2.6 always closes the file descriptor, even on EINTR. Retrying the close()
call isn't merely useless, it's actively harmful - the file descriptor may have
been acquired by another thread.
2012-01-18 15:06:30 +01:00
Ben Noordhuis
71f6c0edb8 Merge remote-tracking branch 'origin/v0.6'
Conflicts:
	src/win/util.c
2012-01-16 18:07:49 +01:00
Ben Noordhuis
6d9c9a533f Add uv_loop_refcount() function, debug tool. 2012-01-14 00:33:08 +01:00
Ben Noordhuis
a13584bec7 unix: remove unused #define 2012-01-13 15:59:53 +01:00
Daisuke Murase
e8494dddc0 unix: use EVRUN_ONCE in uv_run_once()
EVRUN_NOWAIT means "poll and don't block". Use EVRUN_ONCE instead, "wait for
single event".
2012-01-11 10:15:25 +01:00
Paddy Byers
abf9654a55 unix: create separate eio result queue per loop
Makes the eio "done" callback run in the thread that submitted it. Makes it safe
to use libeio from multiple event loops.
2011-12-20 20:47:33 +01:00
Ben Noordhuis
10de090b9e unix: centralize loop init logic
Also fixes a bug where loops other than the main loop didn't pick the kqueue
backend, which broke the fs event watcher on Darwin and the BSDs.
2011-12-20 20:47:33 +01:00
Ben Noordhuis
6b3075cd73 linux: improve kernel feature detection
Do not check for minimum kernel and glibc versions, just check that the kernel
headers export the syscall number and invoke the syscall directly. Effectively
bypasses glibc.
2011-12-16 15:16:31 +01:00
mattn
e53cecb8c0 add uv_run_once() 2011-12-14 14:28:35 +01:00
Ben Noordhuis
4c6008f488 Merge branch 'v0.6'
Conflicts:
	test/test-list.h
2011-12-12 18:04:17 +01:00
Shigeki Ohtsu
ba52023ef3 Fix missing increments of loop->counters 2011-12-12 18:01:26 +01:00
Ben Noordhuis
0d8cb08f83 Merge branch 'v0.6' 2011-12-08 16:31:52 +01:00