Finalization of closed handles and associated requests was sometimes delayed
until an external event (network I/O, timeout, etc.) happened. This commit
addresses that.
* 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%.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
libuv uses feature checks to determine if newer syscalls like pipe2() are
available. This works fine until someone compiles libuv against kernel headers
that are newer than the actual kernel our software runs on.
Fall back to traditional (but race-y!) syscalls when the kernel reports ENOSYS
or EINVAL.
If the uv_getaddrinfo_t handle is owned by its
data pointer, deleting the data in the callback
could cause uv_getaddrinfo_done to call freeaddrinfo
on an invalid pointer.
This patch also fixes#155. Since we no longer
memset clear the uv_getaddrinfo_t, the user can
now set the `uv_getaddrinfo_t->data` field without
problems.