diff --git a/vpd-manager/include/manager.hpp b/vpd-manager/include/manager.hpp index cb64123b4..fd5ca8c63 100644 --- a/vpd-manager/include/manager.hpp +++ b/vpd-manager/include/manager.hpp @@ -255,6 +255,12 @@ class Manager * @param[in] i_msg - The callback message. */ void processAssetTagChangeCallback(sdbusplus::message_t& i_msg); + + /** + * @brief API to process list of EEPROMs for which VPD collection thread + * creation has failed. + */ + void ProcessFailedEeproms(); #endif /** diff --git a/vpd-manager/include/worker.hpp b/vpd-manager/include/worker.hpp index a0da85d9a..660ac76fa 100644 --- a/vpd-manager/include/worker.hpp +++ b/vpd-manager/include/worker.hpp @@ -146,6 +146,22 @@ class Worker return m_activeCollectionThreadCount; } + /** + * @brief API to get the list of EEPROMs for which VPD collection thread + * creation has failed. + * + * This API returns the list of EEPROMs for which VPD collection thread + * creation has failed by reference. Manager needs to process this list of + * EEPROMs and take appropriate action. + * + * @return reference to list of EEPROM paths for which VPD collection thread + * creation has failed + */ + std::forward_list& getListOfEepromPathsThreadFailed() noexcept + { + return m_failedEepromPaths; + } + private: /** * @brief An API to parse and publish a FRU VPD over D-Bus. @@ -533,5 +549,8 @@ class Worker // Counting semaphore to limit the number of threads. std::counting_semaphore m_semaphore{ constants::MAX_THREADS}; + + // List of EEPROM paths for which VPD collection thread creation has failed. + std::forward_list m_failedEepromPaths; }; } // namespace vpd diff --git a/vpd-manager/src/manager.cpp b/vpd-manager/src/manager.cpp index 7f9efd487..550955403 100644 --- a/vpd-manager/src/manager.cpp +++ b/vpd-manager/src/manager.cpp @@ -236,6 +236,8 @@ void Manager::SetTimerToDetectSVPDOnDbus() m_interface->set_property("CollectionStatus", std::string("InProgress")); m_worker->collectFrusFromJson(); + + ProcessFailedEeproms(); } }); } @@ -910,4 +912,17 @@ void Manager::performVpdRecollection() std::string(l_ex.what())); } } + +void Manager::ProcessFailedEeproms() +{ + if (m_worker.get() != nullptr) + { + // TODO: + // - iterate through list of EEPROMs for which thread creation has + // failed + // - get list of FRUs under the EEPROM + // - For each FRU, extract the object path and do collect single FRU + m_worker->getListOfEepromPathsThreadFailed().clear(); + } +} } // namespace vpd diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp index 531dc6e59..6711d76a0 100644 --- a/vpd-manager/src/worker.cpp +++ b/vpd-manager/src/worker.cpp @@ -1508,22 +1508,36 @@ void Worker::collectFrusFromJson() continue; } - std::thread{[vpdFilePath, this]() { - auto l_futureObject = std::async(&Worker::parseAndPublishVPD, this, - vpdFilePath); - - std::tuple l_threadInfo = l_futureObject.get(); + try + { + std::thread{[vpdFilePath, this]() { + const auto& l_parseResult = parseAndPublishVPD(vpdFilePath); - // thread returned. - m_mutex.lock(); - m_activeCollectionThreadCount--; - m_mutex.unlock(); + m_mutex.lock(); + m_activeCollectionThreadCount--; + m_mutex.unlock(); - if (!m_activeCollectionThreadCount) + if (!m_activeCollectionThreadCount && + m_failedEepromPaths.empty()) + { + m_isAllFruCollected = true; + } + }}.detach(); + } + catch (const std::exception& l_ex) + { + try { - m_isAllFruCollected = true; + // add vpdFilePath(EEPROM path) to failed list + m_failedEepromPaths.push_front(vpdFilePath); } - }}.detach(); + catch (const std::exception& l_ex) + { + logging::logMessage( + "Failed to add [" + vpdFilePath + + "] to failed EEPROM list. Error: " + l_ex.what()); + } + } } }