From fe6cc2ae0947c91d9daf844dccc44a8c76deb767 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 9 Aug 2004 07:24:19 +0000 Subject: [BZ #154] Update. 2004-08-09 Ulrich Drepper * time/tzset.c (tzset_internal): If TZ is not set do not compare old and new tz value since it might be /etc/localtime in both cases although the file changed. [BZ #154] Patch by Christian Franke . * time/tzfile.c (__tzfile_read): Determine dev/ino of file. Compare with values of previously opened file. Don't do anything is they match. --- time/tzfile.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'time/tzfile.c') diff --git a/time/tzfile.c b/time/tzfile.c index 2c178253e4..b118e07dc4 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -24,11 +24,14 @@ #include #include #include +#include #define NOID #include int __use_tzfile; +static dev_t tzfile_dev; +static ino64_t tzfile_ino; struct ttinfo { @@ -97,6 +100,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) size_t total_size; size_t types_idx; size_t leaps_idx; + int was_using_tzfile = __use_tzfile; __use_tzfile = 0; @@ -154,6 +158,25 @@ __tzfile_read (const char *file, size_t extra, char **extrap) if (f == NULL) return; + /* Get information about the file. */ + struct stat64 st; + if (fstat64 (fileno (f), &st) != 0) + { + fclose (f); + return; + } + if (was_using_tzfile && tzfile_ino == st.st_ino && tzfile_dev == st.st_dev) + { + /* It's the same file. No further work needed. */ + fclose (f); + __use_tzfile = 1; + return; + } + + /* Remember the inode and device number. */ + tzfile_dev = st.st_dev; + tzfile_ino = st.st_ino; + /* No threads reading this stream. */ __fsetlocking (f, FSETLOCKING_BYCALLER); -- cgit v1.2.3