diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2012-04-19 23:20:34 +0200 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2012-04-20 17:12:27 +0200 |
commit | 02a3bcc6b4372ca50c0a62b193f9a75b988ffa69 (patch) | |
tree | e570c8bed3b05d55efc6a0a4d1ac5fe9f876d61d /src/core/manager.c | |
parent | 153bda8f03c670caf137f745350c0215b9be2147 (diff) |
job: allow job_free() only on already unlinked jobs
job_free() is IMO too helpful when it unlinks the job from the transaction.
The callers should ensure the job is already unlinked before freeing.
The added assertions check if anyone gets it wrong.
Diffstat (limited to 'src/core/manager.c')
-rw-r--r-- | src/core/manager.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/manager.c b/src/core/manager.c index 95056296ad..aa918f1bd0 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -662,13 +662,15 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) { return r; } +static void transaction_unlink_job(Manager *m, Job *j, bool delete_dependencies); + static void transaction_delete_job(Manager *m, Job *j, bool delete_dependencies) { assert(m); assert(j); /* Deletes one job from the transaction */ - manager_transaction_unlink_job(m, j, delete_dependencies); + transaction_unlink_job(m, j, delete_dependencies); if (!j->installed) job_free(j); @@ -710,8 +712,10 @@ static void transaction_abort(Manager *m) { while ((j = hashmap_first(m->transaction_jobs))) if (j->installed) transaction_delete_job(m, j, true); - else + else { + transaction_unlink_job(m, j, true); job_free(j); + } assert(hashmap_isempty(m->transaction_jobs)); @@ -1441,6 +1445,7 @@ static Job* transaction_add_one_job(Manager *m, JobType type, Unit *unit, bool o LIST_PREPEND(Job, transaction, f, j); if (hashmap_replace(m->transaction_jobs, unit, f) < 0) { + LIST_REMOVE(Job, transaction, f, j); job_free(j); return NULL; } @@ -1453,7 +1458,7 @@ static Job* transaction_add_one_job(Manager *m, JobType type, Unit *unit, bool o return j; } -void manager_transaction_unlink_job(Manager *m, Job *j, bool delete_dependencies) { +static void transaction_unlink_job(Manager *m, Job *j, bool delete_dependencies) { assert(m); assert(j); |