summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-05-11 16:17:28 -0700
committerWilliam A. Kennington III <wak@google.com>2018-05-11 16:31:20 -0700
commite16284935dc097747bf6e74dff5b22219f8c2abb (patch)
tree89f04a99b41e56d541f1bcbbba5e76892e626b97 /app
parent82c173a001399ba1c22de50ab53c4240e9e7edb0 (diff)
downloadphosphor-host-ipmid-e16284935dc097747bf6e74dff5b22219f8c2abb.zip
phosphor-host-ipmid-e16284935dc097747bf6e74dff5b22219f8c2abb.tar.gz
watchdog: Retry dbus requests if the service was cached
Right now if the phosphor-watchdog gets restarted, the first ipmi request querying it will fail and return all the way back up to the ipmi client. In this case, it would be nicer for the client if we retried the request once before reporting a failure. Resolves openbmc/phosphor-host-ipmid#111 Change-Id: I73fce5431911279f9c2e4389d32b671ed60c2305 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'app')
-rw-r--r--app/watchdog_service.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp
index d3fa3ad..cf386b8 100644
--- a/app/watchdog_service.cpp
+++ b/app/watchdog_service.cpp
@@ -25,12 +25,18 @@ WatchdogService::WatchdogService()
WatchdogService::Properties WatchdogService::getProperties()
{
+ bool wasValid = wd_service.isValid(bus);
auto request = wd_service.newMethodCall(bus, prop_intf, "GetAll");
request.append(wd_intf);
auto response = bus.call(request);
if (response.is_method_error())
{
wd_service.invalidate();
+ if (wasValid)
+ {
+ // Retry the request once in case the cached service was stale
+ return getProperties();
+ }
throw std::runtime_error("Failed to get watchdog properties");
}
@@ -49,12 +55,18 @@ WatchdogService::Properties WatchdogService::getProperties()
template <typename T>
void WatchdogService::setProperty(const std::string& key, const T& val)
{
+ bool wasValid = wd_service.isValid(bus);
auto request = wd_service.newMethodCall(bus, prop_intf, "Set");
request.append(wd_intf, key, variant<T>(val));
auto response = bus.call(request);
if (response.is_method_error())
{
wd_service.invalidate();
+ if (wasValid)
+ {
+ // Retry the request once in case the cached service was stale
+ return setProperty(key, val);
+ }
throw std::runtime_error(std::string("Failed to set property: ") + key);
}
}
OpenPOWER on IntegriCloud