chiark / gitweb /
exit-on-idle: only exit if actually idle
[elogind.git] / src / libsystemd / sd-bus / bus-util.c
index c264f2d3fdf1602cb2891070def4b930f9ae2381..52d4ebe6112f919ce4572a0ae08bc4f47756f50a 100644 (file)
@@ -123,7 +123,7 @@ int bus_event_loop_with_idle(
                 if (r < 0)
                         return r;
 
-                if (r == 0 && !exiting) {
+                if (r == 0 && !exiting && idle) {
 
                         r = sd_bus_try_close(bus);
                         if (r == -EBUSY)
@@ -1371,8 +1371,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
 
         if (STR_IN_SET(field,
                        "CPUAccounting", "MemoryAccounting", "BlockIOAccounting",
-                       "SendSIGHUP", "SendSIGKILL",
-                       "WakeSystem")) {
+                       "SendSIGHUP", "SendSIGKILL", "WakeSystem", "DefaultDependencies")) {
 
                 r = parse_boolean(eq);
                 if (r < 0) {
@@ -1638,13 +1637,21 @@ int bus_wait_for_jobs_new(sd_bus *bus, BusWaitForJobs **ret) {
 
         d->bus = sd_bus_ref(bus);
 
+        /* When we are a bus client we match by sender. Direct
+         * connections OTOH have no initialized sender field, and
+         * hence we ignore the sender then */
         r = sd_bus_add_match(
                         bus,
                         &d->slot_job_removed,
+                        bus->bus_client ?
                         "type='signal',"
                         "sender='org.freedesktop.systemd1',"
                         "interface='org.freedesktop.systemd1.Manager',"
                         "member='JobRemoved',"
+                        "path='/org/freedesktop/systemd1'" :
+                        "type='signal',"
+                        "interface='org.freedesktop.systemd1.Manager',"
+                        "member='JobRemoved',"
                         "path='/org/freedesktop/systemd1'",
                         match_job_removed, d);
         if (r < 0)
@@ -1752,6 +1759,7 @@ int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet) {
                         if (q < 0 && r == 0)
                                 r = q;
 
+                        errno = 0;
                         log_debug_errno(q, "Got result %s/%m for job %s", strna(d->result), strna(d->name));
                 }
 
@@ -1776,3 +1784,29 @@ int bus_wait_for_jobs_add(BusWaitForJobs *d, const char *path) {
 
         return set_put_strdup(d->jobs, path);
 }
+
+int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet) {
+        const char *type, *path, *source;
+        int r;
+
+        r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "(sss)");
+        if (r < 0)
+                return bus_log_parse_error(r);
+
+        while ((r = sd_bus_message_read(m, "(sss)", &type, &path, &source)) > 0) {
+                if (!quiet) {
+                        if (streq(type, "symlink"))
+                                log_info("Created symlink from %s to %s.", path, source);
+                        else
+                                log_info("Removed symlink %s.", path);
+                }
+        }
+        if (r < 0)
+                return bus_log_parse_error(r);
+
+        r = sd_bus_message_exit_container(m);
+        if (r < 0)
+                return bus_log_parse_error(r);
+
+        return 0;
+}