[evolution-data-server] Pre-load all built-in timezones in libical on calendar factory start



commit f3a1b06f7fc28974c9a048a440bc2d2379075571
Author: Milan Crha <mcrha redhat com>
Date:   Wed Nov 23 09:30:37 2011 +0100

    Pre-load all built-in timezones in libical on calendar factory start
    
    This is the same fix as was done in evolution within bug #628139

 calendar/libedata-cal/e-data-cal-factory.c |   33 +++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index 66b5a81..d65c042 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -37,9 +37,7 @@
 
 #include "e-gdbus-cal-factory.h"
 
-#ifdef HAVE_ICAL_UNKNOWN_TOKEN_HANDLING
 #include <libical/ical.h>
-#endif
 
 #define d(x)
 
@@ -440,8 +438,37 @@ EDBusServer *
 e_data_cal_factory_new (GCancellable *cancellable,
                         GError **error)
 {
+	icalarray *builtin_timezones;
+	gint ii;
+
+#ifdef HAVE_ICAL_UNKNOWN_TOKEN_HANDLING
+	ical_set_unknown_token_handling_setting (ICAL_DISCARD_TOKEN);
+#endif
+
+	/* XXX Pre-load all built-in timezones in libical.
+	 *
+	 *     Built-in time zones in libical 0.43 are loaded on demand,
+	 *     but not in a thread-safe manner, resulting in a race when
+	 *     multiple threads call icaltimezone_load_builtin_timezone()
+	 *     on the same time zone.  Until built-in time zone loading
+	 *     in libical is made thread-safe, work around the issue by
+	 *     loading all built-in time zones now, so libical's internal
+	 *     time zone array will be fully populated before any threads
+	 *     are spawned.
+	 */
+	builtin_timezones = icaltimezone_get_builtin_timezones ();
+	for (ii = 0; ii < builtin_timezones->num_elements; ii++) {
+		icaltimezone *zone;
+
+		zone = icalarray_element_at (builtin_timezones, ii);
+
+		/* We don't care about the component right now,
+		 * we just need some function that will trigger
+		 * icaltimezone_load_builtin_timezone(). */
+		icaltimezone_get_component (zone);
+	}
+
 	return g_initable_new (
 		E_TYPE_DATA_CAL_FACTORY,
 		cancellable, error, NULL);
 }
-



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]