summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index c5fde63afb..491ba3f33f 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -249,6 +249,9 @@ bool unit_check_gc(Unit *u) {
if (u->job)
return true;
+ if (u->nop_job)
+ return true;
+
if (unit_active_state(u) != UNIT_INACTIVE)
return true;
@@ -358,6 +361,12 @@ void unit_free(Unit *u) {
job_free(j);
}
+ if (u->nop_job) {
+ Job *j = u->nop_job;
+ job_uninstall(j);
+ job_free(j);
+ }
+
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
bidi_set_free(u, u->dependencies[d]);
@@ -501,6 +510,9 @@ int unit_merge(Unit *u, Unit *other) {
if (other->job)
return -EEXIST;
+ if (other->nop_job)
+ return -EEXIST;
+
if (!UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other)))
return -EEXIST;
@@ -729,6 +741,9 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
if (u->job)
job_dump(u->job, f, prefix2);
+ if (u->nop_job)
+ job_dump(u->nop_job, f, prefix2);
+
free(p2);
}
@@ -1507,6 +1522,7 @@ bool unit_job_is_applicable(Unit *u, JobType j) {
case JOB_VERIFY_ACTIVE:
case JOB_START:
case JOB_STOP:
+ case JOB_NOP:
return true;
case JOB_RESTART:
@@ -2293,6 +2309,11 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds) {
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);
dual_timestamp_serialize(f, "active-enter-timestamp", &u->active_enter_timestamp);
dual_timestamp_serialize(f, "active-exit-timestamp", &u->active_exit_timestamp);
@@ -2382,12 +2403,18 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
return r;
}
- job_install_deserialized(j);
r = hashmap_put(u->manager->jobs, UINT32_TO_PTR(j->id), j);
if (r < 0) {
job_free(j);
return r;
}
+
+ r = job_install_deserialized(j);
+ if (r < 0) {
+ hashmap_remove(u->manager->jobs, UINT32_TO_PTR(j->id));
+ job_free(j);
+ return r;
+ }
} else {
/* legacy */
JobType type = job_type_from_string(v);