Add a retry mechanism for introspection
Some processes, when starting up have long delays after registering on
the D-Bus that cause the mapper to timeout on introspection. The mapper
should be more resilient and retry several times before giving up.
This adds a 3X retry as a balance between never giving up and breaking
without cause.
Example errors before this change:
phosphor-mapper[245]: Introspect call failed with error: generic:110,
Connection timed out on process: xyz.openbmc_project.CPUSensor path: /
phosphor-mapper[245]: Introspect call failed with error: generic:110,
Connection timed out on process: xyz.openbmc_project.EntityManager path:
/xyz/openbmc_project/EntityManager
Tested: Boot and see that there are no Introspect call failed timeuot
messages.
Change-Id: I08c0219f445340588d973a2a19ade5a045b3f82e
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/Makefile.am b/Makefile.am
index e28a542..48b9268 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,7 @@
-DBOOST_ALL_NO_LIB
AM_LDFLAGS = $(GMOCK_LIBS) -lgmock_main \
$(GTEST_LIBS) $(OESDK_TESTCASE_FLAGS) $(PTHREAD_LIBS) \
- $(SDBUSPLUS_LIBS) -lboost_system
+ $(SDBUSPLUS_LIBS)
bin_PROGRAMS = mapper mapperx
diff --git a/src/main.cpp b/src/main.cpp
index a42c1fe..0ba614d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -154,14 +154,22 @@
std::shared_ptr<InProgressIntrospect> transaction,
interface_map_type& interface_map,
sdbusplus::asio::object_server& objectServer,
- std::string path)
+ std::string path, int timeoutRetries = 0)
{
+ constexpr int maxTimeoutRetries = 3;
system_bus->async_method_call(
- [&interface_map, &objectServer, transaction, path,
- system_bus](const boost::system::error_code ec,
- const std::string& introspect_xml) {
+ [&interface_map, &objectServer, transaction, path, system_bus,
+ timeoutRetries](const boost::system::error_code ec,
+ const std::string& introspect_xml) {
if (ec)
{
+ if (ec.value() == boost::system::errc::timed_out &&
+ timeoutRetries < maxTimeoutRetries)
+ {
+ do_introspect(system_bus, transaction, interface_map,
+ objectServer, path, timeoutRetries + 1);
+ return;
+ }
std::cerr << "Introspect call failed with error: " << ec << ", "
<< ec.message()
<< " on process: " << transaction->process_name