Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions vpd-manager/include/manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
19 changes: 19 additions & 0 deletions vpd-manager/include/worker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>& getListOfEepromPathsThreadFailed() noexcept
{
return m_failedEepromPaths;
}

private:
/**
* @brief An API to parse and publish a FRU VPD over D-Bus.
Expand Down Expand Up @@ -533,5 +549,8 @@ class Worker
// Counting semaphore to limit the number of threads.
std::counting_semaphore<constants::MAX_THREADS> m_semaphore{
constants::MAX_THREADS};

// List of EEPROM paths for which VPD collection thread creation has failed.
std::forward_list<std::string> m_failedEepromPaths;
};
} // namespace vpd
15 changes: 15 additions & 0 deletions vpd-manager/src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ void Manager::SetTimerToDetectSVPDOnDbus()
m_interface->set_property("CollectionStatus",
std::string("InProgress"));
m_worker->collectFrusFromJson();

ProcessFailedEeproms();
}
});
}
Expand Down Expand Up @@ -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
38 changes: 26 additions & 12 deletions vpd-manager/src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1508,22 +1508,36 @@ void Worker::collectFrusFromJson()
continue;
}

std::thread{[vpdFilePath, this]() {
auto l_futureObject = std::async(&Worker::parseAndPublishVPD, this,
vpdFilePath);

std::tuple<bool, std::string> 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());
}
}
}
}

Expand Down