Implement optional timezone change detection for local time libc functions.
This is enabled at libc build time by #defining DETECT_TZ_CHANGES.
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #47
Differential D30183
tzcode: Implement timezone change detection trasz on May 10 2021, 2:16 PM. Authored by Tags None Referenced Files
Details Implement optional timezone change detection for local time libc functions. Sponsored by: NetApp, Inc.
Diff Detail
Event TimelineComment Actions Is this NetApp code being merged, or is this upstream tzcode? If this is not upstream, it should be submitted to the tz mailing list for wider review by the tz community. (Which reminds me that it's been a long time since we've merged a newer version of tzcode. Now that we're on Git, I've run out of excuses for not doing the work. :)) What is the use of this? Comment Actions On a related note: do the makefiles fetch the current tzinfo files automatically, when building world/universe? (official repository now at https://www.iana.org/time-zones ) Comment Actions @rscheff They are not downloaded automatically. That would make it impossible to build world/universe on an offline machine. They are imported when a new tzdb release is made. I've been doing this for the past several years. I actively follow the tz mailing list. Releases of tzdata are usually imported into FreeBSD head within days of the upstream release (often hours). Imports are merged to stable/* branches soon after and we issue errata notices for supported releases not much later. I've been less diligent about maintaining tzcode. My excuse has been that Subversion made merging hard. That excuse went away recently. I'll start merging the latest tzcode today.
Comment Actions No. Nor should they. That would break a reproducible build, needlessly delay incremental builds, trigger firewall warnings, introduce races into make universe and would be troublesome for disconnected machines. Having a periodic job that ran once a day or once a week even would likely suffice and would produce better results and would be more controllable by the system admin. Comment Actions @imp Weekly? There were six releases of tzdata in all of 2020... (I didn't look at the diff in much detail since any changes to tzcode need to happen upstream.)
Comment Actions All the more reason that polling every 61 seconds is overkill... 2009 had is the biggest I saw with 21 releases.... And a few years had 15... Comment Actions My understanding was this was meant to catch when you switch which timezone you are in, less so detecting when the timezone definition is updated. Comment Actions Then it should use kqueue, imho, and not poll once a minute. It only has to monitor one file. Comment Actions Sorry for delay; I had quite a bit of a backlog... Indeed, this is intended to detect changes to the timezone. However, it's not just one file: it also needs to detect changes to a symlink components in the timezone file path; so while the stat(2) version is fine as it is - it uses the whole path - the kqueue(2)-based one would require keeping open file descriptors for each path component. And with both kqueue(2), and the current implementation using stat(2), we would need some kind of static timeout to avoid calling into the kernel every time. Now, I was looking into prior cases like this in libc, and so far the only one I've found was 60b27ebb253, which implements watching /etc/resolv.conf. That change also uses fstat(2), with reload period of two seconds. Comment Actions It's not upstream. I wonder what should be the workflow here: review it here on FreeBSD Phabricator, then send upstream, or perhaps go upstream first? I'm leaning towards the former. Comment Actions Wouldn't it be sufficient to check the destination file as well as the symlink itself to detect any changes in anything other than a pathological deployment?
Comment Actions We should likely workout a sane change here and then try to submit upstream.
Comment Actions It probably would, but this means introducing additional assumptions; I'd strongly prefer a general approach. Comment Actions It would just mean modding the 'clock' with the monotonic time. That would likely be sufficient to improve things... But as this is speculative, feel free to opt not to do this. Comment Actions Now, about the upstream - I've looked at https://github.com/eggert/tz.git, and it... well, it does resemble our code, to an extent. Which is to say, their code is quite a bit different from ours. Not sure how to handle this, tbh. Comment Actions We're running quite a bit behind on tracking upstream. I attempted to sync a couple of times but I got turned off by Subversion. Now I don't have that excuse anymore. I've bumped a sync with upstream higher on my todo list. Meanwhile, the tz mailing list is very active. Instead of posting your patch to GitHub, I'd recommend posting it to the tz@iana.org mailing list for discussion. Comment Actions I've asked for review on tz@, and here's what follows (see https://mm.icann.org/pipermail/tz/2021-September/030335.html and followups): this has a potential of breaking apps that depend on zone information to not change behind their back, but there's a precedent with Apple doing something similar (although not identical). One proposed solution that I particularly like is for tzcode to provide a function which returns the path to the zone file; this way the app could use whatever notification mechanism it likes, and it would also make it possible to implement a LD_PRELOADed wrapper to implement transparent change detection like this change does. All in all, I think this is fine, as long as it's not enabled by default. |