diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-12-12 22:21:25 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-12-13 04:06:43 +0100 |
commit | 6203e07a83214a55bb1f88508fcda2005c601dea (patch) | |
tree | 51112fe80de37b9f7cfd59f703fafdc624ae02d7 /src/libsystemd-bus/test-event.c | |
parent | 6e41a3e53d858f30e131c62350f51465558ca55c (diff) |
event: rework sd-event exit logic
With this change a failing event source handler will not cause the
entire event loop to fail. Instead, we just disable the specific event
source, log a message at debug level and go on.
This also introduces a new concept of "exit code" which can be stored in
the event loop and is returned by sd_event_loop(). We also rename "quit"
to "exit" everywhere else.
Altogether this should make things more robus and keep errors local
while still providing a way to return event loop errors in a clear way.
Diffstat (limited to 'src/libsystemd-bus/test-event.c')
-rw-r--r-- | src/libsystemd-bus/test-event.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsystemd-bus/test-event.c b/src/libsystemd-bus/test-event.c index 2b91eb0a73..5317008a87 100644 --- a/src/libsystemd-bus/test-event.c +++ b/src/libsystemd-bus/test-event.c @@ -63,7 +63,7 @@ static int child_handler(sd_event_source *s, const siginfo_t *si, void *userdata assert(userdata == INT_TO_PTR('f')); - assert_se(sd_event_request_quit(sd_event_source_get_event(s)) >= 0); + assert_se(sd_event_exit(sd_event_source_get_event(s), 0) >= 0); sd_event_source_unref(s); return 1; @@ -143,12 +143,12 @@ static int time_handler(sd_event_source *s, uint64_t usec, void *userdata) { return 2; } -static bool got_quit = false; +static bool got_exit = false; -static int quit_handler(sd_event_source *s, void *userdata) { +static int exit_handler(sd_event_source *s, void *userdata) { log_info("got quit handler on %c", PTR_TO_INT(userdata)); - got_quit = true; + got_exit = true; return 3; } @@ -183,7 +183,7 @@ int main(int argc, char *argv[]) { assert_se(sd_event_add_io(e, a[0], EPOLLIN, io_handler, INT_TO_PTR('a'), &x) >= 0); assert_se(sd_event_add_io(e, b[0], EPOLLIN, io_handler, INT_TO_PTR('b'), &y) >= 0); assert_se(sd_event_add_monotonic(e, 0, 0, time_handler, INT_TO_PTR('c'), &z) >= 0); - assert_se(sd_event_add_quit(e, quit_handler, INT_TO_PTR('g'), &q) >= 0); + assert_se(sd_event_add_exit(e, exit_handler, INT_TO_PTR('g'), &q) >= 0); assert_se(sd_event_source_set_priority(x, 99) >= 0); assert_se(sd_event_source_set_enabled(y, SD_EVENT_ONESHOT) >= 0); |