diff options
author | Marri Devender Rao <devenrao@in.ibm.com> | 2017-07-10 01:49:54 -0500 |
---|---|---|
committer | Marri Devender Rao <devenrao@in.ibm.com> | 2017-07-26 03:12:42 -0500 |
commit | 908f75075bfb4ece993d6dcfb00ceccbe3983f59 (patch) | |
tree | a1bc0d7480828b224a17d44839b86ff17871cf2b /read_fru_data.cpp | |
parent | c9d7d0197566faef14f290ebfc2695c93eb4cb85 (diff) | |
download | phosphor-host-ipmid-908f75075bfb4ece993d6dcfb00ceccbe3983f59.tar.gz phosphor-host-ipmid-908f75075bfb4ece993d6dcfb00ceccbe3983f59.zip |
cater for property change signal to invalidate fru data
Resolves openbmc/openbmc#1560
Change-Id: I90897959dab76181a6006c372c4b60cc1bdd0c0c
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
Diffstat (limited to 'read_fru_data.cpp')
-rw-r--r-- | read_fru_data.cpp | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/read_fru_data.cpp b/read_fru_data.cpp index 5388926..b23498e 100644 --- a/read_fru_data.cpp +++ b/read_fru_data.cpp @@ -7,7 +7,6 @@ #include "utils.hpp" extern const FruMap frus; - namespace ipmi { namespace fru @@ -15,6 +14,7 @@ namespace fru using namespace phosphor::logging; using InternalFailure = sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; +std::unique_ptr<sdbusplus::bus::match_t> matchPtr(nullptr); static constexpr auto INV_INTF = "xyz.openbmc_project.Inventory.Manager"; static constexpr auto OBJ_PATH = "/xyz/openbmc_project/inventory"; @@ -66,6 +66,57 @@ std::string readProperty(const std::string& intf, return value; } +void processFruPropChange(sdbusplus::message::message& msg) +{ + if(cache::fruMap.empty()) + { + return; + } + std::string path = msg.get_path(); + //trim the object base path, if found at the beginning + if (path.compare(0, strlen(OBJ_PATH), OBJ_PATH) == 0) + { + path.erase(0, strlen(OBJ_PATH)); + } + for (auto& fru : frus) + { + bool found = false; + auto& fruId = fru.first; + auto& instanceList = fru.second; + for (auto& instance : instanceList) + { + if(instance.first == path) + { + found = true; + break; + } + } + if (found) + { + cache::fruMap.erase(fruId); + break; + } + } +} + +//register for fru property change +int registerCallbackHandler() +{ + if(matchPtr == nullptr) + { + using namespace sdbusplus::bus::match::rules; + sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; + matchPtr = std::make_unique<sdbusplus::bus::match_t>( + bus, + path_namespace(OBJ_PATH) + + type::signal() + + member("PropertiesChanged") + + interface(PROP_INTF), + std::bind(processFruPropChange, std::placeholders::_1)); + } + return 0; +} + /** * @brief Read FRU property values from Inventory * |