Commit Graph

15 Commits

Author SHA1 Message Date
Ben Noordhuis
837edf4c0f unix, windows: remove handle init counters
Remove the handle init counters, no one uses them.
2012-08-10 02:00:11 +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
1f001fe917 unix: remove kqueue cb == NULL check
The other implementations don't check for it and it's making the counters_init
test fail.
2012-04-23 17:55:57 +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
Ben Noordhuis
5a8446c309 unix: move handle specific close logic out of core.c 2012-04-04 05:30:15 -07: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
0459097745 unix: fix fs_event refcount bug on darwin
The event loop got unref'd twice when the handle was closed.
2012-02-29 15:55:54 +01:00
Ben Noordhuis
cdb44df86d unix: add UNREACHABLE() macro
Asserts and aborts when program flow reaches a place it shouldn't.
2012-01-30 21:44:27 +01:00
Ben Noordhuis
c89a75f5a2 unix: fix compiler warning in kqueue.c, tcp.c, udp.c
Include <unistd.h>, it contains the definition of close().
2011-09-28 00:57:20 +02:00
Ben Noordhuis
38fc6ad839 unix: unref fs event watcher
Watchers were being ref-counted twice which wasn't harmful in itself but stopped
uv_unref() from working like you'd expect it to.
2012-01-02 10:42:27 +01:00
Shigeki Ohtsu
ba52023ef3 Fix missing increments of loop->counters 2011-12-12 18:01:26 +01:00
Ben Noordhuis
2bd181a8d2 unix: properly disarm kqueue fs watcher
Fixes "Assertion failed: (revents == EV_LIBUV_KQUEUE_HACK),
function uv__fs_event, file ../src/unix/kqueue.c, line 58."
2011-11-18 01:40:11 +01:00
Bert Belder
1997e10b50 Add flags to uv_fs_event_init 2011-11-05 01:42:08 +01:00
Ben Noordhuis
47d22acfb2 unix: stub kqueue support functions on old platforms 2011-10-11 16:53:42 +02: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