Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
	* time/tzfile.c (__tzfile_read): Avoid open for checking whether
	the file we already use changed.
  • Loading branch information
Ulrich Drepper committed Nov 20, 2004
1 parent d3a9cb0 commit 250ecb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2004-11-20 Ulrich Drepper <drepper@redhat.com>

* time/tzfile.c (__tzfile_read): Avoid open for checking whether
the file we already use changed.

* misc/syslog.c: Remove !USE_IN_LIBIO code.

2004-11-20 Jakub Jelinek <jakub@redhat.com>
Expand Down
23 changes: 13 additions & 10 deletions time/tzfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,30 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
file = new;
}

/* If we were already using tzfile, check whether the file changed. */
struct stat64 st;
if (was_using_tzfile
&& stat64 (file, &st) == 0
&& tzfile_ino == st.st_ino && tzfile_dev == st.st_dev
&& tzfile_mtime == st.st_mtime)
{
/* Nothing to do. */
__use_tzfile = 1;
return;
}

/* Note the file is opened with cancellation in the I/O functions
disabled. */
f = fopen (file, "rc");
if (f == NULL)
goto ret_free_transitions;

/* Get information about the file. */
struct stat64 st;
/* Get information about the file we are actually using. */
if (fstat64 (fileno (f), &st) != 0)
{
fclose (f);
goto ret_free_transitions;
}
if (was_using_tzfile && tzfile_ino == st.st_ino && tzfile_dev == st.st_dev
&& tzfile_mtime == st.st_mtime)
{
/* It's the same file. No further work needed. */
fclose (f);
__use_tzfile = 1;
return;
}

free ((void *) transitions);
transitions = NULL;
Expand Down

0 comments on commit 250ecb4

Please sign in to comment.