summaryrefslogtreecommitdiff
path: root/src/core/job.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2012-04-20 02:04:01 +0200
committerMichal Schmidt <mschmidt@redhat.com>2012-04-20 17:12:28 +0200
commit05d576f1f77699ea5c2e5ed0e04451b14dfc45a0 (patch)
tree08ce135a80c8dd15866925fcbe30341fbf028746 /src/core/job.c
parentf1c2bdca422dba1bc5615f72662dee5ce69c147b (diff)
job: separate job_install()
Let the jobs install themselves.
Diffstat (limited to 'src/core/job.c')
-rw-r--r--src/core/job.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/core/job.c b/src/core/job.c
index aa7cdbff2a..0b50888184 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -54,21 +54,6 @@ Job* job_new(Unit *unit, JobType type) {
return j;
}
-void job_uninstall(Job *j) {
- assert(j->installed);
- /* Detach from next 'bigger' objects */
-
- bus_job_send_removed_signal(j);
-
- if (j->unit->job == j) {
- j->unit->job = NULL;
- unit_add_to_gc_queue(j->unit);
- }
-
- hashmap_remove(j->manager->jobs, UINT32_TO_PTR(j->id));
- j->installed = false;
-}
-
void job_free(Job *j) {
assert(j);
assert(!j->installed);
@@ -96,6 +81,35 @@ void job_free(Job *j) {
free(j);
}
+void job_uninstall(Job *j) {
+ assert(j->installed);
+ /* Detach from next 'bigger' objects */
+
+ bus_job_send_removed_signal(j);
+
+ if (j->unit->job == j) {
+ j->unit->job = NULL;
+ unit_add_to_gc_queue(j->unit);
+ }
+
+ hashmap_remove(j->manager->jobs, UINT32_TO_PTR(j->id));
+ j->installed = false;
+}
+
+void job_install(Job *j) {
+ Job *uj = j->unit->job;
+
+ if (uj) {
+ job_uninstall(uj);
+ job_free(uj);
+ }
+
+ j->unit->job = j;
+ j->installed = true;
+ j->manager->n_installed_jobs ++;
+ log_debug("Installed new job %s/%s as %u", j->unit->id, job_type_to_string(j->type), (unsigned) j->id);
+}
+
JobDependency* job_dependency_new(Job *subject, Job *object, bool matters, bool conflicts) {
JobDependency *l;