chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
ff2ea19
)
bus: fix exit-on-idle for driverd
author
Lennart Poettering
<lennart@poettering.net>
Thu, 19 Dec 2013 20:14:52 +0000
(21:14 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Thu, 19 Dec 2013 21:18:39 +0000
(22:18 +0100)
src/bus-driverd/bus-driverd.c
patch
|
blob
|
history
src/hostname/hostnamed.c
patch
|
blob
|
history
src/libsystemd-bus/bus-util.c
patch
|
blob
|
history
src/libsystemd-bus/bus-util.h
patch
|
blob
|
history
src/locale/localed.c
patch
|
blob
|
history
src/timedate/timedated.c
patch
|
blob
|
history
diff --git
a/src/bus-driverd/bus-driverd.c
b/src/bus-driverd/bus-driverd.c
index d4126a99b6a7d9cafe333c33335af9e8fa2f99b9..46ee3492bade04611a22666a4e1b427410d3ecc3 100644
(file)
--- a/
src/bus-driverd/bus-driverd.c
+++ b/
src/bus-driverd/bus-driverd.c
@@
-772,6
+772,13
@@
static int connect_bus(Context *c) {
return 0;
}
return 0;
}
+static bool check_idle(void *userdata) {
+ Context *c = userdata;
+ assert(c);
+
+ return hashmap_isempty(c->clients);
+}
+
int main(int argc, char *argv[]) {
Context context = {};
Client *c;
int main(int argc, char *argv[]) {
Context context = {};
Client *c;
@@
-799,7
+806,7
@@
int main(int argc, char *argv[]) {
if (r < 0)
goto finish;
if (r < 0)
goto finish;
- r = bus_event_loop_with_idle(context.event, context.bus, "org.freedesktop.DBus", DEFAULT_EXIT_USEC);
+ r = bus_event_loop_with_idle(context.event, context.bus, "org.freedesktop.DBus", DEFAULT_EXIT_USEC
, check_idle, &context
);
if (r < 0) {
log_error("Failed to run event loop: %s", strerror(-r));
goto finish;
if (r < 0) {
log_error("Failed to run event loop: %s", strerror(-r));
goto finish;
diff --git
a/src/hostname/hostnamed.c
b/src/hostname/hostnamed.c
index eb2b35f2ccf225c92d513db708f143b12c12863f..e57891bf0d932b365731a623655c7c1f9f59c389 100644
(file)
--- a/
src/hostname/hostnamed.c
+++ b/
src/hostname/hostnamed.c
@@
-639,7
+639,7
@@
int main(int argc, char *argv[]) {
goto finish;
}
goto finish;
}
- r = bus_event_loop_with_idle(event, bus, "org.freedesktop.hostname1", DEFAULT_EXIT_USEC);
+ r = bus_event_loop_with_idle(event, bus, "org.freedesktop.hostname1", DEFAULT_EXIT_USEC
, NULL, NULL
);
if (r < 0) {
log_error("Failed to run event loop: %s", strerror(-r));
goto finish;
if (r < 0) {
log_error("Failed to run event loop: %s", strerror(-r));
goto finish;
diff --git
a/src/libsystemd-bus/bus-util.c
b/src/libsystemd-bus/bus-util.c
index 4c87e167264d12c8c3b4ca709e365b2b1b3dec6a..f96c293984b014220f7d25cc63b721c63e069189 100644
(file)
--- 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;
}
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;
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 (;;) {
assert(name);
for (;;) {
+ bool idle;
+
r = sd_event_get_state(e);
if (r < 0)
return r;
r = sd_event_get_state(e);
if (r < 0)
return r;
-
if (r == SD_EVENT_FINISHED)
break;
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;
if (r < 0)
return r;
diff --git
a/src/libsystemd-bus/bus-util.h
b/src/libsystemd-bus/bus-util.h
index 9a90c2a1e0c920b8fba75a96079baa2e0205c3c2..51e1613c17a0b344019bb9987314332635da6e1b 100644
(file)
--- a/
src/libsystemd-bus/bus-util.h
+++ b/
src/libsystemd-bus/bus-util.h
@@
-54,7
+54,9
@@
int bus_map_all_properties(sd_bus *bus,
int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name);
int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name);
-int bus_event_loop_with_idle(sd_event *e, sd_bus *bus, const char *name, usec_t timeout);
+typedef bool (*check_idle_t)(void *userdata);
+
+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);
int bus_name_has_owner(sd_bus *c, const char *name, sd_bus_error *error);
int bus_name_has_owner(sd_bus *c, const char *name, sd_bus_error *error);
diff --git
a/src/locale/localed.c
b/src/locale/localed.c
index 2c901801737c4eb47cde7da7a5f4fc7c9442e3a4..a1e0ab6fe876e72ec2926850eee48b8ea2d0be05 100644
(file)
--- a/
src/locale/localed.c
+++ b/
src/locale/localed.c
@@
-1149,7
+1149,7
@@
int main(int argc, char *argv[]) {
goto finish;
}
goto finish;
}
- r = bus_event_loop_with_idle(event, bus, "org.freedesktop.locale1", DEFAULT_EXIT_USEC);
+ r = bus_event_loop_with_idle(event, bus, "org.freedesktop.locale1", DEFAULT_EXIT_USEC
, NULL, NULL
);
if (r < 0) {
log_error("Failed to run event loop: %s", strerror(-r));
goto finish;
if (r < 0) {
log_error("Failed to run event loop: %s", strerror(-r));
goto finish;
diff --git
a/src/timedate/timedated.c
b/src/timedate/timedated.c
index 8ac933c5eed5732411c1c9f99436efe50bc9a66e..d85ce57394468347028cdadcca9b5577246a29e7 100644
(file)
--- a/
src/timedate/timedated.c
+++ b/
src/timedate/timedated.c
@@
-857,7
+857,7
@@
int main(int argc, char *argv[]) {
goto finish;
}
goto finish;
}
- r = bus_event_loop_with_idle(event, bus, "org.freedesktop.timedate1", DEFAULT_EXIT_USEC);
+ r = bus_event_loop_with_idle(event, bus, "org.freedesktop.timedate1", DEFAULT_EXIT_USEC
, NULL, NULL
);
if (r < 0) {
log_error("Failed to run event loop: %s", strerror(-r));
goto finish;
if (r < 0) {
log_error("Failed to run event loop: %s", strerror(-r));
goto finish;