This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
WG: missing TZ_LOCK
- From: "Becker, Andreas" <becker at se-elektronic dot de>
- To: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Mon, 27 Jun 2011 10:54:46 +0200
- Subject: WG: missing TZ_LOCK
Hi Folks,
We are using the localtime, mktime - ?functions really heavy. Sometimes a miscalculation happened.
With hard investigations, we could verify that the problem is a missing lock around the global __tzinfo_type *tz structure. ?
This structure is returned by __gettzinfo() and changed by __tz_calc_limits(year) .
Operations on this structure should be protected by TZ_LOCK() and TZ_UNLOCK().
This is correctly done in (newlib/time/) mktm_r.c, tzset_r.c and strftime.c but missing in mktime.c
--- a/newlib/libc/time/mktime.c Mon Jun 28 11:00:35 2010 +0200
+++ b/newlib/libc/time/mktime.c Mon Jun 27 10:18:58 2011 +0200
@@ -204,6 +204,8 @@
???isdst = tim_p->tm_isdst;
+? TZ_LOCK;
+???
???if (_daylight)
???? {
?????? int y = tim_p->tm_year + YEAR_BASE;
@@ -251,6 +253,8 @@
?? else /* otherwise assume std time */
???? tim += (time_t) tz->__tzrule[0].offset;
+? TZ_UNLOCK;
+?
???/* reset isdst flag to what we have calculated */
?? tim_p->tm_isdst = isdst;
Best regards,
Andi.
Mit freundlichen Grüßen
i.A. Andreas Becker
Entwicklung Embedded
_________________________________
SE-Elektronic GmbH
Eythstrasse 16
73037 Göppingen
Deutschland
Fon +49 (7161) 9584-0
Fax +49 (7161) 9584-30
becker@se-elektronic.de
www.se-elektronic.de
Geschäftsführer:
Bogomir Dajcman
Hermann Lippert
Sitz der Gesellschaft:?Göppingen
Handelsregister:?????????Amtsgericht Ulm HRB Nr. 531354