summaryrefslogtreecommitdiff
path: root/src/timesync/timesyncd-conf.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2017-11-08 01:47:38 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2017-11-08 01:47:38 +0900
commita4465d0d4c63c2021b0ba4788e93006e84aafb58 (patch)
tree7c7e7231e3ef602e72b2aa892acebb0ad70297a7 /src/timesync/timesyncd-conf.c
parent0b97f52a33c5397bce6e36fbd39136d2230b96bf (diff)
downloadsystemd-a4465d0d4c63c2021b0ba4788e93006e84aafb58.tar.gz
timesync: make poll interval configurable
This adds PollIntervalMinSec= and PollIntervalMaxSec= to timesyncd.conf Closes #7262.
Diffstat (limited to 'src/timesync/timesyncd-conf.c')
-rw-r--r--src/timesync/timesyncd-conf.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c
index f394d0a2af..b62e20c287 100644
--- a/src/timesync/timesyncd-conf.c
+++ b/src/timesync/timesyncd-conf.c
@@ -106,11 +106,27 @@ int config_parse_servers(
}
int manager_parse_config_file(Manager *m) {
+ int r;
+
assert(m);
- return config_parse_many_nulstr(PKGSYSCONFDIR "/timesyncd.conf",
- CONF_PATHS_NULSTR("systemd/timesyncd.conf.d"),
- "Time\0",
- config_item_perf_lookup, timesyncd_gperf_lookup,
- false, m);
+ r = config_parse_many_nulstr(PKGSYSCONFDIR "/timesyncd.conf",
+ CONF_PATHS_NULSTR("systemd/timesyncd.conf.d"),
+ "Time\0",
+ config_item_perf_lookup, timesyncd_gperf_lookup,
+ false, m);
+ if (r < 0)
+ return r;
+
+ if (m->poll_interval_min_usec < 16 * USEC_PER_SEC) {
+ log_warning("Invalid PollIntervalMinSec=. Using default value.");
+ m->poll_interval_min_usec = NTP_POLL_INTERVAL_MIN_USEC;
+ }
+
+ if (m->poll_interval_max_usec < m->poll_interval_min_usec) {
+ log_warning("PollIntervalMaxSec= is smaller than PollIntervalMinSec=. Using default value.");
+ m->poll_interval_max_usec = MAX(NTP_POLL_INTERVAL_MAX_USEC, m->poll_interval_min_usec * 32);
+ }
+
+ return r;
}