summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-10 18:45:39 +0200
committerLennart Poettering <lennart@poettering.net>2015-04-10 18:45:39 +0200
commit53bac4e0e32b017e7a5c1fd1181c740a1583e3fd (patch)
treee21bd02b5570ea4c4a0190a1df1a6849eedb253c /src
parent5c5ccf12b623a1e77684c58bb0d06e1d4fd73e21 (diff)
sd-event: simplify sd_event_run()
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-event/sd-event.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 376477f275..0dc4680376 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2490,24 +2490,20 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
assert_return(e->state == SD_EVENT_INITIAL, -EBUSY);
r = sd_event_prepare(e);
- if (r > 0) {
- r = sd_event_dispatch(e);
- if (r < 0)
- return r;
- else
- return 1;
- } else if (r < 0)
- return r;
+ if (r == 0)
+ /* There was nothing? Then wait... */
+ r = sd_event_wait(e, timeout);
- r = sd_event_wait(e, timeout);
if (r > 0) {
+ /* There's something now, then let's dispatch it */
r = sd_event_dispatch(e);
if (r < 0)
return r;
- else
- return 1;
- } else
- return r;
+
+ return 1;
+ }
+
+ return r;
}
_public_ int sd_event_loop(sd_event *e) {