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/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 5215589..192112e 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -174,7 +174,7 @@
     std::unique_ptr<HostPDRHandler> hostPDRHandler;
     std::unique_ptr<pldm::host_effecters::HostEffecterParser>
         hostEffecterParser;
-    DBusHandler dbusHandler;
+    auto dbusHandler = std::make_unique<DBusHandler>();
     auto hostEID = pldm::utils::readHostEID();
     if (hostEID)
     {
@@ -183,7 +183,7 @@
             dbusImplReq);
         hostEffecterParser =
             std::make_unique<pldm::host_effecters::HostEffecterParser>(
-                &dbusImplReq, sockfd, pdrRepo.get(), &dbusHandler,
+                &dbusImplReq, sockfd, pdrRepo.get(), dbusHandler.get(),
                 HOST_JSONS_DIR, verbose);
     }
 
@@ -197,9 +197,9 @@
     // Platform handler.
     invoker.registerHandler(PLDM_PLATFORM,
                             std::make_unique<platform::Handler>(
-                                dbusHandler, PDR_JSONS_DIR, EVENTS_JSONS_DIR,
-                                pdrRepo.get(), hostPDRHandler.get(),
-                                fruHandler.get()));
+                                dbusHandler.get(), PDR_JSONS_DIR,
+                                EVENTS_JSONS_DIR, pdrRepo.get(),
+                                hostPDRHandler.get(), fruHandler.get(), true));
     invoker.registerHandler(PLDM_FRU, std::move(fruHandler));
 
 #ifdef OEM_IBM