summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-01-07 14:15:30 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-01-07 14:15:30 +0100
commitccdad6a4eded99b17fef6f60c3e1a5284dce74e3 (patch)
tree89a16916ac1de517e19ad93d3b2d27fc3e312360
parentde3d7854928a73392426077b63c3875fb47c852b (diff)
downloaddabmux-ccdad6a4eded99b17fef6f60c3e1a5284dce74e3.tar.gz
dabmux-ccdad6a4eded99b17fef6f60c3e1a5284dce74e3.tar.bz2
dabmux-ccdad6a4eded99b17fef6f60c3e1a5284dce74e3.zip
ClockTAI: cache only to /var/tmp
-rw-r--r--src/ClockTAI.cpp30
1 files changed, 8 insertions, 22 deletions
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<const char*, 2> 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<const char*, 2> 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;
}
}