Update Interval when timeRemaining is updated
A typical watchdog implementation would give these 2 features:
- Setting the interval
- Resetting the timer which also means poke
This watchdog implementation does not provide a poke function
and the same can be achieved by clients making these dbus calls
in that order.
1) Get the Last set Interval
2) Set TimeRemaining field to result from #1
To achieve #1, this commit adds the support.
This would make sure that the new timer would expire after last
updated user interval from that time.
Fixes openbmc/openbmc#767
Change-Id: I7393eb32992d7a08518ef463fd0a442df0772392
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/test/watchdog_test.cpp b/test/watchdog_test.cpp
index 4e77528..f9a992c 100644
--- a/test/watchdog_test.cpp
+++ b/test/watchdog_test.cpp
@@ -84,6 +84,9 @@
auto newTime = duration_cast<milliseconds>(expireTime);
wdog.timeRemaining(newTime.count());
+ // Expect an update in the Interval
+ EXPECT_EQ(newTime.count(), wdog.interval());
+
// Waiting for expiration
int count = 0;
while(count < expireTime.count() && !wdog.timerExpired())
diff --git a/watchdog.cpp b/watchdog.cpp
index 0c82df1..8c019a3 100644
--- a/watchdog.cpp
+++ b/watchdog.cpp
@@ -90,6 +90,9 @@
log<level::INFO>("watchdog: reset timer",
entry("VALUE=%llu", value));
+ // Update Interval in Base class.
+ this->interval(value);
+
// Update Base class data.
return WatchdogInherits::timeRemaining(value);
}