[systemd-commits] src/hostname src/libsystemd-bus src/timedate
Lennart Poettering
lennart at kemper.freedesktop.org
Thu Oct 17 16:44:46 PDT 2013
src/hostname/hostnamed.c | 1 -
src/libsystemd-bus/bus-internal.h | 1 +
src/libsystemd-bus/bus-util.c | 2 +-
src/libsystemd-bus/sd-bus.c | 17 +++++++++++++++++
src/timedate/timedated.c | 1 -
5 files changed, 19 insertions(+), 3 deletions(-)
New commits:
commit abc5fe72503fcc30998334e73c5d8e58f9a9d85e
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Oct 18 01:43:11 2013 +0200
bus: automatically flush bus queue when we exit the event loop
This way, we do not have to call it manually
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index a8f0574..db07621 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -665,7 +665,6 @@ int main(int argc, char *argv[]) {
goto finish;
}
- sd_bus_flush(bus);
r = 0;
finish:
diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h
index 1726b61..5f8298b 100644
--- a/src/libsystemd-bus/bus-internal.h
+++ b/src/libsystemd-bus/bus-internal.h
@@ -244,6 +244,7 @@ struct sd_bus {
sd_event_source *input_io_event_source;
sd_event_source *output_io_event_source;
sd_event_source *time_event_source;
+ sd_event_source *quit_event_source;
sd_event *event;
};
diff --git a/src/libsystemd-bus/bus-util.c b/src/libsystemd-bus/bus-util.c
index 0046b48..c726104 100644
--- a/src/libsystemd-bus/bus-util.c
+++ b/src/libsystemd-bus/bus-util.c
@@ -83,7 +83,7 @@ int bus_event_loop_with_idle(sd_event *e, sd_bus *bus, const char *name, usec_t
if (r == SD_EVENT_FINISHED)
break;
- r = sd_event_run(e, exiting ? (uint64_t) -1 : DEFAULT_EXIT_USEC);
+ r = sd_event_run(e, exiting ? (uint64_t) -1 : timeout);
if (r < 0)
return r;
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 665f1e6..55d964e 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -2208,6 +2208,16 @@ static int prepare_callback(sd_event_source *s, void *userdata) {
return 1;
}
+static int quit_callback(sd_event_source *event, void *userdata) {
+ sd_bus *bus = userdata;
+
+ assert(event);
+
+ sd_bus_flush(bus);
+
+ return 1;
+}
+
int sd_bus_attach_event(sd_bus *bus, sd_event *event, int priority) {
int r;
@@ -2251,6 +2261,10 @@ int sd_bus_attach_event(sd_bus *bus, sd_event *event, int priority) {
if (r < 0)
goto fail;
+ r = sd_event_add_quit(event, quit_callback, bus, &bus->quit_event_source);
+ if (r < 0)
+ goto fail;
+
return 0;
fail:
@@ -2271,6 +2285,9 @@ int sd_bus_detach_event(sd_bus *bus) {
if (bus->time_event_source)
bus->time_event_source = sd_event_source_unref(bus->time_event_source);
+ if (bus->quit_event_source)
+ bus->quit_event_source = sd_event_source_unref(bus->quit_event_source);
+
if (bus->event)
bus->event = sd_event_unref(bus->event);
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 61f8fc5..2ead4b9 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -880,7 +880,6 @@ int main(int argc, char *argv[]) {
goto finish;
}
- sd_bus_flush(bus);
r = 0;
finish:
More information about the systemd-commits
mailing list