68 Commits

Author SHA1 Message Date
David Herrmann
42631efa2c eloop: add debug messages
Add two debug messages to track eloop behavior.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 17:57:53 +01:00
David Herrmann
205ab68ff9 eloop: add ev_eloop_run() function
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>
2012-03-23 17:32:45 +01:00
David Herrmann
14b0035f50 eloop: several fixes
Fix parameter validation, fix log_* statements, fix indentation and print
messages on HUP/ERR.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 17:13:01 +01:00
David Herrmann
563492a0c8 eloop: remove fd from epoll-set on HUP
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>
2012-03-23 16:59:42 +01:00
David Herrmann
56659ce429 eloop: remove ev_eloop_get_fd()
This function was never used so remove it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 16:46:22 +01:00
David Herrmann
be8fe301f9 eloop: allow an eloop to be an event source
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>
2012-03-23 16:10:53 +01:00
David Herrmann
e7e0744e6e eloop: rename from kmscon_ to ev_
We don't need the long kmscon_ prefix so make it shorter.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 19:01:28 +01:00
Ran Benita
fb14273bf7 eloop: add timer support
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>
2012-02-01 22:35:54 +01:00
David Herrmann
bd09f38a4d log: move log_warning to log_warn
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>
2012-01-24 15:29:55 +01:00
David Herrmann
4d34890cde eloop: remove verbose debug messages
These dispatch debug messages are currently no longer needed and just
fill the log needlessly.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-24 15:10:16 +01:00
Ran Benita
e823d283c5 eloop: allow reporting error conditions
Add KMSCON_ERR, the equivalent of EPOLLERR.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-11 13:28:12 +01:00
Ran Benita
0d0cac0ad1 Fix compiler sign-mismatch warnings
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-09 20:20:58 +01:00
Ran Benita
58b9f1fdb6 a few cosmetic changes
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-09 20:20:58 +01:00
David Herrmann
39b3cc1237 Eloop: Fix function name typo
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-03 16:38:14 +01:00
David Herrmann
7fa1ab55dd Eloop: Add debug statements
Add some more debug statements to allow easier eloop monitoring.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-03 15:09:10 +01:00
David Herrmann
1fb4c71895 Eloop: Pass mask argument to fd callbacks
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>
2011-12-03 12:22:36 +01:00
David Herrmann
42a6c76e28 Eloop: Add idle-event support
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>
2011-12-03 12:04:29 +01:00
David Herrmann
fe5b180fbb Add event loop
Add event loop implementation with support for fd's and signal's through
signalfd.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-03 11:42:41 +01:00