summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/watchdog.cpp10
-rw-r--r--app/watchdog_service.cpp6
-rw-r--r--app/watchdog_service.hpp8
3 files changed, 24 insertions, 0 deletions
diff --git a/app/watchdog.cpp b/app/watchdog.cpp
index d537683..f28ff80 100644
--- a/app/watchdog.cpp
+++ b/app/watchdog.cpp
@@ -28,6 +28,13 @@ ipmi_ret_t ipmi_app_watchdog_reset(
WatchdogService wd_service;
WatchdogService::Properties wd_prop = wd_service.getProperties();
+ // Notify the caller if we haven't initialized our timer yet
+ // so it can configure actions and timeouts
+ if (!wd_prop.initialized)
+ {
+ return IPMI_WDOG_CC_NOT_INIT;
+ }
+
// Reset the countdown to make sure we don't expire our timer
wd_service.setTimeRemaining(wd_prop.interval);
@@ -114,6 +121,9 @@ ipmi_ret_t ipmi_app_watchdog_set(
wd_service.setInterval(interval);
wd_service.setTimeRemaining(interval);
+ // Mark as initialized so that future resets behave correctly
+ wd_service.setInitialized(true);
+
return IPMI_CC_OK;
}
catch (const std::domain_error &)
diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp
index 7f5d179..36a967c 100644
--- a/app/watchdog_service.cpp
+++ b/app/watchdog_service.cpp
@@ -34,6 +34,7 @@ WatchdogService::Properties WatchdogService::getProperties()
std::map<std::string, variant<bool, uint64_t, std::string>> properties;
response.read(properties);
Properties wd_prop;
+ wd_prop.initialized = get<bool>(properties.at("Initialized"));
wd_prop.enabled = get<bool>(properties.at("Enabled"));
wd_prop.interval = get<uint64_t>(properties.at("Interval"));
wd_prop.timeRemaining = get<uint64_t>(properties.at("TimeRemaining"));
@@ -53,6 +54,11 @@ void WatchdogService::setProperty(const std::string& key, const T& val)
}
}
+void WatchdogService::setInitialized(bool initialized)
+{
+ setProperty("Initialized", initialized);
+}
+
void WatchdogService::setEnabled(bool enabled)
{
setProperty("Enabled", enabled);
diff --git a/app/watchdog_service.hpp b/app/watchdog_service.hpp
index 4590e31..1d5ffb8 100644
--- a/app/watchdog_service.hpp
+++ b/app/watchdog_service.hpp
@@ -14,6 +14,7 @@ class WatchdogService {
* watchdog service.
*/
struct Properties {
+ bool initialized;
bool enabled;
uint64_t interval;
uint64_t timeRemaining;
@@ -26,6 +27,13 @@ class WatchdogService {
*/
Properties getProperties();
+ /** @brief Sets the value of the initialized property on the host
+ * watchdog
+ *
+ * @param[in] initialized - The new initializedvalue
+ */
+ void setInitialized(bool initialized);
+
/** @brief Sets the value of the enabled property on the host watchdog
*
* @param[in] enabled - The new enabled value
OpenPOWER on IntegriCloud