dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
Zbigniew Jędrzejewski-Szmek 176a18
From e63ebf71edd7947f29389c72e851d8df5c7bedda Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 176a18
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Zbigniew Jędrzejewski-Szmek 176a18
Date: Fri, 16 Mar 2018 23:01:05 +0100
Zbigniew Jędrzejewski-Szmek 176a18
Subject: [PATCH] core: when reloading, delay any actions on journal and dbus
Zbigniew Jędrzejewski-Szmek 176a18
 connections
Zbigniew Jędrzejewski-Szmek 176a18
Zbigniew Jędrzejewski-Szmek 176a18
manager_recheck_journal() and manager_recheck_dbus() would be called to early
Zbigniew Jędrzejewski-Szmek 176a18
while we were deserialiazing units, before the systemd-journald.service and
Zbigniew Jędrzejewski-Szmek 176a18
dbus.service have been deserialized. In effect we'd disable logging to the
Zbigniew Jędrzejewski-Szmek 176a18
journald and close the bus connection. The first is not very noticable, it
Zbigniew Jędrzejewski-Szmek 176a18
mostly means that logs emitted during deserialization are lost. The second is
Zbigniew Jędrzejewski-Szmek 176a18
more noticeable, because manager_recheck_dbus() would call bus_done_api() and
Zbigniew Jędrzejewski-Szmek 176a18
bus_done_system() and close dbus connections. Logging and bus connection would
Zbigniew Jędrzejewski-Szmek 176a18
then be restored later after the respective units have been deserialized.
Zbigniew Jędrzejewski-Szmek 176a18
Zbigniew Jędrzejewski-Szmek 176a18
This is easily reproduced by calling:
Zbigniew Jędrzejewski-Szmek 176a18
  $ sudo gdbus call --system --dest org.freedesktop.systemd1 --object-path /org/freedesktop/systemd1 --method "org.freedesktop.systemd1.Manager.Reload"
Zbigniew Jędrzejewski-Szmek 176a18
which works fine before 8559b3b75cb, and then starts failing with:
Zbigniew Jędrzejewski-Szmek 176a18
  Error: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Remote peer disconnected
Zbigniew Jędrzejewski-Szmek 176a18
Zbigniew Jędrzejewski-Szmek 176a18
None of this should happen, and we should delay changing state until after
Zbigniew Jędrzejewski-Szmek 176a18
deserialization is complete when reloading. manager_reload() already included
Zbigniew Jędrzejewski-Szmek 176a18
the calls to manager_recheck_journal() and manager_recheck_dbus(), so the
Zbigniew Jędrzejewski-Szmek 176a18
connection state will be updated after deserialization during reloading is done.
Zbigniew Jędrzejewski-Szmek 176a18
Zbigniew Jędrzejewski-Szmek 176a18
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1554578.
Zbigniew Jędrzejewski-Szmek 176a18
---
Zbigniew Jędrzejewski-Szmek 176a18
 src/core/unit.c | 7 +++++--
Zbigniew Jędrzejewski-Szmek 176a18
 1 file changed, 5 insertions(+), 2 deletions(-)
Zbigniew Jędrzejewski-Szmek 176a18
Zbigniew Jędrzejewski-Szmek 176a18
diff --git a/src/core/unit.c b/src/core/unit.c
Zbigniew Jędrzejewski-Szmek 176a18
index 815701ad4e..f88aabba61 100644
Zbigniew Jędrzejewski-Szmek 176a18
--- a/src/core/unit.c
Zbigniew Jędrzejewski-Szmek 176a18
+++ b/src/core/unit.c
Zbigniew Jędrzejewski-Szmek 176a18
@@ -2501,8 +2501,11 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
Zbigniew Jędrzejewski-Szmek 176a18
                 }
Zbigniew Jędrzejewski-Szmek 176a18
         }
Zbigniew Jędrzejewski-Szmek 176a18
 
Zbigniew Jędrzejewski-Szmek 176a18
-        manager_recheck_journal(m);
Zbigniew Jędrzejewski-Szmek 176a18
-        manager_recheck_dbus(m);
Zbigniew Jędrzejewski-Szmek 176a18
+        if (!MANAGER_IS_RELOADING(u->manager)) {
Zbigniew Jędrzejewski-Szmek 176a18
+                manager_recheck_journal(m);
Zbigniew Jędrzejewski-Szmek 176a18
+                manager_recheck_dbus(m);
Zbigniew Jędrzejewski-Szmek 176a18
+        }
Zbigniew Jędrzejewski-Szmek 176a18
+
Zbigniew Jędrzejewski-Szmek 176a18
         unit_trigger_notify(u);
Zbigniew Jędrzejewski-Szmek 176a18
 
Zbigniew Jędrzejewski-Szmek 176a18
         if (!MANAGER_IS_RELOADING(u->manager)) {