From 8f8f05a919355095518911135c3d630f4620a9b0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 3 Mar 2014 01:33:45 +0100 Subject: bus: add sd_bus_track object for tracking peers, and port core over to it This is primarily useful for services that need to track clients which reference certain objects they maintain, or which explicitly want to subscribe to certain events. Something like this is done in a large number of services, and not trivial to do. Hence, let's unify this at one place. This also ports over PID 1 to use this to ensure that subscriptions to job and manager events are correctly tracked. As a side-effect this makes sure we properly serialize and restore the track list across daemon reexec/reload, which didn't work correctly before. This also simplifies how we distribute messages to broadcast to the direct busses: we only track subscriptions for the API bus and implicitly assume that all direct busses are subscribed. This should be a pretty OK simplification since clients connected via direct bus connections are shortlived anyway. --- src/core/dbus.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/core/dbus.h') diff --git a/src/core/dbus.h b/src/core/dbus.h index a3bef47d5..bfb236ec8 100644 --- a/src/core/dbus.h +++ b/src/core/dbus.h @@ -30,5 +30,8 @@ void bus_done(Manager *m); int bus_fdset_add_all(Manager *m, FDSet *fds); -void bus_serialize(Manager *m, FILE *f); -int bus_deserialize_item(Manager *m, const char *line); +void bus_track_serialize(sd_bus_track *t, FILE *f); +int bus_track_deserialize_item(char ***l, const char *line); +int bus_track_coldplug(Manager *m, sd_bus_track **t, char ***l); + +int bus_foreach_bus(Manager *m, sd_bus_track *subscribed2, int (*send_message)(sd_bus *bus, void *userdata), void *userdata); -- cgit v1.2.3