[evolution-data-server/gnome-3-6] Bug #691298 - Deadlock under e_cal_backend_foreach_view()



commit aa7d79d6432503787a1ba72a50d54529543225f5
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jan 11 09:13:21 2013 +0100

    Bug #691298 - Deadlock under e_cal_backend_foreach_view()

 addressbook/libedata-book/e-book-backend.c |   11 +++++++----
 calendar/libedata-cal/e-cal-backend.c      |   14 +++++++-------
 2 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend.c b/addressbook/libedata-book/e-book-backend.c
index 83fd371..a6b878b 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -859,7 +859,7 @@ e_book_backend_foreach_view (EBookBackend *backend,
                                                    gpointer user_data),
                              gpointer user_data)
 {
-	const GSList *views;
+	GSList *views_list, *viter;
 	EDataBookView *view;
 	gboolean stop = FALSE;
 
@@ -867,13 +867,16 @@ e_book_backend_foreach_view (EBookBackend *backend,
 	g_return_if_fail (callback != NULL);
 
 	g_mutex_lock (backend->priv->views_mutex);
+	views_list = g_slist_copy (backend->priv->views);
+	g_slist_foreach (views_list, (GFunc) g_object_ref, NULL);
+	g_mutex_unlock (backend->priv->views_mutex);
 
-	for (views = backend->priv->views; views && !stop; views = views->next) {
-		view = E_DATA_BOOK_VIEW (views->data);
+	for (viter = views_list; viter && !stop; viter = viter->next) {
+		view = E_DATA_BOOK_VIEW (viter->data);
 		stop = !callback (view, user_data);
 	}
 
-	g_mutex_unlock (backend->priv->views_mutex);
+	g_slist_free_full (views_list, g_object_unref);
 }
 
 /**
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index 4258780..425561f 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -776,7 +776,7 @@ e_cal_backend_foreach_view (ECalBackend *backend,
                                                   gpointer user_data),
                             gpointer user_data)
 {
-	const GSList *views;
+	GSList *views_list, *viter;
 	EDataCalView *view;
 	gboolean stop = FALSE;
 
@@ -784,16 +784,16 @@ e_cal_backend_foreach_view (ECalBackend *backend,
 	g_return_if_fail (callback != NULL);
 
 	g_mutex_lock (backend->priv->views_mutex);
+	views_list = g_slist_copy (backend->priv->views);
+	g_slist_foreach (views_list, (GFunc) g_object_ref, NULL);
+	g_mutex_unlock (backend->priv->views_mutex);
 
-	for (views = backend->priv->views; views && !stop; views = views->next) {
-		view = E_DATA_CAL_VIEW (views->data);
-
-		g_object_ref (view);
+	for (viter = views_list; viter && !stop; viter = viter->next) {
+		view = E_DATA_CAL_VIEW (viter->data);
 		stop = !callback (view, user_data);
-		g_object_unref (view);
 	}
 
-	g_mutex_unlock (backend->priv->views_mutex);
+	g_slist_free_full (views_list, g_object_unref);
 }
 
 /**



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