ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
84b277
From bbfce083901a7c7b0ca93297453796c2183a237d Mon Sep 17 00:00:00 2001
84b277
From: Lennart Poettering <lennart@poettering.net>
84b277
Date: Fri, 16 May 2014 01:15:03 +0200
84b277
Subject: [PATCH] core: make sure to serialize jobs for all units
84b277
84b277
Previously we wouldn't serialize jobs for units that themselves have
84b277
nothing to serialize.
84b277
84b277
http://lists.freedesktop.org/archives/systemd-devel/2014-May/019051.html
84b277
84b277
Conflicts:
84b277
	src/core/unit.c
84b277
84b277
(cherry-picked from 9bdb98c59451ed090f8d35d470a54710f389ce71)
84b277
84b277
Related: #1138546
84b277
---
84b277
 src/core/manager.c |  3 ---
84b277
 src/core/unit.c    | 45 +++++++++++++++++++++------------------------
84b277
 2 files changed, 21 insertions(+), 27 deletions(-)
84b277
84b277
diff --git a/src/core/manager.c b/src/core/manager.c
84b277
index a2810b4..4ad26e1 100644
84b277
--- a/src/core/manager.c
84b277
+++ b/src/core/manager.c
84b277
@@ -2169,9 +2169,6 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root) {
84b277
                 if (u->id != t)
84b277
                         continue;
84b277
 
84b277
-                if (!unit_can_serialize(u))
84b277
-                        continue;
84b277
-
84b277
                 /* Start marker */
84b277
                 fputs(u->id, f);
84b277
                 fputc('\n', f);
84b277
diff --git a/src/core/unit.c b/src/core/unit.c
84b277
index 17792d1..855e135 100644
84b277
--- a/src/core/unit.c
84b277
+++ b/src/core/unit.c
84b277
@@ -2296,24 +2296,10 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) {
84b277
         assert(f);
84b277
         assert(fds);
84b277
 
84b277
-        if (!unit_can_serialize(u))
84b277
-                return 0;
84b277
-
84b277
-        r = UNIT_VTABLE(u)->serialize(u, f, fds);
84b277
-        if (r < 0)
84b277
-                return r;
84b277
-
84b277
-
84b277
-        if (serialize_jobs) {
84b277
-                if (u->job) {
84b277
-                        fprintf(f, "job\n");
84b277
-                        job_serialize(u->job, f, fds);
84b277
-                }
84b277
-
84b277
-                if (u->nop_job) {
84b277
-                        fprintf(f, "job\n");
84b277
-                        job_serialize(u->nop_job, f, fds);
84b277
-                }
84b277
+        if (unit_can_serialize(u)) {
84b277
+                r = UNIT_VTABLE(u)->serialize(u, f, fds);
84b277
+                if (r < 0)
84b277
+                        return r;
84b277
         }
84b277
 
84b277
         dual_timestamp_serialize(f, "inactive-exit-timestamp", &u->inactive_exit_timestamp);
84b277
@@ -2330,6 +2316,18 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) {
84b277
         if (u->cgroup_path)
84b277
                 unit_serialize_item(u, f, "cgroup", u->cgroup_path);
84b277
 
84b277
+        if (serialize_jobs) {
84b277
+                if (u->job) {
84b277
+                        fprintf(f, "job\n");
84b277
+                        job_serialize(u->job, f, fds);
84b277
+                }
84b277
+
84b277
+                if (u->nop_job) {
84b277
+                        fprintf(f, "job\n");
84b277
+                        job_serialize(u->nop_job, f, fds);
84b277
+                }
84b277
+        }
84b277
+
84b277
         /* End marker */
84b277
         fputc('\n', f);
84b277
         return 0;
84b277
@@ -2369,9 +2367,6 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
84b277
         assert(f);
84b277
         assert(fds);
84b277
 
84b277
-        if (!unit_can_serialize(u))
84b277
-                return 0;
84b277
-
84b277
         for (;;) {
84b277
                 char line[LINE_MAX], *l, *v;
84b277
                 size_t k;
84b277
@@ -2484,9 +2479,11 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
84b277
                         continue;
84b277
                 }
84b277
 
84b277
-                r = UNIT_VTABLE(u)->deserialize_item(u, l, v, fds);
84b277
-                if (r < 0)
84b277
-                        return r;
84b277
+                if (unit_can_serialize(u)) {
84b277
+                        r = UNIT_VTABLE(u)->deserialize_item(u, l, v, fds);
84b277
+                        if (r < 0)
84b277
+                                return r;
84b277
+                }
84b277
         }
84b277
 }
84b277