Age | Commit message (Collapse) | Author | Files | Lines |
|
Restructure eloop code. This puts stuff more closely together if it is
related.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Similar to other event sources we now initialize internal data on timer
creation instead of when the source is added to the loop.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
When creating a new fd-source you must supply the file descriptor
directly. You cannot delay this to the time when you add the fd to the
event loop.
This simplifies the logic and allows much smoother handling in the event
loop core.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Counter sources are based on the eventfd syscall of linux. Internally, is
uses a 64bit counter which is initialized to 0 and can be increased by the
caller. Whenever the value is non-zero, the fd is marked readable and we
call our callback. We read the 64bit integer (which resets it to 0) and
pass the current value to the callback.
This can be used to implement cross-process notification methods or to
have idle-sources as valid file-descriptors in an epoll set which could be
exported to other applications that are not compliant to our event loop.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
This helper returns true if the fd is bound to an eloop object, otherwise
false is returned.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Sometimes one wants to remove all pending events for an fd. The new
ev_eloop_flush_fd() call allows this in a safe way.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
A shared signal owns an eloop_fd object. This has a reference of its
connected eloop. Therefore, we must free a shared signal to drop a
reference to the connected eloop and cannot postpone this to
eloop-destruction. Otherwise, the eloop will never get destroyed.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Move to new list-implementation instead of the single-linked list. This
allows removal of elements in O(1).
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Move child-waiting into the eloop subsystem so all childs are always
correctly freed.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Remove the old non-shared signal sources in favor of shared-signals.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
pthread is already in our vmem due to our dependencies so link to it
explicitly and use pthread_sigmask to avoid buggy sigprocmask in
multi-threaded applications.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Our current signal source has the problem that a single signal event is
only delivered to one random registered source. This is the design of the
signalfd kernel feature. However, for signals like SIGCHLD it is often
desired to have multiple callbacks. Hence, while keeping the old
signal-source, we now also allow a shared signal source. It is registered
the same way as the old signal source but uses a shared hook.
We may remove the old source so we don't use it in the new implementation.
There are still problems when multiple eloops are used in a single
process and you register the same shared-signum in both eloops. However,
such a design is bad anyway, so we don't care.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
epoll_wait() returns EINTR even if using SA_RESTART for signals.
Therefore, catch EINTR and set count to zero.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
eloop.c and log.c use struct timeval to calculate time-diffs but
incorrectly use "-" instead of "+" as the value is already negative.
They also use unsigned integers so fix both occurences.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
When exiting a child eloop we should forward the exit to the parent. Also,
we should reset ->exit on ev_eloop_run() otherwise we cannot run multiple
times.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Add two debug messages to track eloop behavior.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
ev_eloop_run() runs the eloop for a given fixed time. If the dispatcher
returns and the timeout isn't reached, then the dispatcher is called
again.
This also adds the *_exit() function which allows to exit the main-loop
and can be called from anywhere (including the callbacks).
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Fix parameter validation, fix log_* statements, fix indentation and print
messages on HUP/ERR.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
If a handler does not correctly remove itself on HUP, the epoll-loop will
never sleep again because the fd will always be notified as HUP.
Therefore, remove the fd from the epoll-set directly on HUP. This doesn't
change application behavior so it is safe here.
This also allows other subsystems to ignore HUP/ERR events if they are not
fatal. The FD won't be readded but that may not bother.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
This function was never used so remove it.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
This allows to add one eloop object into another eloop. This is useful if
we want to run a single event source isolated (for instance VT on exit).
The internal epoll-descriptor allows polling so this is a fairly
straightforward implementation.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We don't need the long kmscon_ prefix so make it shorter.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Add support for dispatching events every given interval. timerfd is used
for hooking up to the event loop, similar to how signalfd is used.
Only relative, monotonic and possibly repeating timer events are
supported. It can be enhanced if there's ever a need.
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
log_warn is much shorter and we already use log_err instead of log_error
so this is more consistent now.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
These dispatch debug messages are currently no longer needed and just
fill the log needlessly.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Add KMSCON_ERR, the equivalent of EPOLLERR.
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Add some more debug statements to allow easier eloop monitoring.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
fd-callbacks are pretty useless if we do not pass a mask argument with the
current flags.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Idle events are dispatched everytime kmscon_eloop_dispatch() is called. To allow
the callbacks to add/remove/modify all current idle events (including themself),
we need to keep a pointer to the currently dispatched event.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Add event loop implementation with support for fd's and signal's through
signalfd.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|