From owner-freebsd-hackers Tue Jun 20 8:33:25 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from relay1.ntu-kpi.kiev.ua (www.ntu-kpi.kiev.ua [212.111.192.161]) by hub.freebsd.org (Postfix) with ESMTP id E2E6637B76D for ; Tue, 20 Jun 2000 08:33:12 -0700 (PDT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from comsys.ntu-kpi.kiev.ua (eth0.comsys.ntu-kpi.kiev.ua [10.0.1.184]) by relay1.ntu-kpi.kiev.ua (Postfix) with ESMTP id 4D8412FA28 for ; Tue, 20 Jun 2000 18:33:03 +0300 (EEST) Received: from comsys.ntu-kpi.kiev.ua (pm514-9.comsys.ntu-kpi.kiev.ua [10.18.54.109]) by comsys.ntu-kpi.kiev.ua (8.9.3/8.8.7) with ESMTP id SAA43961 for ; Tue, 20 Jun 2000 18:41:46 +0300 (EEST) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Message-ID: <394F8083.39DF0F57@comsys.ntu-kpi.kiev.ua> Date: Tue, 20 Jun 2000 18:32:35 +0400 From: Andrey Simonenko X-Mailer: Mozilla 4.07 [en] (Win98; I) MIME-Version: 1.0 To: hackers@freebsd.org Subject: TZ implementation: question or proposition Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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