return 0;
}
-void cgroup_bonding_free(CGroupBonding *b) {
+void cgroup_bonding_free(CGroupBonding *b, bool remove_or_trim) {
assert(b);
if (b->unit) {
}
}
- if (b->realized && b->ours) {
+ if (b->realized && b->ours && remove_or_trim) {
if (cgroup_bonding_is_empty(b) > 0)
cg_delete(b->controller, b->path);
free(b);
}
-void cgroup_bonding_free_list(CGroupBonding *first) {
+void cgroup_bonding_free_list(CGroupBonding *first, bool remove_or_trim) {
CGroupBonding *b, *n;
LIST_FOREACH_SAFE(by_unit, b, n, first)
- cgroup_bonding_free(b);
+ cgroup_bonding_free(b, remove_or_trim);
}
void cgroup_bonding_trim(CGroupBonding *b, bool delete_root) {
int cgroup_bonding_realize(CGroupBonding *b);
int cgroup_bonding_realize_list(CGroupBonding *first);
-void cgroup_bonding_free(CGroupBonding *b);
-void cgroup_bonding_free_list(CGroupBonding *first);
+void cgroup_bonding_free(CGroupBonding *b, bool remove_or_trim);
+void cgroup_bonding_free_list(CGroupBonding *first, bool remove_or_trim);
int cgroup_bonding_install(CGroupBonding *b, pid_t pid);
int cgroup_bonding_install_list(CGroupBonding *first, pid_t pid);
assert(f);
assert(fds);
+ m->n_serializing ++;
+
fprintf(f, "current-job-id=%i\n", m->current_job_id);
fprintf(f, "taint-usr=%s\n", yes_no(m->taint_usr));
fputs(u->meta.id, f);
fputc('\n', f);
- if ((r = unit_serialize(u, f, fds)) < 0)
+ if ((r = unit_serialize(u, f, fds)) < 0) {
+ m->n_serializing --;
return r;
+ }
}
+ assert(m->n_serializing > 0);
+ m->n_serializing --;
+
if (ferror(f))
return -EIO;
if ((r = manager_open_serialization(m, &f)) < 0)
return r;
+ m->n_serializing ++;
+
if (!(fds = fdset_new())) {
+ m->n_serializing --;
r = -ENOMEM;
goto finish;
}
- if ((r = manager_serialize(m, f, fds)) < 0)
+ if ((r = manager_serialize(m, f, fds)) < 0) {
+ m->n_serializing --;
goto finish;
+ }
if (fseeko(f, 0, SEEK_SET) < 0) {
+ m->n_serializing --;
r = -errno;
goto finish;
}
manager_clear_jobs_and_units(m);
manager_undo_generators(m);
+ assert(m->n_serializing > 0);
+ m->n_serializing --;
+
/* Find new unit paths */
lookup_paths_free(&m->lookup_paths);
if ((q = lookup_paths_init(&m->lookup_paths, m->running_as)) < 0)
ExecOutput default_std_output, default_std_error;
+ int n_serializing;
int n_deserializing;
unsigned n_installed_jobs;
/* For the inactive states unit_notify() will trim the cgroup,
* but for exit we have to do that ourselves... */
- if (state == SERVICE_EXITED)
+ if (state == SERVICE_EXITED && s->meta.manager->n_deserializing <= 0)
cgroup_bonding_trim_list(s->meta.cgroup_bondings, true);
if (old_state != state)
u->meta.manager->n_in_gc_queue--;
}
- cgroup_bonding_free_list(u->meta.cgroup_bondings);
+ cgroup_bonding_free_list(u->meta.cgroup_bondings, u->meta.manager->n_serializing <= 0);
free(u->meta.description);
free(u->meta.fragment_path);