summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-19 21:14:52 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-19 22:18:39 +0100
commit37224a5ff522a366b353e8a01e2c2eee1e5416e5 (patch)
tree9da1d82af8aa34acc360e889b05b436e6ebb76f7 /src/libsystemd-bus/bus-util.c
parentff2ea19264b016bd34232cd9c4820c9547413a9a (diff)
bus: fix exit-on-idle for driverd
Diffstat (limited to 'src/libsystemd-bus/bus-util.c')
-rw-r--r--src/libsystemd-bus/bus-util.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/libsystemd-bus/bus-util.c b/src/libsystemd-bus/bus-util.c
index 4c87e16726..f96c293984 100644
--- a/src/libsystemd-bus/bus-util.c
+++ b/src/libsystemd-bus/bus-util.c
@@ -87,7 +87,13 @@ int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name) {
return 0;
}
-int bus_event_loop_with_idle(sd_event *e, sd_bus *bus, const char *name, usec_t timeout) {
+int bus_event_loop_with_idle(
+ sd_event *e,
+ sd_bus *bus,
+ const char *name,
+ usec_t timeout,
+ check_idle_t check_idle,
+ void *userdata) {
bool exiting = false;
int r, code;
@@ -96,14 +102,20 @@ int bus_event_loop_with_idle(sd_event *e, sd_bus *bus, const char *name, usec_t
assert(name);
for (;;) {
+ bool idle;
+
r = sd_event_get_state(e);
if (r < 0)
return r;
-
if (r == SD_EVENT_FINISHED)
break;
- r = sd_event_run(e, exiting ? (uint64_t) -1 : timeout);
+ if (check_idle)
+ idle = check_idle(userdata);
+ else
+ idle = true;
+
+ r = sd_event_run(e, exiting || !idle ? (uint64_t) -1 : timeout);
if (r < 0)
return r;