libpldmresponder: construct BMC PDRs lazily
BMC's PDRs were constructed when the pldm daemon starts up. However, the
pldm daemon might rely on other services to start in order to create
PDRs. To solve this problem, construct the PDRs when the first GetPDR
call comes in. From a practical timing perspective, this ensures the
pldm daemon and the services it needs to build PDRs are all up and
running.
An alternative would be to add 'After' directives in pldm's service
file, however that can get complex when some of the services are not
present on all platforms.
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: Id6ac9fd47b293f7e84e3837432b32b0e3c3f8a5a
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 6801566..211ff65 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -135,6 +135,12 @@
Response Handler::getPDR(const pldm_msg* request, size_t payloadLength)
{
+ if (!pdrCreated)
+ {
+ generate(*dBusIntf, pdrJsonsDir, pdrRepo);
+ pdrCreated = true;
+ }
+
// Build FRU table if not built, since entity association PDR's are built
// when the FRU table is constructed.
if (fruHandler)