[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Posix Lua VM and os timezone update bug
- From: Gé Weijers <ge@...>
- Date: Mon, 3 Nov 2014 13:28:10 -0800
The downside of this approach is that you end up processing a zoneinfo
file each time you just intend to call localtime/localtime_r.
Depending on the time zone that can take a substantial amount of time.
The zoneinfo files for Cairo, Chile and Jerusalem are over 8K on my
system.
To use tzset and localtime_r correctly in a multi-threaded environment
it is probably necessary to use a read/write lock or similar to make
sure no localtime_r call is in progress while tzset is parsing the
zoneinfo file.
Gé
On Mon, Nov 3, 2014 at 12:13 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> As 'localtime_r' is preferred, because it is thread safe, then if some
>> application needs awareness of timezone changes, it should use external
>> library like
>> http://luaposix.github.io/luaposix/docs/modules/posix.html#localtime
>>
>> Thank you for clarifying that.
>
> If you want, you can configure your Lua version to call tzset by adding
> the following definitions at the end of luaconf.h (or in your makefile):
>
> #define l_gmtime(t,r) gmtime_r(t,r)
> #define l_localtime(t,r) (tzset(), localtime_r(t,r))
>
> -- Roberto
>
--
Gé