diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-15 22:24:52 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-05-30 07:49:55 +0200 |
commit | 004bb7654fb0ca644e70ae22221adfecdcb4a8ed (patch) | |
tree | 7163c295455c55b82b02e6d1c372a8f3423f9a18 /src/libelogind/sd-bus/bus-internal.h | |
parent | 5295adaf6b864f44b0f6ad8ec5aeda540d9c236e (diff) |
sd-bus: optionally, use inotify to wait for bus sockets to appear
This adds a "watch-bind" feature to sd-bus connections. If set and the
AF_UNIX socket we are connecting to doesn't exist yet, we'll establish
an inotify watch instead, and wait for the socket to appear. In other
words, a missing AF_UNIX just makes connecting slower.
This is useful for daemons such as networkd or resolved that shall be
able to run during early-boot, before dbus-daemon is up, and want to
connect to dbus-daemon as soon as it becomes ready.
Diffstat (limited to 'src/libelogind/sd-bus/bus-internal.h')
-rw-r--r-- | src/libelogind/sd-bus/bus-internal.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libelogind/sd-bus/bus-internal.h b/src/libelogind/sd-bus/bus-internal.h index 8557d67e1..ab84dde5f 100644 --- a/src/libelogind/sd-bus/bus-internal.h +++ b/src/libelogind/sd-bus/bus-internal.h @@ -157,6 +157,7 @@ struct sd_bus_slot { enum bus_state { BUS_UNSET, + BUS_WATCH_BIND, /* waiting for the socket to appear via inotify */ BUS_OPENING, BUS_AUTHENTICATING, BUS_HELLO, @@ -188,6 +189,7 @@ struct sd_bus { enum bus_state state; int input_fd, output_fd; + int inotify_fd; int message_version; int message_endian; @@ -210,6 +212,7 @@ struct sd_bus { bool exited:1; bool exit_triggered:1; bool is_local:1; + bool watch_bind:1; int use_memfd; @@ -293,6 +296,7 @@ struct sd_bus { sd_event_source *output_io_event_source; sd_event_source *time_event_source; sd_event_source *quit_event_source; + sd_event_source *inotify_event_source; sd_event *event; int event_priority; @@ -312,6 +316,9 @@ struct sd_bus { LIST_HEAD(sd_bus_slot, slots); LIST_HEAD(sd_bus_track, tracks); + + int *inotify_watches; + size_t n_inotify_watches; }; /* For method calls we time-out at 25s, like in the D-Bus reference implementation */ @@ -369,6 +376,12 @@ bool bus_pid_changed(sd_bus *bus); char *bus_address_escape(const char *v); +int bus_attach_io_events(sd_bus *b); +int bus_attach_inotify_event(sd_bus *b); + +void bus_close_inotify_fd(sd_bus *b); +void bus_close_io_fds(sd_bus *b); + #define OBJECT_PATH_FOREACH_PREFIX(prefix, path) \ for (char *_slash = ({ strcpy((prefix), (path)); streq((prefix), "/") ? NULL : strrchr((prefix), '/'); }) ; \ _slash && !(_slash[(_slash) == (prefix)] = 0); \ |