Ignore PLDM message if status objects not created
The OCC status objects are not created until after the host@0-on file
has been removed. This now delays when the objects are created.
This introduced a window where the host notified occ-control that the
OCCs were running (via PLDM) before the status objects were created
which led to a segfault.
This commit will verify the status object exists when getting the PLDM
callback.
Verified on Rainier
Change-Id: I72404d1b5d89c5259cc9f857c8087096644ef318
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/occ_manager.cpp b/occ_manager.cpp
index eb116e7..a77d49b 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -337,7 +337,24 @@
bool Manager::updateOCCActive(instanceID instance, bool status)
{
- return (statusObjects[instance])->occActive(status);
+ auto obj = std::find_if(statusObjects.begin(), statusObjects.end(),
+ [instance](const auto& obj) {
+ return instance == obj->getOccInstanceID();
+ });
+
+ if (obj != statusObjects.end())
+ {
+ return (*obj)->occActive(status);
+ }
+ else
+ {
+ log<level::WARNING>(
+ fmt::format(
+ "Manager::updateOCCActive: No status object to update for OCC{} (active={})",
+ instance, status)
+ .c_str());
+ return false;
+ }
}
void Manager::sbeHRESETResult(instanceID instance, bool success)
diff --git a/occ_sensor.mako.hpp b/occ_sensor.mako.hpp
index 19c785f..123babb 100755
--- a/occ_sensor.mako.hpp
+++ b/occ_sensor.mako.hpp
@@ -14,7 +14,7 @@
namespace occ
{
-using instanceID = int;
+using instanceID = unsigned int;
using sensorID = uint8_t;
using sensorName = std::string;
using sensorDefs = std::tuple<sensorID, sensorName>;
diff --git a/occ_status.hpp b/occ_status.hpp
index e02aaea..77fb82d 100644
--- a/occ_status.hpp
+++ b/occ_status.hpp
@@ -36,7 +36,7 @@
namespace sdbusRule = sdbusplus::bus::match::rules;
// OCC status instance. Ex. for "occ0", the instance is 0
-using instanceID = int;
+using instanceID = unsigned int;
// IPMI sensor ID for a given OCC instance
using sensorID = uint8_t;