chiark / gitweb /
machined: sync to /run after job completed
authorLennart Poettering <lennart@poettering.net>
Tue, 2 Jul 2013 13:49:27 +0000 (15:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 2 Jul 2013 13:49:27 +0000 (15:49 +0200)
src/core/dbus-unit.c
src/core/unit.c
src/login/logind-dbus.c
src/machine/machined-dbus.c

index ad6d5a6..5831046 100644 (file)
@@ -778,16 +778,18 @@ static int bus_unit_set_transient_property(
         assert(i);
 
         if (streq(name, "Description")) {
-                const char *description;
-
                 if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_STRING)
                         return -EINVAL;
 
-                dbus_message_iter_get_basic(i, &description);
+                if (mode != UNIT_CHECK) {
+                        const char *description;
 
-                r = unit_set_description(u, description);
-                if (r < 0)
-                        return r;
+                        dbus_message_iter_get_basic(i, &description);
+
+                        r = unit_set_description(u, description);
+                        if (r < 0)
+                                return r;
+                }
 
                 return 1;
 
@@ -800,14 +802,20 @@ static int bus_unit_set_transient_property(
 
                 dbus_message_iter_get_basic(i, &s);
 
-                r = manager_load_unit(u->manager, s, NULL, error, &slice);
-                if (r < 0)
-                        return r;
+                if (isempty(s)) {
+                        if (mode != UNIT_CHECK)
+                                unit_ref_unset(&u->slice);
+                } else {
+                        r = manager_load_unit(u->manager, s, NULL, error, &slice);
+                        if (r < 0)
+                                return r;
 
-                if (slice->type != UNIT_SLICE)
-                        return -EINVAL;
+                        if (slice->type != UNIT_SLICE)
+                                return -EINVAL;
 
-                unit_ref_set(&u->slice, slice);
+                        if (mode != UNIT_CHECK)
+                                unit_ref_set(&u->slice, slice);
+                }
                 return 1;
         }
 
index 991111a..acc575b 100644 (file)
@@ -231,8 +231,13 @@ int unit_set_description(Unit *u, const char *description) {
 
         assert(u);
 
-        if (!(s = strdup(description)))
-                return -ENOMEM;
+        if (isempty(description))
+                s = NULL;
+        else {
+                s = strdup(description);
+                if (!s)
+                        return -ENOMEM;
+        }
 
         free(u->description);
         u->description = s;
index 9a19932..e61ec7a 100644 (file)
@@ -2356,6 +2356,7 @@ DBusHandlerResult bus_message_filter(
                                 if (streq_ptr(path, s->scope_job)) {
                                         free(s->scope_job);
                                         s->scope_job = NULL;
+                                        session_save(s);
 
                                         if (s->started) {
                                                 if (streq(result, "done"))
@@ -2382,6 +2383,7 @@ DBusHandlerResult bus_message_filter(
                                         u->slice_job = NULL;
                                 }
 
+                                user_save(u);
                                 user_add_to_gc_queue(u);
                         }
                 }
index 83a45b6..a81f37c 100644 (file)
@@ -116,7 +116,7 @@ static bool valid_machine_name(const char *p) {
 
 static int bus_manager_create_machine(Manager *manager, DBusMessage *message) {
 
-        const char *name, *service, *class, *slice, *root_directory;
+        const char *name, *service, *class, *root_directory;
         _cleanup_free_ char *p = NULL;
         DBusMessageIter iter, sub;
         MachineClass c;
@@ -537,6 +537,7 @@ DBusHandlerResult bus_message_filter(
                         if (streq_ptr(path, mm->scope_job)) {
                                 free(mm->scope_job);
                                 mm->scope_job = NULL;
+                                machine_save(mm);
 
                                 if (mm->started) {
                                         if (streq(result, "done"))