[tz] [PROPOSED PATCH] Make the library thread-safe if THREAD_SAFE is defined.

Paul Eggert eggert at cs.ucla.edu
Mon Aug 25 01:56:39 UTC 2014


Attached is another fixup for that patch, to fix a race that could cause 
two threads try to assign to tzname simultaneously.  Only tzset-like 
functions (or functions documented to call tzset) should assign to 
tzname anyway.  The commentary for this fixup can be:

(localsub): Don't set tzname here; that's not thread-safe.  This change 
can lose information on hosts without TM_ZONE, but there is no reliable 
way to fix that in a thread-safe way.
-------------- next part --------------
diff --git a/localtime.c b/localtime.c
index f499583..1df3fba 100644
--- a/localtime.c
+++ b/localtime.c
@@ -1322,7 +1322,6 @@ localsub(const time_t *const timep, const int_fast32_t offset,
 	*/
 	result = timesub(&t, ttisp->tt_gmtoff, sp, tmp);
 	tmp->tm_isdst = ttisp->tt_isdst;
-	tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind];
 #ifdef TM_ZONE
 	tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind];
 #endif /* defined TM_ZONE */


More information about the tz mailing list