diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-04-20 03:53:12 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-04-20 03:53:12 +0200 |
commit | 38c52d4606c77ff2b2b60a08f663a1983d8254b0 (patch) | |
tree | 694361c7bb0e242e73c0ef9014624ea5ac6da19d /src/manager.c | |
parent | 9534ce54858c67363b841cdbdc315140437bfdb4 (diff) |
cgroup: don't accidentaly trim on reload
https://bugzilla.redhat.com/show_bug.cgi?id=678555
Diffstat (limited to 'src/manager.c')
-rw-r--r-- | src/manager.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/manager.c b/src/manager.c index b59339b178..9c817b0e41 100644 --- a/src/manager.c +++ b/src/manager.c @@ -2654,6 +2654,8 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds) { 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)); @@ -2674,10 +2676,15 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds) { 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; @@ -2781,15 +2788,21 @@ int manager_reload(Manager *m) { 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; } @@ -2798,6 +2811,9 @@ int manager_reload(Manager *m) { 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) |