diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-10-11 10:14:37 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-10-11 10:14:37 +0200 |
commit | ee0f937a5321378ed46a51586bfa281c9a5941d7 (patch) | |
tree | ca91792e60f9dca5a623ea0422efa6beeaecfc8d /src | |
parent | 6c568a521fbaa1b35b3f4f4711f23d828543d02f (diff) | |
download | dabmux-ee0f937a5321378ed46a51586bfa281c9a5941d7.tar.gz dabmux-ee0f937a5321378ed46a51586bfa281c9a5941d7.tar.bz2 dabmux-ee0f937a5321378ed46a51586bfa281c9a5941d7.zip |
Store leap-second cache in /var/tmp
Diffstat (limited to 'src')
-rw-r--r-- | src/ClockTAI.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/ClockTAI.cpp b/src/ClockTAI.cpp index b14de8d..8d693a2 100644 --- a/src/ClockTAI.cpp +++ b/src/ClockTAI.cpp @@ -71,9 +71,20 @@ const int64_t ntp_unix_offset = 2208988800L; // distribution static array<const char*, 2> tai_urls = { "http://www.ietf.org/timezones/data/leap-seconds.list", - "https://raw.githubusercontent.com/eggert/tz/master/leap-seconds.list"}; + "https://raw.githubusercontent.com/eggert/tz/master/leap-seconds.list", +}; -static const char* tai_ietf_cache_file = "/tmp/odr-dabmux-leap-seconds.cache"; +// 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", +}; ClockTAI::ClockTAI() : RemoteControllable("clocktai") @@ -94,7 +105,12 @@ int ClockTAI::get_valid_offset() offset_valid = true; } else { - load_bulletin_from_file(tai_ietf_cache_file); + for (const auto& cache_file : tai_cache_locations) { + load_bulletin_from_file(cache_file); + if (bulletin_is_valid()) { + break; + } + } if (bulletin_is_valid()) { #if TEST @@ -125,7 +141,7 @@ int ClockTAI::get_valid_offset() } if (offset_valid) { - update_cache(tai_ietf_cache_file); + update_cache(tai_cache_locations[0]); break; } } |