daandemeyer / rpms / systemd

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