chiark / gitweb /
manager: when breaking ordering cycle show full cycle loop
authorLennart Poettering <lennart@poettering.net>
Thu, 5 Aug 2010 18:39:45 +0000 (20:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 5 Aug 2010 18:39:45 +0000 (20:39 +0200)
src/manager.c

index bdb2b8ba3e8b9849ce430ddbef3795d6867de83d..7dbc4482695fd6102fb3287d63488207fe652620 100644 (file)
@@ -885,7 +885,7 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
 
         /* Have we seen this before? */
         if (j->generation == generation) {
 
         /* Have we seen this before? */
         if (j->generation == generation) {
-                Job *k;
+                Job *k, *delete;
 
                 /* If the marker is NULL we have been here already and
                  * decided the job was loop-free from here. Hence
 
                 /* If the marker is NULL we have been here already and
                  * decided the job was loop-free from here. Hence
@@ -901,17 +901,17 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
                  * in there. */
                 log_warning("Found ordering cycle on %s/%s", j->unit->meta.id, job_type_to_string(j->type));
 
                  * in there. */
                 log_warning("Found ordering cycle on %s/%s", j->unit->meta.id, job_type_to_string(j->type));
 
+                delete = NULL;
                 for (k = from; k; k = ((k->generation == generation && k->marker != k) ? k->marker : NULL)) {
 
                         log_info("Walked on cycle path to %s/%s", k->unit->meta.id, job_type_to_string(k->type));
 
                 for (k = from; k; k = ((k->generation == generation && k->marker != k) ? k->marker : NULL)) {
 
                         log_info("Walked on cycle path to %s/%s", k->unit->meta.id, job_type_to_string(k->type));
 
-                        if (!k->installed &&
+                        if (!delete &&
+                            !k->installed &&
                             !unit_matters_to_anchor(k->unit, k)) {
                                 /* Ok, we can drop this one, so let's
                                  * do so. */
                             !unit_matters_to_anchor(k->unit, k)) {
                                 /* Ok, we can drop this one, so let's
                                  * do so. */
-                                log_warning("Breaking order cycle by deleting job %s/%s", k->unit->meta.id, job_type_to_string(k->type));
-                                transaction_delete_unit(m, k->unit);
-                                return -EAGAIN;
+                                delete = k;
                         }
 
                         /* Check if this in fact was the beginning of
                         }
 
                         /* Check if this in fact was the beginning of
@@ -920,6 +920,13 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
                                 break;
                 }
 
                                 break;
                 }
 
+
+                if (delete) {
+                        log_warning("Breaking ordering cycle by deleting job %s/%s", k->unit->meta.id, job_type_to_string(k->type));
+                        transaction_delete_unit(m, delete->unit);
+                        return -EAGAIN;
+                }
+
                 log_error("Unable to break cycle");
 
                 dbus_set_error(e, BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC, "Transaction order is cyclic. See logs for details.");
                 log_error("Unable to break cycle");
 
                 dbus_set_error(e, BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC, "Transaction order is cyclic. See logs for details.");