]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machine: skip reading properties through DBus when not connected
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 30 Jan 2026 12:34:02 +0000 (21:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 30 Jan 2026 16:23:26 +0000 (01:23 +0900)
When machined is started earlier than DBus service, the execution is
blocked by reading properties through DBus for a while. Let's return
earlier if the DBus connection is not ready.

Fixes issue reported in #40414.

src/machine/machined-dbus.c

index 398cd0e19153bc600867d773bce368565b2305d8..f2f6a300e3c28457d2de3414a59a163ae81bd158 100644 (file)
@@ -1642,6 +1642,12 @@ int manager_unit_is_active(Manager *manager, const char *unit, sd_bus_error *ret
         assert(manager);
         assert(unit);
 
+        r = sd_bus_is_ready(manager->api_bus);
+        if (r < 0)
+                return r;
+        if (r == 0)
+                return -ENOTCONN;
+
         path = unit_dbus_path_from_name(unit);
         if (!path)
                 return -ENOMEM;
@@ -1682,6 +1688,12 @@ int manager_job_is_active(Manager *manager, const char *path, sd_bus_error *rete
         assert(manager);
         assert(path);
 
+        r = sd_bus_is_ready(manager->api_bus);
+        if (r < 0)
+                return r;
+        if (r == 0)
+                return -ENOTCONN;
+
         r = sd_bus_get_property(
                         manager->api_bus,
                         "org.freedesktop.systemd1",