Commit graph

26 commits

Author SHA1 Message Date
Lennart Poettering 1b5995b039 event: make sure to possibly disarm the timerfds before we reenter epoll_wait 2013-11-20 20:58:17 +01:00
Lennart Poettering c57b5ca301 event: don't disarm invalid timerfd 2013-11-20 20:58:17 +01:00
Lennart Poettering 2576a19ed2 event: whenever a time source changes pending state reshuffle elapsation prioqs 2013-11-20 20:58:17 +01:00
Lennart Poettering 503f39c35e event: when we change the io events to watch we need to figure out if a an event is pending again 2013-11-20 20:58:17 +01:00
Lennart Poettering a99badf5ed sd-event: fix comparison functions 2013-11-20 20:58:17 +01:00
Lennart Poettering 718db96199 core: convert PID 1 to libsystemd-bus
This patch converts PID 1 to libsystemd-bus and thus drops the
dependency on libdbus. The only remaining code using libdbus is a test
case that validates our bus marshalling against libdbus' marshalling,
and this dependency can be turned off.

This patch also adds a couple of things to libsystem-bus, that are
necessary to make the port work:

- Synthesizing of "Disconnected" messages when bus connections are
  severed.

- Support for attaching multiple vtables for the same interface on the
  same path.

This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus
calls which used an inappropriate signature.

As a side effect we will now generate PropertiesChanged messages which
carry property contents, rather than just invalidation information.
2013-11-20 20:52:36 +01:00
David Herrmann 0cc1125ae1 event: clear pending-state when re-arming timers
If a timer fires and is marked pending, but an application re-arms it
before it is dispatched, we now clear the pending state.

This fixes a bug where an application arms a timer, which fires and is
marked pending. But before it is dispatched, the application loses
interest in it and disables it. Now if the timer is re-armed and
re-enabled later, it will be immediately dispatched as it is still marked
pending.

This behavior is unexpected, so avoid it by clearing pending state when
re-arming timers. Note that applications have no way to clear pending
state themselves, so there's no current workaround.
2013-11-20 16:19:58 +01:00
Lennart Poettering 76b543756e bus: introduce concept of a default bus for each thread and make use of it everywhere
We want to emphasize bus connections as per-thread communication
primitives, hence introduce a concept of a per-thread default bus, and
make use of it everywhere.
2013-11-12 00:12:43 +01:00
Lennart Poettering afc6adb5ec bus: introduce concept of a "default" event loop per-thread and make use of it everywhere
Try to emphasize a bit that there should be a mapping between event
loops and threads, hence introduce a logic that there's one "default"
event loop for each thread, that can be queried via
"sd_event_default()".
2013-11-12 00:12:43 +01:00
Lennart Poettering b7484e2a58 event: make sure we keep a reference to all events we dispatch while we do so. 2013-11-07 00:13:58 +01:00
Zbigniew Jędrzejewski-Szmek f7262a9f28 bus: add public libsystemd-event 2013-11-06 14:56:47 -05:00
David Strauss 9ec9694ce3 sd-event: EPOLLONESHOT only disables event reporting after an event. The fd is still registered. 2013-10-21 17:23:01 -07:00
Dave Reisner fe8245eb3c sd-event: initialize return value
src/libsystemd-bus/sd-event.c:1597:13: warning: 'r' may be used
uninitialized in this function [-Wmaybe-uninitialized]
2013-10-17 16:19:48 -04:00
Lennart Poettering d09d5ecda2 event: handle arbitrary signals received during epoll gracefully 2013-10-16 06:15:00 +02:00
Lennart Poettering 72aedc1e80 event: properly disarm timers when we don't need them anymore 2013-10-16 06:15:00 +02:00
Lennart Poettering e471512768 event: fix sd_event_source_set_io_events() 2013-10-16 06:15:00 +02:00
Zbigniew Jędrzejewski-Szmek 0eb2e0e340 event: avoid derefencing null pointer 2013-10-13 17:56:55 -04:00
Lennart Poettering 46e8c8257f event: add apis to query the timestamp of the event currently processed 2013-10-11 04:36:02 +02:00
Lennart Poettering 305f78bff3 event: move all library calls over to new assert_return() macro 2013-10-11 02:11:30 +02:00
Lennart Poettering 4bee801296 event: add sd_event_source_get_child_pid() call to query the PID of a child event source 2013-10-11 01:33:25 +02:00
Lennart Poettering baf7628332 event: rename the "mute" field of event sources to "enabled"
In addition, the states "UNMUTED" and "MUTED" become "ON" and "OFF".

This has the benefit that a possible value of this field is not
identical to its name, thus minimizing confusion.
2013-10-11 01:08:15 +02:00
Lennart Poettering da7e457c5b event: implement quit handlers
Quit handlers are executed when an event loop is terminated via
sd_event_request_quit(). They are in a way atexit() handlers that are
executed in a well-defined environment, time and thread: from the event
loop thread when the event loop finishes.
2013-10-11 00:49:11 +02:00
Lennart Poettering eaa3cbef3b event: refuse operation if the caller tries to reuse an event loop after a fork() 2013-10-10 21:37:50 +02:00
Lennart Poettering c2ba3ad660 event: add timer accuracy/coalescing logic
In order to improve energy consumption we should minimize our wake-ups
when handling timers.  Hence, for each timer take an accuracy value and
schedule the actual wake-up time somewhere between the specified time
and the specified timer plus the accuracy.

The specified time of timer event sources hence becomes the time the
handler is called the *earliest*, and the specified time plus the accuracy
the time by which it is called the *latest*, leaving the library the
freedom to schedule the wake-up somewhere inbetween.

If the accuracy is specified as 0 the default of 250ms will be used.

When scheduling timeouts we will now try to elapse them at the same
point within each second, across the entire system. We do this by using
a fixed perturbation value keyed off the boot id. If this point within a
second is not in the acceptable range, we try again with a fixed time
within each 250ms time step. If that doesn't work either, we wake up at
the last possible time.
2013-10-10 21:22:59 +02:00
Tero Roponen dfcd88f634 bus: fix duplicate comparisons
Testing for y > x is the same as testing for x < y.
2013-10-10 18:37:48 +02:00
Lennart Poettering fd38203a2a bus: add minimal event loop API
So far we tried to use epoll directly wherever we needed an event loop.
However, that has various shortcomings, such as the inability to handle
larger amounts of timers (since each timerfd costs one fd, which is a
very limited resource, usually bounded to 1024), and inability to do
priorisation between multiple queued events.

Let's add a minimal event loop API around epoll that is suitable for
implementation of our own daemons and maybe one day can become public
API for those who desire it.

This loop is part of libsystemd-bus, but may be used independently of
it.
2013-10-10 04:44:48 +02:00