From ccdad6a4eded99b17fef6f60c3e1a5284dce74e3 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 7 Jan 2019 14:15:30 +0100 Subject: ClockTAI: cache only to /var/tmp --- src/ClockTAI.cpp | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/ClockTAI.cpp b/src/ClockTAI.cpp index 90dbab2..787eb4d 100644 --- a/src/ClockTAI.cpp +++ b/src/ClockTAI.cpp @@ -74,17 +74,9 @@ static array default_tai_urls = { "https://raw.githubusercontent.com/eggert/tz/master/leap-seconds.list", }; -// A downloaded bulletin will be saved in the first location of tai_cache_locations -static array tai_cache_locations = { - // According to the Filesystem Hierarchy Standard, the data in - // /var/tmp "must not be deleted when the system is booted.". This is why - // this location has been added. - "/var/tmp/odr-dabmux-leap-seconds.cache", - - // The old location in /tmp is less appropriate, as /tmp can get cleared - // on a reboot. - "/tmp/odr-dabmux-leap-seconds.cache", -}; +// According to the Filesystem Hierarchy Standard, the data in +// /var/tmp "must not be deleted when the system is booted." +static const char *tai_cache_location = "/var/tmp/odr-dabmux-leap-seconds.cache"; struct bulletin_state { bool valid = false; @@ -295,17 +287,11 @@ int ClockTAI::get_valid_offset() offset_valid = true; } else { - for (const auto& cache_file : tai_cache_locations) { - const auto cache_bulletin = load_bulletin_from_file(cache_file); - if (parse_bulletin(cache_bulletin).usable()) { - m_bulletin = cache_bulletin; - break; - } - } - - if (parse_bulletin(m_bulletin).usable()) { + const auto cache_bulletin = load_bulletin_from_file(tai_cache_location); + if (parse_bulletin(cache_bulletin).usable()) { + m_bulletin = cache_bulletin; #if TEST - etiLog.level(info) << "Bulletin from file valid"; + etiLog.level(info) << "Bulletin from cache valid"; #endif offset = parse_ietf_bulletin(m_bulletin); offset_valid = true; @@ -337,7 +323,7 @@ int ClockTAI::get_valid_offset() } if (offset_valid) { - update_cache(tai_cache_locations[0]); + update_cache(tai_cache_location); break; } } -- cgit v1.2.3