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



commit 79d3e77aa172edf47ab0f458c7949b8a78643610
Author: Dan Nicholson <nicholson endlessm com>
Date:   Tue Mar 27 17:25:44 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     |   29 ++++++++++++++++++++
 .../libedata-cal/e-subprocess-cal-factory.c        |   29 ++++++++++++++++++++
 2 files changed, 58 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 baaeb5f..b9adf05 100644
--- a/src/calendar/libedata-cal/e-data-cal-factory.c
+++ b/src/calendar/libedata-cal/e-data-cal-factory.c
@@ -49,6 +49,26 @@
 
 #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.
+ */
+#if defined(ICAL_CHECK_VERSION) && defined(ICAL_MAJOR_VERSION) && defined(ICAL_MINOR_VERSION) && 
defined(ICAL_MICRO_VERSION)
+#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)))
+#else
+#if defined(ICAL_CHECK_VERSION)
+#undef ICAL_CHECK_VERSION
+#endif
+#define ICAL_CHECK_VERSION(major,minor,micro) (0)
+#endif
+
 #define d(x)
 
 #define E_DATA_CAL_FACTORY_GET_PRIVATE(obj) \
@@ -272,8 +292,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);
@@ -283,6 +305,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,
@@ -293,6 +316,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++) {
@@ -305,6 +333,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..7547a30 100644
--- a/src/calendar/libedata-cal/e-subprocess-cal-factory.c
+++ b/src/calendar/libedata-cal/e-subprocess-cal-factory.c
@@ -38,6 +38,26 @@
 
 #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.
+ */
+#if defined(ICAL_CHECK_VERSION) && defined(ICAL_MAJOR_VERSION) && defined(ICAL_MINOR_VERSION) && 
defined(ICAL_MICRO_VERSION)
+#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)))
+#else
+#if defined(ICAL_CHECK_VERSION)
+#undef ICAL_CHECK_VERSION
+#endif
+#define ICAL_CHECK_VERSION(major,minor,micro) (0)
+#endif
+
 /* Forward Declarations */
 static void    e_subprocess_cal_factory_initable_init
                                                (GInitableIface *iface);
@@ -137,8 +157,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 +170,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 +181,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 +198,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]