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.
Fixes a bug where timers expire prematurely when the following
conditions hold:
a) libuv first spends some time blocked in the platform poll function
b) a callback then calls uv_timer_start()
Cause: uv_timer_start() uses an out-of-date loop->time in its
'when should the timer callback run?' calculations.
Solution: Update loop->time before invoking any callbacks.
Fixes#678.
This commit renames the various uv_hrtime() implementations to uv__hrtime().
Libuv uses the high-res timer internally in performance-critical code paths.
Calling the non-public version avoids going through the PLT when libuv is
compiled as a shared object.
The exported uv_hrtime() now has a single definition in src/unix/core.c that
calls uv__hrtime().
A future optimization is to lift the uv__hrtime() declarations into header
files so they can be inlined at the call sites. Then again, linking with -flto
should accomplish the same thing.
File descriptor might be closed during callback, all events that was reported
before the callback are not valid and trying to remove them will result
in ENOENT. This error can be safely ignored.
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.
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.
Fixesjoyent/node#3075.