Revert "Remove the interfaces removed handler"
Listening for the interfaces removed signal is required so
that ibm-logging can remove its objects when phosphor-logging
prunes its entries after hitting capacity.
Previously, ibm-logging depended on someone calling Delete or
DeleteAll to remove objects.
This reverts commit 19ff79fafee4bdf695ae71522715e16bedb1349a.
Tested: Delete xyz.openbmc_project.Logging entries and verify
these logs get deleted too.
Change-Id: Ib172100cc455563fc026330182d46b96f97679b5
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/manager.cpp b/manager.cpp
index 60d26ef..45982fc 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -29,7 +29,12 @@
sdbusplus::bus::match::rules::interfacesAdded() +
sdbusplus::bus::match::rules::path_namespace(LOGGING_PATH),
std::bind(std::mem_fn(&Manager::interfaceAdded), this,
- std::placeholders::_1))
+ std::placeholders::_1)),
+ removeMatch(bus,
+ sdbusplus::bus::match::rules::interfacesRemoved() +
+ sdbusplus::bus::match::rules::path_namespace(LOGGING_PATH),
+ std::bind(std::mem_fn(&Manager::interfaceRemoved), this,
+ std::placeholders::_1))
#ifdef USE_POLICY_INTERFACE
,
policies(POLICY_JSON_PATH)
@@ -145,5 +150,29 @@
create(path, propertyMap->second);
}
}
+
+void Manager::interfaceRemoved(sdbusplus::message::message& msg)
+{
+ sdbusplus::message::object_path path;
+ DbusInterfaceList interfaces;
+
+ msg.read(path, interfaces);
+
+ // If the Logging.Entry interface was removed, then remove
+ // our object
+
+ auto i = std::find(interfaces.begin(), interfaces.end(), LOGGING_IFACE);
+
+ if (i != interfaces.end())
+ {
+ auto id = getEntryID(path);
+
+ auto entry = entries.find(id);
+ if (entry != entries.end())
+ {
+ entries.erase(entry);
+ }
+ }
+}
}
}