entity-manager: scan after NameOwnerChanged
We need a poke from DBus for static providers that create all their
objects prior to claiming a well-known name, and thus don't emit any
org.freedesktop.DBus.Properties signals. Similarly if a process exits
for any reason, expected or otherwise, we'll need a poke to remove
entities from DBus.
Testcase is as follows. Consider a static provider service
xyz.openbmc_project.Inventory.Manager[1] that implements interfaces found
in a DBus probe statement. Prior to this patch these commands do not
result in a successful probe:
systemctl stop xyz.openbmc_project.EntityManager
systemctl stop xyz.openbmc_project.Inventory.Manager
systemctl start xyz.openbmc_project.EntityManager
systemctl start xyz.openbmc_project.Inventory.Manager
Yet these commands do:
systemctl stop xyz.openbmc_project.EntityManager
systemctl stop xyz.openbmc_project.Inventory.Manager
systemctl start xyz.openbmc_project.Inventory.Manager
systemctl start xyz.openbmc_project.EntityManager
However if we then:
systemctl stop xyz.openbmc_project.Inventory.Manager
entity manager does not detect the missing objects and remove the
previously exposed configuration (un-probe).
With this patch applied, all scenarios above result in a successful
probe (or un-probe).
[1] To execute this testcase, this series is required:
https://gerrit.openbmc-project.xyz/38853
Change-Id: I54f5b445bafb37551664d57b0444701dc54013f7
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index 5b5e5ce..14c8179 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -1851,6 +1851,18 @@
nlohmann::json systemConfiguration = nlohmann::json::object();
+ // We need a poke from DBus for static providers that create all their
+ // objects prior to claiming a well-known name, and thus don't emit any
+ // org.freedesktop.DBus.Properties signals. Similarly if a process exits
+ // for any reason, expected or otherwise, we'll need a poke to remove
+ // entities from DBus.
+ sdbusplus::bus::match::match nameOwnerChangedMatch(
+ static_cast<sdbusplus::bus::bus&>(*SYSTEM_BUS),
+ sdbusplus::bus::match::rules::nameOwnerChanged(),
+ [&](sdbusplus::message::message&) {
+ propertiesChangedCallback(systemConfiguration, objServer);
+ });
+
io.post(
[&]() { propertiesChangedCallback(systemConfiguration, objServer); });