summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2017-11-08 17:30:04 +0800
committerLei YU <mine260309@gmail.com>2017-11-10 21:23:26 +0800
commit47263808f5237da331397cd588e91a1ed97405e2 (patch)
tree02a6289050e135e779c74b99d4a4c8ec009a0282
parent7f25c53fa79f71a12b11593ac7eda23a9b8d3e1a (diff)
downloadphosphor-time-manager-47263808f5237da331397cd588e91a1ed97405e2.tar.gz
phosphor-time-manager-47263808f5237da331397cd588e91a1ed97405e2.zip
Fix incorrect host time issue switching to SPLIT
The time tests find an issue that when owner is set to Split, and then set the BMC time, the host time becomes incorrect. The root cause is that the diff between host time and steady clock is not updated when the owner is changed to Split, and thus when BMC time is changed, the host time is calculated incorrectly. The fix is to re-calculate the diff between host time and steady clock in this case. Resolves openbmc/openbmc#901 Change-Id: Ida22f27c6adba6b1cf8a41274eb5f26b6f1bdab7 Signed-off-by: Lei YU <mine260309@gmail.com>
-rw-r--r--host_epoch.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/host_epoch.cpp b/host_epoch.cpp
index 99cdf6d..8415f15 100644
--- a/host_epoch.cpp
+++ b/host_epoch.cpp
@@ -87,6 +87,14 @@ void HostEpoch::onOwnerChanged(Owner owner)
offset = microseconds(0);
saveOffset();
}
+ else
+ {
+ // In SPLIT, need to re-calculate the diff between
+ // host and steady time
+ auto steadyTime = duration_cast<microseconds>(
+ steady_clock::now().time_since_epoch());
+ diffToSteadyClock = getTime() - steadyTime;
+ }
}
void HostEpoch::saveOffset()
OpenPOWER on IntegriCloud