[evolution-data-server] [ECalClient] Do not replace cached timezones



commit 260b0f229b767e4c4b3baa98eb93b8308b9f48c1
Author: Milan Crha <mcrha redhat com>
Date:   Thu Feb 5 19:12:32 2015 +0100

    [ECalClient] Do not replace cached timezones
    
    It can be that another thread already filled the zone into the cache,
    thus deal with it properly, because that other zone can be used by that
    other thread.

 calendar/libecal/e-cal-client.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c
index 09d115b..2137c59 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -6916,8 +6916,16 @@ e_cal_client_get_timezone_sync (ECalClient *client,
         * otherwise we'd have to free this struct
         * and fetch the cached copy. */
        g_mutex_lock (&client->priv->zone_cache_lock);
-       g_hash_table_insert (
-               client->priv->zone_cache, g_strdup (tzid), zone);
+       if (g_hash_table_lookup (client->priv->zone_cache, tzid)) {
+               /* It can be that another thread already filled the zone into the cache,
+                  thus deal with it properly, because that other zone can be used by that
+                  other thread. */
+               icaltimezone_free (zone, 1);
+               zone = g_hash_table_lookup (client->priv->zone_cache, tzid);
+       } else {
+               g_hash_table_insert (
+                       client->priv->zone_cache, g_strdup (tzid), zone);
+       }
        g_mutex_unlock (&client->priv->zone_cache_lock);
 
        *out_zone = zone;


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