Bug 6612 - strftime() calls tzset() unnecessarily
Summary: strftime() calls tzset() unnecessarily
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-09 19:27 UTC by Petr Baudis
Modified: 2014-07-03 11:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
Proposed patch (706 bytes, patch)
2008-06-09 19:29 UTC, Petr Baudis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Baudis 2008-06-09 19:27:46 UTC
strftime() calls tzset() unnecessarily even if no timezone information is
required. Since tzset() involves at least single stat('/etc/localtime') syscall,
that can be significant overhead for applications that call strftime() very
frequently (e.g. gbookmark GLib component, see
http://bugzilla.gnome.org/show_bug.cgi?id=535223#c4). Attached patch makes
strftime() call tzset() only when actually necessary.

It might be preferrable to ratelimit tzset() stat() calls, to say single call
per few seconds - there's no sense in checking for timezone change thousands of
times per second.
Comment 1 Petr Baudis 2008-06-09 19:29:52 UTC
Created attachment 2775 [details]
Proposed patch
Comment 2 Ulrich Drepper 2008-06-13 06:09:20 UTC
I've added a slightly changed version of the patch.  And no, there will never be
rate limiting.