Martin Pitt [2015-02-05 10:08 +0100]:
> This problem affects not only invoke-rc.d and service (which are from
> sysvinit), but also /lib/lsb/init-functions.d/40-systemd, so cloning
> the bug accordingly.

Patch against experimental branch attached. (Previously erroneously
sent to #777113).

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
From a0b7f75f785ce22f1e0ab4c6d753b1ae5aef7ca5 Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin.p...@ubuntu.com>
Date: Thu, 5 Feb 2015 10:26:58 +0100
Subject: [PATCH] /lib/lsb/init-functions.d/40-systemd: Avoid deadlocks during
 bootup and shutdown

DHCP/ifupdown and similar hooks which call "/etc/init.d/foo reload" can easily
cause deadlocks , since the synchronous wait plus systemd's normal behaviour of
transactionally processing all dependencies first easily causes dependency
loops. Thus during boot/shutdown operate only on the unit and not on its
dependencies, just like SysV behaves.

Closes: #777115
LP: #1417010
---
 debian/changelog                         |  7 +++++++
 debian/extra/init-functions.d/40-systemd | 11 ++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index d18a720..a786486 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,13 @@ systemd (218-8) UNRELEASED; urgency=medium
   * Drop Launch-logind-via-a-shell-wrapper.patch and systemd-logind-launch
     wrapper. The only remaining thing that we need from it is to create
     /run/systemd/, move that into the D-BUS service file directly.
+  * /lib/lsb/init-functions.d/40-systemd: Avoid deadlocks during bootup and
+    shutdown. DHCP/ifupdown and similar hooks which call "/etc/init.d/foo
+    reload" can easily cause deadlocks , since the synchronous wait plus
+    systemd's normal behaviour of transactionally processing all dependencies
+    first easily causes dependency loops. Thus during boot/shutdown operate
+    only on the unit and not on its dependencies, just like SysV behaves.
+    (Closes: #777115, LP: #1417010)
 
  -- Martin Pitt <mp...@debian.org>  Sun, 01 Feb 2015 22:42:30 +0100
 
diff --git a/debian/extra/init-functions.d/40-systemd b/debian/extra/init-functions.d/40-systemd
index 3260d84..6340e5c 100644
--- a/debian/extra/init-functions.d/40-systemd
+++ b/debian/extra/init-functions.d/40-systemd
@@ -59,8 +59,17 @@ systemctl_redirect () {
     state=$(systemctl -p LoadState show $service 2>/dev/null)
     [ "$state" = "LoadState=masked" ] && return 0
 
+    # avoid deadlocks during bootup and shutdown from units/hooks
+    # which call "invoke-rc.d service reload" and similar, since
+    # the synchronous wait plus systemd's normal behaviour of
+    # transactionally processing all dependencies first easily
+    # causes dependency loops
+    if ! systemctl is-system-running; then
+        sctl_args="--job-mode=ignore-dependencies"
+    fi
+
     [ "$command" = status ] || log_daemon_msg "$s" "$service"
-    /bin/systemctl $command "$service"
+    /bin/systemctl $sctl_args $command "$service"
     rc=$?
     [ "$command" = status ] || log_end_msg $rc
 
-- 
2.1.4

Attachment: signature.asc
Description: Digital signature

Reply via email to