summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-19 15:47:09 +0100
committerLennart Poettering <lennart@poettering.net>2018-01-05 13:58:32 +0100
commitbdbc866914e54189d6f9924349005fa8fa6bf71b (patch)
tree6402a7a8be208d7cffb3aea29be1169e8143a5bb
parentf9d5fcceaf7f0ec56e328f7c8efc96c523fc87c1 (diff)
downloadsystemd-bdbc866914e54189d6f9924349005fa8fa6bf71b.tar.gz
sd-bus: add new sd_bus_is_ready() API
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.
-rw-r--r--src/libsystemd/libsystemd.sym1
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c7
-rw-r--r--src/systemd/sd-bus.h1
3 files changed, 9 insertions, 0 deletions
diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym
index 05c3b99bd6..af4226c73a 100644
--- a/src/libsystemd/libsystemd.sym
+++ b/src/libsystemd/libsystemd.sym
@@ -540,4 +540,5 @@ global:
sd_bus_add_match_async;
sd_bus_match_signal;
sd_bus_match_signal_async;
+ sd_bus_is_ready;
} LIBSYSTEMD_236;
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 0266fbaf55..7967aac7c6 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -1396,6 +1396,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;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 9a6581348c..76bd5eff95 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -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);