mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "alice" <alice@ayaya.dev>
To: "Rich Felker" <dalias@libc.org>
Cc: <musl@lists.openwall.com>, "yubing (C)" <yubing12@huawei.com>,
	"liudongxu" <liudongxu3@huawei.com>,
	"wangyunhe (A)" <wangyunhe@huawei.com>,
	"qiuguorui" <qiuguorui1@huawei.com>,
	"Wanglieming (VRP SSP)" <wanglieming@huawei.com>
Subject: Re: [musl] Time zone has not updated after call tzset()
Date: Sat, 11 Feb 2023 15:30:58 +0100	[thread overview]
Message-ID: <CQFT11F50VT0.PKIXH946RVEX@sumire> (raw)
In-Reply-To: <20230211142034.GF4163@brightrain.aerifal.cx>

On Sat Feb 11, 2023 at 3:20 PM CET, Rich Felker wrote:
> On Sat, Feb 11, 2023 at 03:10:40PM +0100, alice wrote:
> > On Sat Feb 11, 2023 at 7:53 AM CET, zhoujingqiang (A) wrote:
> > > Hello,
> > >
> > > Normally, /etc/localtime is a soft link to a file that stores time zone
> > > information.
> > >
> > > Without setting the TZ environment variable, I change the time zone by
> > > changing the file linked to /etc/localtime. After calling tzset(), I find that
> > > the time zone does not change. The test code is as follows:
> > 
> > musl does not support changing the timezone while running.
> > see https://www.openwall.com/lists/musl/2017/06/09/9 ,
> > for a response to an identical bug report
> > 
> > tl;dr without semantics: you have to restart a running process to get a new
> > timezone.
>
> This is not quite accurate. It does, but only via application intent,
> in the form of changing its value of TZ. It does not re-scan files if
> the application doesn't do that, for two important reasons:

yes, with the semantics, something like:

 setenv("TZ", "something", 0);
 tzset();
 unsetenv("TZ");

will update to a new /etc/localtime symlink. it's mentioned in
https://marc.info/?l=musl&m=141374003126007&w=2
from the above thread.

(apologies, i worded that poorly; what i mean is you cannot rely on /
etc/localtime being read on update (without the hack above), which was the
question. setenv("TZ") is also supported, of course.)

> 1. Without explicit action by the application, there is no way to
>    synchronize changes to the timezone with application consumption of
>    the timezone. Operations like localtime, [some adjustment], mktime
>    will give erroneous results under a race where the zone changes
>    between the calls. (One might suggest using calls to tzset to
>    synchronize, but POSIX specifies that all the functions which use
>    time zone behave as if they implicitly called tzset, so this seems
>    to be forbidden, and it wouldn't be thread-safe anyway.)
>
> 2. Re-scanning the file on disk every time an operation using the time
>    zone is performed results in abysmal performance. This is a
>    bottleneck for lots of programs that do any kind of logging, and if
>    I recall it was the topic of a longstanding, user-infuriating bug
>    report against glibc.
>
> Rich


  reply	other threads:[~2023-02-11 14:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-11  6:53 zhoujingqiang (A)
2023-02-11 14:10 ` alice
2023-02-11 14:20   ` Rich Felker
2023-02-11 14:30     ` alice [this message]
2023-02-11 14:42       ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CQFT11F50VT0.PKIXH946RVEX@sumire \
    --to=alice@ayaya.dev \
    --cc=dalias@libc.org \
    --cc=liudongxu3@huawei.com \
    --cc=musl@lists.openwall.com \
    --cc=qiuguorui1@huawei.com \
    --cc=wanglieming@huawei.com \
    --cc=wangyunhe@huawei.com \
    --cc=yubing12@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).