PEL: Tell HostNotifier about deleted PELs
Have the HostNotifier class subscribe to the Repository class's PEL
deletion callbacks so that when a PEL is deleted HostNotifier can remove
that PEL from its queue and also from its sent list.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I37c61bd62f208512e0c45a628548e0881272d2f5
diff --git a/extensions/openpower-pels/host_notifier.cpp b/extensions/openpower-pels/host_notifier.cpp
index 175a644..b268c9c 100644
--- a/extensions/openpower-pels/host_notifier.cpp
+++ b/extensions/openpower-pels/host_notifier.cpp
@@ -40,6 +40,12 @@
std::bind(std::mem_fn(&HostNotifier::newLogCallback),
this, std::placeholders::_1));
+ // Subscribe to be told about deleted PELs.
+ _repo.subscribeToDeletes(
+ subscriptionName,
+ std::bind(std::mem_fn(&HostNotifier::deleteLogCallback), this,
+ std::placeholders::_1));
+
// Add any existing PELs to the queue to send them if necessary.
_repo.for_each(std::bind(std::mem_fn(&HostNotifier::addPELToQueue), this,
std::placeholders::_1));
@@ -188,6 +194,31 @@
}
}
+void HostNotifier::deleteLogCallback(uint32_t id)
+{
+ auto queueIt = std::find(_pelQueue.begin(), _pelQueue.end(), id);
+ if (queueIt != _pelQueue.end())
+ {
+ log<level::DEBUG>("Host notifier removing deleted log from queue");
+ _pelQueue.erase(queueIt);
+ }
+
+ auto sentIt = std::find(_sentPELs.begin(), _sentPELs.end(), id);
+ if (sentIt != _sentPELs.end())
+ {
+ log<level::DEBUG>("Host notifier removing deleted log from sent list");
+ _sentPELs.erase(sentIt);
+ }
+
+ // Nothing we can do about this...
+ if (id == _inProgressPEL)
+ {
+ log<level::WARNING>(
+ "A PEL was deleted while its host notification was in progress",
+ entry("PEL_ID=0x%X", id));
+ }
+}
+
void HostNotifier::scheduleDispatch()
{
_dispatcher = std::make_unique<sdeventplus::source::Defer>(