sel-cache: Add match for sel updated event
Add the match for sel updated event so that if an entry is updated, the
sel cache could be updated.
Tested: Verify in g220a QEMU that if an logging entry is updated, the
sel cache is updated.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I5335710c5fa94aaf551091a6051cc1b3a9232e13
diff --git a/storagehandler.cpp b/storagehandler.cpp
index ced34eb..dd247c0 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -80,6 +80,8 @@
__attribute__((init_priority(101)));
std::unique_ptr<sdbusplus::bus::match::match> selRemovedMatch
__attribute__((init_priority(101)));
+std::unique_ptr<sdbusplus::bus::match::match> selUpdatedMatch
+ __attribute__((init_priority(101)));
static inline uint16_t getLoggingId(const std::string& p)
{
@@ -127,6 +129,13 @@
selCacheMap.erase(getLoggingId(p));
}
+static void selUpdatedCallback(sdbusplus::message::message& m)
+{
+ std::string p = m.get_path();
+ auto entry = parseLoggingEntry(p);
+ selCacheMap.insert_or_assign(entry.first, std::move(entry.second));
+}
+
void registerSelCallbackHandler()
{
using namespace sdbusplus::bus::match::rules;
@@ -143,6 +152,15 @@
bus, interfacesRemoved(logWatchPath),
std::bind(selRemovedCallback, std::placeholders::_1));
}
+ if (!selUpdatedMatch)
+ {
+ selUpdatedMatch = std::make_unique<sdbusplus::bus::match::match>(
+ bus,
+ type::signal() + member("PropertiesChanged"s) +
+ interface("org.freedesktop.DBus.Properties"s) +
+ argN(0, logEntryIntf),
+ std::bind(selUpdatedCallback, std::placeholders::_1));
+ }
}
void initSELCache()