[evolution-kolab/ek-wip-porting] ECalBackendKolab: GLib 2.32 GMutex fixups



commit 1fc7e45e311b7dbf93b447a01ed3ddcd5c312a7c
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Jun 15 18:26:37 2012 +0200

    ECalBackendKolab: GLib 2.32 GMutex fixups
    
    * g_mutex_new() / g_mutex_free() have been deprecated
      in GLib 2.32 in favor of g_mutex_init() / g_mutex_clear()

 src/calendar/e-cal-backend-kolab.c |   48 +++++++----------------------------
 1 files changed, 10 insertions(+), 38 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-kolab.c b/src/calendar/e-cal-backend-kolab.c
index 5661b79..54d638a 100644
--- a/src/calendar/e-cal-backend-kolab.c
+++ b/src/calendar/e-cal-backend-kolab.c
@@ -49,8 +49,8 @@
 /* table of KolabMailAccess objects */
 
 static GHashTable *koma_objects = NULL;
-static GMutex *koma_objects_lock = NULL;
-static GMutex *active_cal_views_lock = NULL;
+static GMutex koma_objects_lock;
+static GMutex active_cal_views_lock;
 
 /*----------------------------------------------------------------------------*/
 /* forward declarations */
@@ -77,14 +77,6 @@ G_DEFINE_TYPE (ECalBackendKolab, e_cal_backend_kolab, E_TYPE_CAL_BACKEND_SYNC)
 
 /* private structures for Kolab calendar class ********************************/
 
-/* TODO check what is appropriate for Kolab here */
-
-typedef struct {
-	GCond *cond;
-	GMutex *mutex;
-	gboolean exit;
-} SyncDelta;
-
 /* Private part of the ECalBackendKolab structure */
 typedef struct _ECalBackendKolabPrivate ECalBackendKolabPrivate;
 struct _ECalBackendKolabPrivate {
@@ -259,7 +251,7 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
 	self = E_CAL_BACKEND_KOLAB (backend);
 	priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
 
-	g_mutex_lock (koma_objects_lock);
+	g_mutex_lock (&koma_objects_lock);
 
 	/* to trigger eds to pass along username and password, set the property
 	 * "auth" to "true" in the source setting:
@@ -438,7 +430,7 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
 	if (ksettings != NULL)
 		g_object_unref (ksettings);
 
-	g_mutex_unlock (koma_objects_lock);
+	g_mutex_unlock (&koma_objects_lock);
 
 	if (c_url != NULL)
 		camel_url_free (c_url);
@@ -1780,7 +1772,7 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
 	self = E_CAL_BACKEND_KOLAB (backend);
 	priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
 
-	g_mutex_lock (active_cal_views_lock);
+	g_mutex_lock (&active_cal_views_lock);
 
 	g_object_ref (view); /* unref()d in stop_view() */
 
@@ -1851,7 +1843,7 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
 
 	e_data_cal_view_notify_complete (view, view_err);
 
-	g_mutex_unlock (active_cal_views_lock);
+	g_mutex_unlock (&active_cal_views_lock);
 
 	if (view_err != NULL)
 		g_error_free (view_err);
@@ -1880,13 +1872,13 @@ e_cal_backend_kolab_stop_view (ECalBackend *backend,
 	/* self = E_CAL_BACKEND_KOLAB (backend); */
 	/* priv = E_CAL_BACKEND_KOLAB_PRIVATE (self); */
 
-	g_mutex_lock (active_cal_views_lock);
+	g_mutex_lock (&active_cal_views_lock);
 
 	e_data_cal_view_notify_complete (view, NULL);
 
 	g_object_unref (view); /* ref()d in start_view() */
 
-	g_mutex_unlock (active_cal_views_lock);
+	g_mutex_unlock (&active_cal_views_lock);
 }
 
 /*----------------------------------------------------------------------------*/
@@ -1898,33 +1890,13 @@ e_cal_backend_kolab_init (ECalBackendKolab *backend)
 	ECalBackendKolab *self = E_CAL_BACKEND_KOLAB (backend);
 	ECalBackendKolabPrivate *priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
 
-	/* We're inside a thread, and each of our siblings
-	 * (other configured ECalBackendKolab instances) is
-	 * so as well. Depending on how the threads are
-	 * started, checking for lock existence (and creating
-	 * one if it is not) in *this* place can still be
-	 * racy. Let's hope the threads are started one
-	 * at a time, in which case this solution will work.
-	 * The whole handling of living KolabMailAccess
-	 * instances would better be moved to a separate
-	 * library...
-	 *
-	 */
-	if (koma_objects_lock == NULL)
-		koma_objects_lock = g_mutex_new ();
-	g_mutex_lock (koma_objects_lock);
+	g_mutex_lock (&koma_objects_lock);
 	if (koma_objects == NULL)
 		koma_objects = g_hash_table_new_full (g_direct_hash,
 		                                      g_direct_equal,
 		                                      g_free,
 		                                      g_object_unref);
-	g_mutex_unlock (koma_objects_lock);
-	/* active cal views are shared in the same way,
-	 * so we do the locking for them analogous
-	 * to the KolabMailAccess instances
-	 */
-	if (active_cal_views_lock == NULL)
-		active_cal_views_lock = g_mutex_new ();
+	g_mutex_unlock (&koma_objects_lock);
 
 	g_debug ("%s()[%u] called.", __func__, __LINE__);
 



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