[evolution-data-server] Bug 794628 - Don't preload timezones on libical 3.0.2+



commit 9c775b4fccdecb232851fe1a29271bb4e8d93503
Author: Dan Nicholson <nicholson endlessm com>
Date:   Tue Mar 27 17:11:39 2018 +0200

    Bug 794628 - Don't preload timezones on libical 3.0.2+
    
    Apparently multithreaded uses of icaltimezone has been fixed in 3.0.1[1]
    and 3.0.2[2]. Don't preload the timezones in that case as they take up
    an enormous amount of heap. Unfortunately, the ICAL_CHECK_VERSION macro
    needed to check the version has been broken until recently[3]. Redefine
    it locally until the libical build requirement is new enough to contain
    the fixed macro in ical.h.
    
    1. https://github.com/libical/libical/releases/tag/v3.0.1
    2. https://github.com/libical/libical/releases/tag/v3.0.2
    3. https://github.com/libical/libical/pull/335

 src/calendar/libedata-cal/e-data-cal-factory.c     |   22 ++++++++++++++++++++
 .../libedata-cal/e-subprocess-cal-factory.c        |   22 ++++++++++++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/src/calendar/libedata-cal/e-data-cal-factory.c b/src/calendar/libedata-cal/e-data-cal-factory.c
index 808abf7..c90db3e 100644
--- a/src/calendar/libedata-cal/e-data-cal-factory.c
+++ b/src/calendar/libedata-cal/e-data-cal-factory.c
@@ -49,6 +49,19 @@
 
 #include <libical/ical.h>
 
+/*
+ * FIXME: Remove this when there's a build time dependency on libical
+ * 3.0.4 (where this is fixed). See
+ * https://github.com/libical/libical/pull/335 and the implementation in
+ * https://github.com/libical/libical/blob/master/src/libical/icalversion.h.cmake.
+ */
+#undef ICAL_CHECK_VERSION
+#define ICAL_CHECK_VERSION(major,minor,micro)                          \
+    (ICAL_MAJOR_VERSION > (major) ||                                   \
+    (ICAL_MAJOR_VERSION == (major) && ICAL_MINOR_VERSION > (minor)) || \
+    (ICAL_MAJOR_VERSION == (major) && ICAL_MINOR_VERSION == (minor) && \
+    ICAL_MICRO_VERSION >= (micro)))
+
 #define d(x)
 
 #define E_DATA_CAL_FACTORY_GET_PRIVATE(obj) \
@@ -364,8 +377,10 @@ e_data_cal_factory_new (gint backend_per_process,
                        GCancellable *cancellable,
                         GError **error)
 {
+#if !ICAL_CHECK_VERSION(3, 0, 2)
        icalarray *builtin_timezones;
        gint ii;
+#endif
 
 #ifdef HAVE_ICAL_UNKNOWN_TOKEN_HANDLING
        ical_set_unknown_token_handling_setting (ICAL_DISCARD_TOKEN);
@@ -375,6 +390,7 @@ e_data_cal_factory_new (gint backend_per_process,
        icaltzutil_set_exact_vtimezones_support (0);
 #endif
 
+#if !ICAL_CHECK_VERSION(3, 0, 2)
        /* XXX Pre-load all built-in timezones in libical.
         *
         *     Built-in time zones in libical 0.43 are loaded on demand,
@@ -385,6 +401,11 @@ e_data_cal_factory_new (gint backend_per_process,
         *     loading all built-in time zones now, so libical's internal
         *     time zone array will be fully populated before any threads
         *     are spawned.
+        *
+        *     This is apparently fixed with additional locking in
+        *     libical 3.0.1 and 3.0.2:
+        *     https://github.com/libical/libical/releases/tag/v3.0.1
+        *     https://github.com/libical/libical/releases/tag/v3.0.2
         */
        builtin_timezones = icaltimezone_get_builtin_timezones ();
        for (ii = 0; ii < builtin_timezones->num_elements; ii++) {
@@ -397,6 +418,7 @@ e_data_cal_factory_new (gint backend_per_process,
                 * icaltimezone_load_builtin_timezone(). */
                icaltimezone_get_component (zone);
        }
+#endif
 
        return g_initable_new (E_TYPE_DATA_CAL_FACTORY, cancellable, error,
                "reload-supported", TRUE,
diff --git a/src/calendar/libedata-cal/e-subprocess-cal-factory.c 
b/src/calendar/libedata-cal/e-subprocess-cal-factory.c
index c4aa3f4..92728de 100644
--- a/src/calendar/libedata-cal/e-subprocess-cal-factory.c
+++ b/src/calendar/libedata-cal/e-subprocess-cal-factory.c
@@ -38,6 +38,19 @@
 
 #include <e-dbus-subprocess-backend.h>
 
+/*
+ * FIXME: Remove this when there's a build time dependency on libical
+ * 3.0.4 (where this is fixed). See
+ * https://github.com/libical/libical/pull/335 and the implementation in
+ * https://github.com/libical/libical/blob/master/src/libical/icalversion.h.cmake.
+ */
+#undef ICAL_CHECK_VERSION
+#define ICAL_CHECK_VERSION(major,minor,micro)                          \
+    (ICAL_MAJOR_VERSION > (major) ||                                   \
+    (ICAL_MAJOR_VERSION == (major) && ICAL_MINOR_VERSION > (minor)) || \
+    (ICAL_MAJOR_VERSION == (major) && ICAL_MINOR_VERSION == (minor) && \
+    ICAL_MICRO_VERSION >= (micro)))
+
 /* Forward Declarations */
 static void    e_subprocess_cal_factory_initable_init
                                                (GInitableIface *iface);
@@ -137,8 +150,10 @@ ESubprocessCalFactory *
 e_subprocess_cal_factory_new (GCancellable *cancellable,
                               GError **error)
 {
+#if !ICAL_CHECK_VERSION(3, 0, 2)
        icalarray *builtin_timezones;
        gint ii;
+#endif
 
 #ifdef HAVE_ICAL_UNKNOWN_TOKEN_HANDLING
        ical_set_unknown_token_handling_setting (ICAL_DISCARD_TOKEN);
@@ -148,6 +163,7 @@ e_subprocess_cal_factory_new (GCancellable *cancellable,
        icaltzutil_set_exact_vtimezones_support (0);
 #endif
 
+#if !ICAL_CHECK_VERSION(3, 0, 2)
        /* XXX Pre-load all built-in timezones in libical.
         *
         *     Built-in time zones in libical 0.43 are loaded on demand,
@@ -158,6 +174,11 @@ e_subprocess_cal_factory_new (GCancellable *cancellable,
         *     loading all built-in time zones now, so libical's internal
         *     time zone array will be fully populated before any threads
         *     are spawned.
+        *
+        *     This is apparently fixed with additional locking in
+        *     libical 3.0.1 and 3.0.2:
+        *     https://github.com/libical/libical/releases/tag/v3.0.1
+        *     https://github.com/libical/libical/releases/tag/v3.0.2
         */
        builtin_timezones = icaltimezone_get_builtin_timezones ();
        for (ii = 0; ii < builtin_timezones->num_elements; ii++) {
@@ -170,6 +191,7 @@ e_subprocess_cal_factory_new (GCancellable *cancellable,
                 * icaltimezone_load_builtin_timezone(). */
                icaltimezone_get_component (zone);
        }
+#endif
 
        return g_initable_new (
                E_TYPE_SUBPROCESS_CAL_FACTORY,


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