]> sourceware.org Git - glibc.git/commitdiff
[BZ #154]
authorUlrich Drepper <drepper@redhat.com>
Mon, 9 Aug 2004 07:24:19 +0000 (07:24 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 9 Aug 2004 07:24:19 +0000 (07:24 +0000)
Update.
2004-08-09  Ulrich Drepper  <drepper@redhat.com>

* 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 <franke@computer.org>.

* time/tzfile.c (__tzfile_read): Determine dev/ino of file.
Compare with values of previously opened file.  Don't do anything
is they match.

ChangeLog
time/tzfile.c
time/tzset.c

index 20c210d72e5fa46f5654226dc584be41d11d6af1..b0791cc535defaf3e5aafcabc572f8b858a7d533 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2004-08-09  Ulrich Drepper  <drepper@redhat.com>
+
+       * 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 <franke@computer.org>.
+
+       * time/tzfile.c (__tzfile_read): Determine dev/ino of file.
+       Compare with values of previously opened file.  Don't do anything
+       is they match.
+
 2004-08-08  Ulrich Drepper  <drepper@redhat.com>
 
        * elf/dl-load.c (_dl_map_object): If __RTLD_CALLMAP flag is set,
index 2c178253e4ae70da533e1c593de8d6f256d1d430..b118e07dc41dae18266b0e0c8360f0c6dad99e73 100644 (file)
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#include <sys/stat.h>
 
 #define        NOID
 #include <timezone/tzfile.h>
 
 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);
 
index 2274a38f59fc9959ae377d176a0b702975287fa4..aa866918e554f1888b66c54bb8790f66bce4c4ee 100644 (file)
@@ -159,10 +159,7 @@ tzset_internal (always)
 
   /* Examine the TZ environment variable.  */
   tz = getenv ("TZ");
-  if (tz == NULL)
-    /* No user specification; use the site-wide default.  */
-    tz = TZDEFAULT;
-  else if (*tz == '\0')
+  if (tz && *tz == '\0')
     /* User specified the empty string; use UTC explicitly.  */
     tz = "Universal";
 
@@ -177,6 +174,10 @@ tzset_internal (always)
     /* No change, simply return.  */
     return;
 
+  if (tz == NULL)
+    /* No user specification; use the site-wide default.  */
+    tz = TZDEFAULT;
+
   tz_rules[0].name = NULL;
   tz_rules[1].name = NULL;
 
This page took 0.050497 seconds and 5 git commands to generate.