summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2017-11-09 10:49:26 +0800
committerLei YU <mine260309@gmail.com>2017-11-10 21:33:54 +0800
commitfa0248805651d63d7975147c821ad288fa03f3d5 (patch)
treeea10c2817915dc9cbd4611584047297f0b8ad370
parent47263808f5237da331397cd588e91a1ed97405e2 (diff)
downloadphosphor-time-manager-fa0248805651d63d7975147c821ad288fa03f3d5.tar.gz
phosphor-time-manager-fa0248805651d63d7975147c821ad288fa03f3d5.zip
Fix incorrect host time after setting BMC time in NTP/Split
The time tests find an issue that after NTP/BMC is changed to NTP/Split, setting BMC time will cause host time change. The root cause is that it fails to set BMC time (which is expected) but still invokes notifyBmcTimeChange(), which cause host to re-calculate the offset. The fix is to not invoke notifyBmcTimeChange() on failure to set BMC time. Change-Id: Id13b5fa8ba7def764eab8afad23661f9b0be37ce Signed-off-by: Lei YU <mine260309@gmail.com>
-rw-r--r--bmc_epoch.cpp7
-rw-r--r--epoch_base.cpp6
-rw-r--r--epoch_base.hpp4
3 files changed, 12 insertions, 5 deletions
diff --git a/bmc_epoch.cpp b/bmc_epoch.cpp
index bb3872b..8ddb1ef 100644
--- a/bmc_epoch.cpp
+++ b/bmc_epoch.cpp
@@ -112,9 +112,10 @@ uint64_t BmcEpoch::elapsed(uint64_t value)
}
auto time = microseconds(value);
- setTime(time);
-
- notifyBmcTimeChange(time);
+ if (setTime(time))
+ {
+ notifyBmcTimeChange(time);
+ }
server::EpochTime::elapsed(value);
return value;
diff --git a/epoch_base.cpp b/epoch_base.cpp
index dc21c67..bab5d3b 100644
--- a/epoch_base.cpp
+++ b/epoch_base.cpp
@@ -38,7 +38,7 @@ void EpochBase::onOwnerChanged(Owner owner)
}
using namespace std::chrono;
-void EpochBase::setTime(const microseconds& usec)
+bool EpochBase::setTime(const microseconds& usec)
{
auto method = bus.new_method_call(SYSTEMD_TIME_SERVICE,
SYSTEMD_TIME_PATH,
@@ -50,8 +50,12 @@ void EpochBase::setTime(const microseconds& usec)
auto reply = bus.call(method);
if (reply.is_method_error())
{
+ // TODO: When sdbus supports exception on property
+ // it can just throw exception instead of returning bool
log<level::ERR>("Error in setting system time");
+ return false;
}
+ return true;
}
microseconds EpochBase::getTime() const
diff --git a/epoch_base.hpp b/epoch_base.hpp
index 778a5cd..4f23d51 100644
--- a/epoch_base.hpp
+++ b/epoch_base.hpp
@@ -49,8 +49,10 @@ class EpochBase : public sdbusplus::server::object::object <
* org.freedesktop.timedate1's SetTime method.
*
* @param[in] timeOfDayUsec - Microseconds since UTC
+ *
+ * @return true or false to indicate if it sets time successfully
*/
- void setTime(const std::chrono::microseconds& timeOfDayUsec);
+ bool setTime(const std::chrono::microseconds& timeOfDayUsec);
/** @brief Get current time
*
OpenPOWER on IntegriCloud