Re: [nft PATCH 2/2] meta: use reentrant localtime_r()/gmtime_r() functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2023-08-22 at 10:54 +0200, Pablo Neira Ayuso wrote:
> On Tue, Aug 22, 2023 at 10:13:10AM +0200, Thomas Haller wrote:
> > These functions are POSIX.1-2001. We should have them in all
> > environments we care about.
> > 
> > Use them as they are thread-safe.
> 
> Also applied, thanks
> 


Hi Pablo,



One more consideration, that I didn't realize before. Sorry about that.


localtime() will always call tzset(). And localtime_r() is documented
that it may not call it.

  https://linux.die.net/man/3/localtime_r


I checked implementations, AFAIS, musl will always call do_tzset()
([1]). glibc will only ensure that tzset() was called at least once
([2]).

[1] https://git.musl-libc.org/cgit/musl/tree/src/time/__tz.c?id=83b858f83b658bd34eca5d8ad4d145f673ae7e5e#n369
[2] https://codebrowser.dev/glibc/glibc/time/tzset.c.html#577


It's not clear to me, whether it would be more correct/desirable to
always call tzset() before localtime_r(). I think it would only matter,
if the timezone were to change (e.g. update /etc/localtime).

nftables calls localtime_r() from print/parse functions. Presumably, we
will print/parse several timestamps during a larger operation, it would
be odd to change/reload the timezone in between or to meaningfully
support that.


I think it is all good, nothing to change. Just to be aware of.


Thomas





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux