Index: trunk/libical/src/libical/icaltimezone.c =================================================================== --- trunk/libical/src/libical/icaltimezone.c (revision 1038) +++ trunk/libical/src/libical/icaltimezone.c (revision 1039) @@ -45,6 +45,11 @@ #include +#ifdef HAVE_PTHREAD +#include +static pthread_mutex_t builtin_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + #ifdef WIN32 #include #include @@ -453,8 +458,7 @@ int changes_end_year; - if (!zone->component) - icaltimezone_load_builtin_timezone (zone); + icaltimezone_load_builtin_timezone (zone); if (icaltimezone_minimum_expansion_year == -1) { struct icaltimetype today = icaltime_today(); @@ -1140,8 +1144,7 @@ if (!zone) return NULL; - if (!zone->tzid) - icaltimezone_load_builtin_timezone (zone); + icaltimezone_load_builtin_timezone (zone); return zone->tzid; } @@ -1167,8 +1170,7 @@ if (!zone) return NULL; - if (!zone->component) - icaltimezone_load_builtin_timezone (zone); + icaltimezone_load_builtin_timezone (zone); return zone->tznames; } @@ -1210,8 +1212,7 @@ if (!zone) return NULL; - if (!zone->component) - icaltimezone_load_builtin_timezone (zone); + icaltimezone_load_builtin_timezone (zone); return zone->component; } @@ -1449,8 +1450,7 @@ for (i=0; icomponent) - icaltimezone_load_builtin_timezone (zone); + icaltimezone_load_builtin_timezone (zone); z_offset = get_offset(zone); @@ -1745,6 +1745,12 @@ if (!zone->location || !zone->location[0]) return; +#ifdef HAVE_PTHREAD + pthread_mutex_lock(&builtin_mutex); + if (zone->component) + goto out; +#endif + #ifdef USE_BUILTIN_TZDATA { char *filename; @@ -1801,8 +1807,11 @@ icalcomponent_remove_component(comp,subcomp); icalcomponent_free(comp); } -#endif - +#endif +#ifdef HAVE_PTHREAD + out: + pthread_mutex_unlock(&builtin_mutex); +#endif }