Skip to content

Commit b74977c

Browse files
author
Souvik Roy
committed
Remove redundant async call in FRU collection threads (#588)
This commit removes the redundant std:async call in the detached thread launched for parsing and publishing the VPD for an individual FRU. Since we have a dedicated detached thread for each FRU, we can do VPD parse and publish in a synchronous manner from the detached thread itself, instead of launching a asynchronous task which adds unnecessary performance cost. This commit also handles any exception thrown while launching the detached thread for a FRU. Incase launching detached thread for a FRU fails, we log a PEL and continue launching threads for other FRUs. This commit addresses issue #558. Test: ``` 1. Install bitbaked image on Everest (ever6bmc) 2. After initial boot, check: - BMC State Ready - vpd-manager's CollectionStatus property should be "Completed" busctl get-property com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager CollectionStatus s "Completed" - vpd-manager status should be running with no restarts - vpd-manager should have only 1 thread running: check "ls -la /proc/<vpd-manager PID>/task" 3. Reboot the BMC several times and repeat Step 2. ``` Change-Id: I603c64dc9b5057429a2288f0edfde6086755b851 Signed-off-by: Souvik Roy <[email protected]>
1 parent f41b758 commit b74977c

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

vpd-manager/include/worker.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class Worker
8080
* Note: Config JSON file path should be passed to worker class constructor
8181
* to make use of this API.
8282
*
83+
* @throw std::runtime_error
8384
*/
8485
void collectFrusFromJson();
8586

vpd-manager/src/worker.cpp

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,22 +1508,31 @@ void Worker::collectFrusFromJson()
15081508
continue;
15091509
}
15101510

1511-
std::thread{[vpdFilePath, this]() {
1512-
auto l_futureObject = std::async(&Worker::parseAndPublishVPD, this,
1513-
vpdFilePath);
1514-
1515-
std::tuple<bool, std::string> l_threadInfo = l_futureObject.get();
1511+
try
1512+
{
1513+
std::thread{[vpdFilePath, this]() {
1514+
const auto& l_parseResult = parseAndPublishVPD(vpdFilePath);
15161515

1517-
// thread returned.
1518-
m_mutex.lock();
1519-
m_activeCollectionThreadCount--;
1520-
m_mutex.unlock();
1516+
m_mutex.lock();
1517+
m_activeCollectionThreadCount--;
1518+
m_mutex.unlock();
15211519

1522-
if (!m_activeCollectionThreadCount)
1523-
{
1524-
m_isAllFruCollected = true;
1525-
}
1526-
}}.detach();
1520+
if (!m_activeCollectionThreadCount)
1521+
{
1522+
m_isAllFruCollected = true;
1523+
}
1524+
}}.detach();
1525+
}
1526+
catch (const std::exception& l_ex)
1527+
{
1528+
// TODO: Should we re-try launching thread for this FRU?
1529+
EventLogger::createSyncPel(
1530+
types::ErrorType::InvalidVpdMessage, types::SeverityType::Alert,
1531+
__FILE__, __FUNCTION__, 0,
1532+
std::string("Failed to start collection thread for FRU :[" +
1533+
vpdFilePath + "]. Error: " + l_ex.what()),
1534+
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
1535+
}
15271536
}
15281537
}
15291538

0 commit comments

Comments
 (0)