mirror of
https://git.freebsd.org/src.git
synced 2026-01-11 19:57:22 +00:00
tzcode: Fix early tz change detection
Assume tzdata is not fresh if last_checked is zero, as comparing the current time to last_checked less than __tz_change_interval after boot may produce a false negative. While here, invert the return value from tzdata_is_fresh() to better match its new name (it was previously called recheck_tzdata(), so zero for fresh and non-zero for stale made sense, but it doesn't now). PR: 269207 MFC after: 3 days Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53502
This commit is contained in:
parent
92a533ed1d
commit
a38c2f99f8
1 changed files with 7 additions and 7 deletions
|
|
@ -1583,15 +1583,15 @@ tzdata_is_fresh(void)
|
|||
struct timespec now;
|
||||
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &now) < 0)
|
||||
return 0;
|
||||
|
||||
if ((now.tv_sec - last_checked >= __tz_change_interval) ||
|
||||
(last_checked > now.tv_sec)) {
|
||||
last_checked = now.tv_sec;
|
||||
return 1;
|
||||
|
||||
if (last_checked == 0 || last_checked > now.tv_sec ||
|
||||
now.tv_sec - last_checked >= __tz_change_interval) {
|
||||
last_checked = now.tv_sec;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
#endif /* DETECT_TZ_CHANGES */
|
||||
|
||||
|
|
@ -1642,7 +1642,7 @@ tzset_unlocked_name(char const *name)
|
|||
? lcl_is_set < 0
|
||||
: 0 < lcl_is_set && strcmp(lcl_TZname, name) == 0)
|
||||
#ifdef DETECT_TZ_CHANGES
|
||||
if (tzdata_is_fresh() == 0)
|
||||
if (tzdata_is_fresh())
|
||||
#endif /* DETECT_TZ_CHANGES */
|
||||
return;
|
||||
# ifdef ALL_STATE
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue