Skip to content

Commit a5e4cbf

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 676ae9e commit a5e4cbf

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
@@ -1505,22 +1505,31 @@ void Worker::collectFrusFromJson()
15051505
continue;
15061506
}
15071507

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

1514-
// thread returned.
1515-
m_mutex.lock();
1516-
m_activeCollectionThreadCount--;
1517-
m_mutex.unlock();
1513+
m_mutex.lock();
1514+
m_activeCollectionThreadCount--;
1515+
m_mutex.unlock();
15181516

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

0 commit comments

Comments
 (0)