summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-06-06 23:15:19 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-06-08 12:50:52 +0530
commitf2309dd978eacd53343b68e012a1406eaf484e2e (patch)
tree11dab864e455a3439acc4c385fed9a79bf6b526d
parentf00d0db8e4f022ed6c2ff2e3b7a4c19d56c8e9ab (diff)
downloadphosphor-watchdog-f2309dd978eacd53343b68e012a1406eaf484e2e.tar.gz
phosphor-watchdog-f2309dd978eacd53343b68e012a1406eaf484e2e.zip
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>
-rw-r--r--test/watchdog_test.cpp3
-rw-r--r--watchdog.cpp3
2 files changed, 6 insertions, 0 deletions
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 @@ TEST_F(WdogTest, enableWdogAndResetTo5Seconds)
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 @@ uint64_t Watchdog::timeRemaining(uint64_t value)
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);
}
OpenPOWER on IntegriCloud