From f3d4ee4d4ca867afe029f6378be9f5cae19d8e80 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 12 Mar 2019 17:55:17 +0100 Subject: [PATCH] init: always abandon child on version change Without this patch, a version change of an already exited child would not trigger the restart of the child because the version is evaluated as late as the child configuration, but only if the child has not exited yet. This patch evaluates the version at the earlier stage where the identity of the child (its name) is checked against the new configuration. Fixes #3226 --- repos/os/src/init/child.cc | 11 +---------- repos/os/src/init/child.h | 5 ++++- repos/os/src/init/main.cc | 5 ++--- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/repos/os/src/init/child.cc b/repos/os/src/init/child.cc index 540327d202..ff5bcc8b3c 100644 --- a/repos/os/src/init/child.cc +++ b/repos/os/src/init/child.cc @@ -55,19 +55,10 @@ Init::Child::apply_config(Xml_node start_node) Config_update config_update = CONFIG_UNCHANGED; /* - * Import new start node if new version differs + * Import new start node if it differs */ if (start_node.differs_from(_start_node->xml())) { - /* - * Check for a change of the version attribute, force restart - * if the version changed. - */ - if (_version != start_node.attribute_value("version", Version())) { - abandon(); - return MAY_HAVE_SIDE_EFFECTS; - } - /* * Start node changed * diff --git a/repos/os/src/init/child.h b/repos/os/src/init/child.h index e98f5625ed..0adc97b633 100644 --- a/repos/os/src/init/child.h +++ b/repos/os/src/init/child.h @@ -35,6 +35,8 @@ class Init::Child : Child_policy, Routed_service::Wakeup { public: + typedef String<80> Version; + /** * Exception types */ @@ -87,7 +89,6 @@ class Init::Child : Child_policy, Routed_service::Wakeup /* * Version attribute of the start node, used to force child restarts. */ - typedef String<80> Version; Version _version { _start_node->xml().attribute_value("version", Version()) }; /* @@ -488,6 +489,8 @@ class Init::Child : Child_policy, Routed_service::Wakeup */ bool has_name(Child_policy::Name const &str) const { return str == name(); } + bool has_version(Version const &version) const { return version == _version; } + Ram_quota ram_quota() const { return _resources.assigned_ram_quota; } Cap_quota cap_quota() const { return _resources.assigned_cap_quota; } diff --git a/repos/os/src/init/main.cc b/repos/os/src/init/main.cc index f511265566..05f2f5937d 100644 --- a/repos/os/src/init/main.cc +++ b/repos/os/src/init/main.cc @@ -249,11 +249,10 @@ void Init::Main::_abandon_obsolete_children() { _children.for_each_child([&] (Child &child) { - Child_policy::Name const name = child.name(); - bool obsolete = true; _config_xml.for_each_sub_node("start", [&] (Xml_node node) { - if (node.attribute_value("name", Child_policy::Name()) == name) + if (child.has_name (node.attribute_value("name", Child_policy::Name())) + && child.has_version(node.attribute_value("version", Child::Version()))) obsolete = false; }); if (obsolete)