chiark / gitweb /
unit: count deserialized job only after it's definitely installed
authorMichal Schmidt <mschmidt@redhat.com>
Sat, 2 Mar 2013 11:29:04 +0000 (12:29 +0100)
committerMichal Schmidt <mschmidt@redhat.com>
Sat, 2 Mar 2013 11:29:04 +0000 (12:29 +0100)
Installation of a deserialized job may fail (though purely in theory),
so increase the running job counter only when succeeding.

src/core/unit.c

index 2f0ac00fcf1fe9ab26b1529d43da0085368fd38c..a6cc3b6102140df840d708e03184579547948e2b 100644 (file)
@@ -2441,15 +2441,15 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
                                         return r;
                                 }
 
                                         return r;
                                 }
 
-                                if (j->state == JOB_RUNNING)
-                                        u->manager->n_running_jobs++;
-
                                 r = job_install_deserialized(j);
                                 if (r < 0) {
                                         hashmap_remove(u->manager->jobs, UINT32_TO_PTR(j->id));
                                         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;
                                 }
+
+                                if (j->state == JOB_RUNNING)
+                                        u->manager->n_running_jobs++;
                         } else {
                                 /* legacy */
                                 JobType type = job_type_from_string(v);
                         } else {
                                 /* legacy */
                                 JobType type = job_type_from_string(v);