chiark / gitweb /
sd-bus: add new sd_bus_is_ready() API
authorLennart Poettering <lennart@poettering.net>
Tue, 19 Dec 2017 14:47:09 +0000 (15:47 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:49:59 +0000 (07:49 +0200)
This new call is much light sd_bus_is_open(), but returns true only if
the connection is fully set up, i.e. after we finished with the
authentication and Hello() phase. This API is useful for clients in
particular when using the "watch_bind" feature, as that way it can be
determined in advance whether it makes sense to sync on some operation.

src/libelogind/libelogind.sym
src/libelogind/sd-bus/sd-bus.c
src/systemd/sd-bus.h

index 84b7ef4066371907f970a322f844d2f468eb48a8..a601e42fd7474b2331f8e53af114fb8f9e273a1e 100644 (file)
@@ -546,4 +546,5 @@ global:
         sd_bus_add_match_async;
         sd_bus_match_signal;
         sd_bus_match_signal_async;
+        sd_bus_is_ready;
 } LIBSYSTEMD_236;
index 5976e6d28962afd5e8435776efd0309a92fa603c..14d90903d11e2ce93844531be3e3cf4aa252a83f 100644 (file)
@@ -1411,6 +1411,13 @@ _public_ int sd_bus_is_open(sd_bus *bus) {
         return BUS_IS_OPEN(bus->state);
 }
 
+_public_ int sd_bus_is_ready(sd_bus *bus) {
+        assert_return(bus, -EINVAL);
+        assert_return(!bus_pid_changed(bus), -ECHILD);
+
+        return bus->state == BUS_RUNNING;
+}
+
 _public_ int sd_bus_can_send(sd_bus *bus, char type) {
         int r;
 
index 60e9d06dfced16c7b25bca14e8fe86282b4fb08c..3c40a53dc70f316c805259a7873c34d80fe74cc8 100644 (file)
@@ -165,6 +165,7 @@ sd_bus *sd_bus_flush_close_unref(sd_bus *bus);
 void sd_bus_default_flush_close(void);
 
 int sd_bus_is_open(sd_bus *bus);
+int sd_bus_is_ready(sd_bus *bus);
 
 int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id);
 int sd_bus_get_scope(sd_bus *bus, const char **scope);