Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Jun 2000 18:32:35 +0400
From:      Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To:        hackers@freebsd.org
Subject:   TZ implementation: question or proposition
Message-ID:  <394F8083.39DF0F57@comsys.ntu-kpi.kiev.ua>

next in thread | raw e-mail | index | archive | help
I found out that implementation of time zone (local time, date, etc.)
has one problem. May be I missed something but I think that following
will be interesting.

If some process calls one of functions which operates with local time,
then all other calls of such functions will use time zone got in first
call.

Example. There is some program with following code:

time_t    curr_time;
struct tm curr_tm;
...
for (;;) {
    curr_time = time((time_t *)0);
    localtime_r(&curr_time, &curr_tm);
    ....    /* do something which takes some minutes */
}

Let current time zone is EST. Program calls localtime_r() and gets local
time adjusted to this time zone. Some time latter time zone is changed
(for example by tzsetup program). New time zone makes new adjustment for
local time. But it will take effect only for programs run after time
zone changes.
Our example program will still use local time adjustment for time zone
EST.

This isn't problem for most of programs, but for programs which
sensitive for local time it makes some kind of problems.

I looked at implementation of localtime_r() (and some other functions
like this one) and found out that they call functions tzset() and
tzsetwall(). But tzsetwall() remembers that it has been called and
doesn't allow to ``call'' itself two times (lcl_is_set variable). May be
it is possible to play with environment variable TZ, but I didn't find
good solution.

If I didn't find function which allows to ``restart'' tzset() and
tzsetwall() please tell me. If I'm right then I think that functions
tzreset() and tzresetwall() will be useful. Implementations of these
functions are quite simple: they should set some variables to initial
values and call tzset() and tzsetwall() respectively.

What do you think about all this?



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?394F8083.39DF0F57>