From 855ae5eed1eeae0cfe271a5a47d6fb8abf21d691 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 31 Oct 2010 11:31:10 -0400 Subject: Bug 628139 - Thread-safety issues in libical time zone loading --- modules/calendar/e-cal-shell-backend.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'modules/calendar') diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c index 134f706054..749dd7ec19 100644 --- a/modules/calendar/e-cal-shell-backend.c +++ b/modules/calendar/e-cal-shell-backend.c @@ -769,8 +769,34 @@ cal_shell_backend_class_init (ECalShellBackendClass *class) static void cal_shell_backend_init (ECalShellBackend *cal_shell_backend) { + icalarray *builtin_timezones; + gint ii; + cal_shell_backend->priv = E_CAL_SHELL_BACKEND_GET_PRIVATE (cal_shell_backend); + + /* 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); + } } GType -- cgit v1.2.3