chiark / gitweb /
fix impact minimizing code
authorLennart Poettering <lennart@poettering.net>
Fri, 29 Jan 2010 03:26:30 +0000 (04:26 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 29 Jan 2010 03:26:30 +0000 (04:26 +0100)
main.c
manager.c

diff --git a/main.c b/main.c
index be733f0cd2b570b7fcac8b1c9fccf5d360a87bfa..26d327cfac08a7e46967efc0e3d4ba7118934828 100644 (file)
--- a/main.c
+++ b/main.c
@@ -42,10 +42,10 @@ int main(int argc, char *argv[]) {
         printf("→ By jobs:\n");
         manager_dump_jobs(m, stdout, "\t");
 
-        /* if ((r = manager_loop(m)) < 0) { */
-        /*         log_error("Failed to run mainloop: %s", strerror(-r)); */
-        /*         goto finish; */
-        /* } */
+        if ((r = manager_loop(m)) < 0) {
+                log_error("Failed to run mainloop: %s", strerror(-r));
+                goto finish;
+        }
 
         retval = 0;
 
index fd219b03041f7eb5b58c19b2ef2f3750cdb655a9..06a171ff2ebb7b6041980caa9e06192eae5767c3 100644 (file)
--- a/manager.c
+++ b/manager.c
@@ -563,6 +563,7 @@ static void transaction_minimize_impact(Manager *m) {
 
                 HASHMAP_FOREACH(j, m->transaction_jobs, i) {
                         LIST_FOREACH(transaction, j, j) {
+                                bool stops_running_service, changes_existing_job;
 
                                 /* If it matters, we shouldn't drop it */
                                 if (j->matters_to_anchor)
@@ -571,12 +572,25 @@ static void transaction_minimize_impact(Manager *m) {
                                 /* Would this stop a running service?
                                  * Would this change an existing job?
                                  * If so, let's drop this entry */
-                                if ((j->type != JOB_STOP || UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(j->unit))) &&
-                                    (!j->unit->meta.job  || job_type_is_conflicting(j->type, j->unit->meta.job->state)))
+
+                                stops_running_service =
+                                        j->type == JOB_STOP && UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(j->unit));
+
+                                changes_existing_job =
+                                        j->unit->meta.job && job_type_is_conflicting(j->type, j->unit->meta.job->state);
+
+                                if (!stops_running_service && !changes_existing_job)
                                         continue;
 
+                                if (stops_running_service)
+                                        log_debug("%s/%s would stop a running service.", unit_id(j->unit), job_type_to_string(j->type));
+
+                                if (changes_existing_job)
+                                        log_debug("%s/%s would change existing job.", unit_id(j->unit), job_type_to_string(j->type));
+
                                 /* Ok, let's get rid of this */
-                                log_debug("Deleting %s/%s to minimize impact", unit_id(j->unit), job_type_to_string(j->type));
+                                log_debug("Deleting %s/%s to minimize impact.", unit_id(j->unit), job_type_to_string(j->type));
+
                                 transaction_delete_job(m, j);
                                 again = true;
                                 break;