diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/main.c | 21 | ||||
-rw-r--r-- | src/core/manager.c | 6 | ||||
-rw-r--r-- | src/core/manager.h | 2 | ||||
-rw-r--r-- | src/core/unit.c | 19 | ||||
-rw-r--r-- | src/core/unit.h | 2 |
5 files changed, 29 insertions, 21 deletions
diff --git a/src/core/main.c b/src/core/main.c index 022d05a31b..c7a7a87e7a 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1058,7 +1058,7 @@ static int version(void) { return 0; } -static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds) { +static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds, bool serialize_jobs) { FILE *f = NULL; FDSet *fds = NULL; int r; @@ -1070,18 +1070,21 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds) { /* Make sure nothing is really destructed when we shut down */ m->n_reloading ++; - if ((r = manager_open_serialization(m, &f)) < 0) { + r = manager_open_serialization(m, &f); + if (r < 0) { log_error("Failed to create serialization file: %s", strerror(-r)); goto fail; } - if (!(fds = fdset_new())) { + fds = fdset_new(); + if (!fds) { r = -ENOMEM; log_error("Failed to allocate fd set: %s", strerror(-r)); goto fail; } - if ((r = manager_serialize(m, f, fds)) < 0) { + r = manager_serialize(m, f, fds, serialize_jobs); + if (r < 0) { log_error("Failed to serialize state: %s", strerror(-r)); goto fail; } @@ -1091,12 +1094,14 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds) { goto fail; } - if ((r = fd_cloexec(fileno(f), false)) < 0) { + r = fd_cloexec(fileno(f), false); + if (r < 0) { log_error("Failed to disable O_CLOEXEC for serialization: %s", strerror(-r)); goto fail; } - if ((r = fdset_cloexec(fds, false)) < 0) { + r = fdset_cloexec(fds, false); + if (r < 0) { log_error("Failed to disable O_CLOEXEC for serialization fds: %s", strerror(-r)); goto fail; } @@ -1624,7 +1629,7 @@ int main(int argc, char *argv[]) { case MANAGER_REEXECUTE: - if (prepare_reexecute(m, &serialization, &fds) < 0) + if (prepare_reexecute(m, &serialization, &fds, true) < 0) goto finish; reexecute = true; @@ -1638,7 +1643,7 @@ int main(int argc, char *argv[]) { m->switch_root = m->switch_root_init = NULL; if (!switch_root_init) - if (prepare_reexecute(m, &serialization, &fds) < 0) + if (prepare_reexecute(m, &serialization, &fds, false) < 0) goto finish; reexecute = true; diff --git a/src/core/manager.c b/src/core/manager.c index 8f2635051e..27dc9f38e0 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1722,7 +1722,7 @@ int manager_open_serialization(Manager *m, FILE **_f) { return 0; } -int manager_serialize(Manager *m, FILE *f, FDSet *fds) { +int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool serialize_jobs) { Iterator i; Unit *u; const char *t; @@ -1759,7 +1759,7 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds) { fputs(u->id, f); fputc('\n', f); - if ((r = unit_serialize(u, f, fds)) < 0) { + if ((r = unit_serialize(u, f, fds, serialize_jobs)) < 0) { m->n_reloading --; return r; } @@ -1899,7 +1899,7 @@ int manager_reload(Manager *m) { goto finish; } - r = manager_serialize(m, f, fds); + r = manager_serialize(m, f, fds, true); if (r < 0) { m->n_reloading --; goto finish; diff --git a/src/core/manager.h b/src/core/manager.h index be2780bafe..6c81f92d63 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -278,7 +278,7 @@ void manager_dispatch_bus_query_pid_done(Manager *m, const char *name, pid_t pid int manager_open_serialization(Manager *m, FILE **_f); -int manager_serialize(Manager *m, FILE *f, FDSet *fds); +int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool serialize_jobs); int manager_deserialize(Manager *m, FILE *f, FDSet *fds); int manager_reload(Manager *m); diff --git a/src/core/unit.c b/src/core/unit.c index 7994f7038e..ae6f69183d 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2401,7 +2401,7 @@ bool unit_can_serialize(Unit *u) { return UNIT_VTABLE(u)->serialize && UNIT_VTABLE(u)->deserialize_item; } -int unit_serialize(Unit *u, FILE *f, FDSet *fds) { +int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) { int r; assert(u); @@ -2414,14 +2414,17 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds) { if ((r = UNIT_VTABLE(u)->serialize(u, f, fds)) < 0) return r; - if (u->job) { - fprintf(f, "job\n"); - job_serialize(u->job, f, fds); - } - if (u->nop_job) { - fprintf(f, "job\n"); - job_serialize(u->nop_job, f, fds); + if (serialize_jobs) { + if (u->job) { + fprintf(f, "job\n"); + job_serialize(u->job, f, fds); + } + + if (u->nop_job) { + fprintf(f, "job\n"); + job_serialize(u->nop_job, f, fds); + } } dual_timestamp_serialize(f, "inactive-exit-timestamp", &u->inactive_exit_timestamp); diff --git a/src/core/unit.h b/src/core/unit.h index 2483e4ea9d..d0a5d641d0 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -499,7 +499,7 @@ char *unit_full_printf(Unit *u, const char *text); char **unit_full_printf_strv(Unit *u, char **l); bool unit_can_serialize(Unit *u); -int unit_serialize(Unit *u, FILE *f, FDSet *fds); +int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs); void unit_serialize_item_format(Unit *u, FILE *f, const char *key, const char *value, ...) _printf_attr_(4,5); void unit_serialize_item(Unit *u, FILE *f, const char *key, const char *value); int unit_deserialize(Unit *u, FILE *f, FDSet *fds); |