ryantimwilson / rpms / systemd

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