Colin Walters b1d608
From f94b2f6c88693a9dbd9230723d097d35c0e94b75 Mon Sep 17 00:00:00 2001
Colin Walters b1d608
From: Colin Walters <walters@verbum.org>
Colin Walters b1d608
Date: Mon, 16 Feb 2015 11:43:46 -0500
Colin Walters b1d608
Subject: [PATCH] unit: When stopping due to BindsTo=, log which unit caused it
Colin Walters b1d608
Colin Walters b1d608
I'm trying to track down a relatively recent change in systemd
Colin Walters b1d608
which broke OSTree; see https://bugzilla.gnome.org/show_bug.cgi?id=743891
Colin Walters b1d608
Colin Walters b1d608
Systemd started to stop sysroot.mount, and this patch should help
Colin Walters b1d608
me debug why at least.
Colin Walters b1d608
Colin Walters b1d608
While we're here, "break" on the first unit we find that will
Colin Walters b1d608
deactivate, as there's no point in further iteration.
Colin Walters b1d608
---
Colin Walters b1d608
 src/core/unit.c | 6 ++++--
Colin Walters b1d608
 1 file changed, 4 insertions(+), 2 deletions(-)
Colin Walters b1d608
Colin Walters b1d608
diff --git a/src/core/unit.c b/src/core/unit.c
Colin Walters b1d608
index ad5348b..f898bb7 100644
Colin Walters b1d608
--- a/src/core/unit.c
Colin Walters b1d608
+++ b/src/core/unit.c
Colin Walters b1d608
@@ -1623,7 +1623,7 @@ static void unit_check_unneeded(Unit *u) {
Colin Walters b1d608
 
Colin Walters b1d608
 static void unit_check_binds_to(Unit *u) {
Colin Walters b1d608
         bool stop = false;
Colin Walters b1d608
-        Unit *other;
Colin Walters b1d608
+        Unit *other = NULL;
Colin Walters b1d608
         Iterator i;
Colin Walters b1d608
 
Colin Walters b1d608
         assert(u);
Colin Walters b1d608
@@ -1642,12 +1642,14 @@ static void unit_check_binds_to(Unit *u) {
Colin Walters b1d608
                         continue;
Colin Walters b1d608
 
Colin Walters b1d608
                 stop = true;
Colin Walters b1d608
+                break;
Colin Walters b1d608
         }
Colin Walters b1d608
 
Colin Walters b1d608
         if (!stop)
Colin Walters b1d608
                 return;
Colin Walters b1d608
 
Colin Walters b1d608
-        log_unit_info(u->id, "Unit %s is bound to inactive unit. Stopping, too.", u->id);
Colin Walters b1d608
+        assert(other);
Colin Walters b1d608
+        log_unit_info(u->id, "Unit %s is bound to inactive unit %s. Stopping, too.", u->id, other->id);
Colin Walters b1d608
 
Colin Walters b1d608
         /* A unit we need to run is gone. Sniff. Let's stop this. */
Colin Walters b1d608
         manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);
Colin Walters b1d608
-- 
Colin Walters b1d608
1.8.3.1
Colin Walters b1d608