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



commit a1a172c7664c9c99e1f3b54ed40f5e9297287a86
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 baf0c3c..a560660 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -6710,8 +6710,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]