git: ddedf2a11eb2 - main - tzcode: Implement timezone change detection

Edward Napierala trasz at freebsd.org
Tue Sep 14 18:56:45 UTC 2021


> On 14 Sep 2021, at 17:39, Bryan Drewery <bdrewery at freebsd.org> wrote:
> 
> On 9/13/2021 7:42 AM, Edward Tomasz Napierala wrote:
>> +#else /* !DETECT_TZ_CHANGES */
>> +#define	change_in_tz(X)	0
> 
> WITHOUT_DETECT_TZ_CHANGES: change_in_tz() == 0
> 
>> +#endif /* !DETECT_TZ_CHANGES */
>> +
>> static int
>> differ_by_repeat(const time_t t1, const time_t t0)
>> {
>> @@ -379,6 +418,7 @@ register const int	doextend;
>> 	int		stored;
>> 	int		nread;
>> 	int		res;
>> +	int		ret;
>> 	union {
>> 		struct tzhead	tzhead;
>> 		char		buf[2 * sizeof(struct tzhead) +
>> @@ -427,6 +467,22 @@ register const int	doextend;
>> 			(void) strcat(fullname, name);
>> 			name = fullname;
>> 		}
>> +		if (doextend == TRUE) {
>> +			/*
>> +			 * Detect if the timezone file has changed.  Check
>> +			 * 'doextend' to ignore TZDEFRULES; the change_in_tz()
>> +			 * function can only keep state for a single file.
>> +			 */
>> +			ret = change_in_tz(name);
>> +			if (ret <= 0) {
> 
> WITHOUT_DETECT_TZ_CHANGES: Always returns a false-positive "done" but
> short-circuits the rest of tzload().
> 
>> +				/*
>> +				 * Returns -1 if there was an error,
>> +				 * and 0 if the timezone had not changed.
>> +				 */
>> +				free(fullname);
>> +				return ret;
>> +			}
>> +		}

Thanks!  No idea how I could miss this.  Does https://reviews.freebsd.org/D31961
look reasonable?



More information about the dev-commits-src-main mailing list