public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at redhat dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sources.redhat.com Subject: [Bug libc/5184] strftime stats /etc/localtime too much Date: Tue, 16 Oct 2007 08:13:00 -0000 [thread overview] Message-ID: <20071016081346.30396.qmail@sourceware.org> (raw) In-Reply-To: <20071016022504.5184.adi@hexapodia.org> ------- Additional Comments From jakub at redhat dot com 2007-10-16 08:13 ------- I think the complaint in this case is that strftime, instead of doing tzset just once, does it 5 times. #include <time.h> #define DBG(str) write (-1, str, sizeof (str) - 1) int main (void) { char buf[40]; time_t now; struct tm *tmp; now = time (0); tmp = localtime (&now); strftime (buf, sizeof (buf), "%F %T", tmp); DBG ("before time"); now = time (0); DBG ("before localtime"); tmp = localtime (&now); DBG ("before strftime"); strftime (buf, sizeof (buf), "%F %T", tmp); DBG ("after strftime"); return 0; } strace ./Y # against CVS glibc ... write(4294967295, "before time", 11) = -1 EBADF (Bad file descriptor) write(4294967295, "before localtime", 16) = -1 EBADF (Bad file descriptor) write(4294967295, "before strftime", 15) = -1 EBADF (Bad file descriptor) stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2246, ...}) = 0 stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2246, ...}) = 0 stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2246, ...}) = 0 stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2246, ...}) = 0 stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2246, ...}) = 0 write(4294967295, "after strftime", 14) = -1 EBADF (Bad file descriptor) That is IMHO easily fixable with some rearrangments of strftime_l.c - changing the my_strftime function to an an internal helper with an additional argument, writing a tiny wrapper and not calling tzset () if it has been called already by an outer strftime in case of recursion. BTW, doesn't localtime have to stat /etc/localtime? http://www.opengroup.org/onlinepubs/009695399/functions/localtime.html Local timezone information is used as though localtime() calls tzset(). -- http://sourceware.org/bugzilla/show_bug.cgi?id=5184 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
next prev parent reply other threads:[~2007-10-16 8:13 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-10-16 2:25 [Bug libc/5184] New: " adi at hexapodia dot org 2007-10-16 5:45 ` [Bug libc/5184] " drepper at redhat dot com 2007-10-16 8:13 ` jakub at redhat dot com [this message] 2007-10-16 8:34 ` adi at hexapodia dot org 2008-08-13 0:24 ` mann at vmware dot com 2008-08-13 0:28 ` mann at vmware dot com
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=20071016081346.30396.qmail@sourceware.org \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sources.redhat.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).