summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2018-07-24 10:40:59 +0800
committerLei YU <mine260309@gmail.com>2018-09-12 10:45:04 +0800
commit1cd4248d4afa664b94411dd57e7e686f944dfafc (patch)
treeb49f3d0aa6c319b263b1134e329cd4f4ee65d3e6
parent89efe6ed27a9df5a8e761073bdadd3fdd3fa5875 (diff)
downloadphosphor-time-manager-1cd4248d4afa664b94411dd57e7e686f944dfafc.tar.gz
phosphor-time-manager-1cd4248d4afa664b94411dd57e7e686f944dfafc.zip
Fix un-initialized time owner/mode in manager
The timeOwner/Mode in Manager class has no init value, and it is initialized with the cached time owner/mode in file system. In most of time it is OK because there is cached time owner/mode. But if the BMC does a factory reset, the cached values are cleaned up, and in next reboot the timeOwner/Mode will not be initialized at all. The fix is to give default time owner/mode, so when BMC comes from factory reset it uses default time settings. Tested: Verify the timeOwner/Mode have correct init values after factory reset. Change-Id: Ib1a8fba4d758f33ed09a7afdc9ed684867fca1c5
-rw-r--r--configure.ac7
-rw-r--r--epoch_base.hpp5
-rw-r--r--manager.hpp5
3 files changed, 13 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index 59cf5ce..2680788 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,13 @@ AC_ARG_VAR(HOST_OFFSET_FILE, [The file to save host time offset])
AS_IF([test "x$HOST_OFFSET_FILE" == "x"], [HOST_OFFSET_FILE="/var/lib/obmc/saved_host_offset"])
AC_DEFINE_UNQUOTED([HOST_OFFSET_FILE], ["$HOST_OFFSET_FILE"], [The file to save host time offset])
+AC_ARG_VAR(DEFAULT_TIME_MODE, [The default time mode])
+AS_IF([test "x$DEFAULT_TIME_MODE" == "x"], [DEFAULT_TIME_MODE=Mode::Manual])
+AC_DEFINE_UNQUOTED([DEFAULT_TIME_MODE], [$DEFAULT_TIME_MODE], [The default time mode])
+
+AC_ARG_VAR(DEFAULT_TIME_OWNER, [The default time owner])
+AS_IF([test "x$DEFAULT_TIME_OWNER" == "x"], [DEFAULT_TIME_OWNER=Owner::Both])
+AC_DEFINE_UNQUOTED([DEFAULT_TIME_OWNER], [$DEFAULT_TIME_OWNER], [The default time owner])
AC_CONFIG_FILES([Makefile test/Makefile])
AC_OUTPUT
diff --git a/epoch_base.hpp b/epoch_base.hpp
index 4f23d51..79aca90 100644
--- a/epoch_base.hpp
+++ b/epoch_base.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include "config.h"
#include "property_change_listener.hpp"
#include <sdbusplus/bus.hpp>
@@ -38,10 +39,10 @@ class EpochBase : public sdbusplus::server::object::object <
sdbusplus::bus::bus& bus;
/** @brief The current time mode */
- Mode timeMode = Mode::Manual;
+ Mode timeMode = DEFAULT_TIME_MODE;
/** @brief The current time owner */
- Owner timeOwner = Owner::Both;
+ Owner timeOwner = DEFAULT_TIME_OWNER;
/** @brief Set current time to system
*
diff --git a/manager.hpp b/manager.hpp
index e84652c..3256f59 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include "config.h"
#include "types.hpp"
#include "property_change_listener.hpp"
#include "settings.hpp"
@@ -64,10 +65,10 @@ class Manager
std::string requestedOwner;
/** @brief The current time mode */
- Mode timeMode;
+ Mode timeMode = DEFAULT_TIME_MODE;
/** @brief The current time owner */
- Owner timeOwner;
+ Owner timeOwner = DEFAULT_TIME_OWNER;
/** @brief Restore saved settings */
void restoreSettings();
OpenPOWER on IntegriCloud