Ignore HRESET status when we did not request
Code was monitoring StateSensorEvents for HRESET changes and acting on
them even if we did not make the request. This change will ignore the
state change if we do not have an outstanding request.
Change-Id: Iaa61a6bc4d0ebb9e21a6e0960e771f84a6553dc6
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/pldm.cpp b/pldm.cpp
index bff995c..11119ab 100644
--- a/pldm.cpp
+++ b/pldm.cpp
@@ -205,21 +205,31 @@
if (sensorEntry != sensorToSBEInstance.end())
{
- if (eventState == static_cast<EventState>(SBE_HRESET_NOT_READY))
+ const uint8_t instance = sensorEntry->second;
+ auto match = std::find(outstandingHResets.begin(),
+ outstandingHResets.end(), instance);
+ if (match != outstandingHResets.end())
{
- log<level::INFO>(
- fmt::format("pldm: HRESET is NOT READY (OCC{})",
- sensorEntry->second)
- .c_str());
+ outstandingHResets.erase(match);
+ if (eventState == static_cast<EventState>(SBE_HRESET_NOT_READY))
+ {
+ log<level::INFO>(
+ fmt::format("pldm: HRESET is NOT READY (OCC{})",
+ instance)
+ .c_str());
+ }
+ else if (eventState ==
+ static_cast<EventState>(SBE_HRESET_READY))
+ {
+ sbeCallBack(instance, true);
+ }
+ else if (eventState ==
+ static_cast<EventState>(SBE_HRESET_FAILED))
+ {
+ sbeCallBack(instance, false);
+ }
}
- else if (eventState == static_cast<EventState>(SBE_HRESET_READY))
- {
- sbeCallBack(sensorEntry->second, true);
- }
- else if (eventState == static_cast<EventState>(SBE_HRESET_FAILED))
- {
- sbeCallBack(sensorEntry->second, false);
- }
+ // else request was not from us
}
}
}
@@ -453,6 +463,7 @@
// Send request to issue HRESET of SBE (ignore response)
sendPldm(request, sbeInstanceId, false);
+ outstandingHResets.insert(sbeInstanceId);
}
else
{