[evolution-data-server] Bug 650105 - Deadlock in GroupWise connector



commit cbffddcccfc279482bc81ba426d1a15049ffb542
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat May 14 06:53:24 2011 -0400

    Bug 650105 - Deadlock in GroupWise connector
    
    Instead of acquiring the CamelSession lock for the entire add_service()
    method, only acquire it when directly accessing the shared 'services'
    hash table.  This allows camel_session_add_service() calls to be nested,
    which is what CamelGroupwiseStore does.

 camel/camel-session.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/camel/camel-session.c b/camel/camel-session.c
index ddd57ac..373b39a 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -312,7 +312,7 @@ session_add_service (CamelSession *session,
 	CamelProvider *provider;
 	GType service_type = G_TYPE_INVALID;
 
-	service = g_hash_table_lookup (session->priv->services, uid);
+	service = camel_session_get_service (session, uid);
 	if (CAMEL_IS_SERVICE (service))
 		return service;
 
@@ -356,11 +356,16 @@ session_add_service (CamelSession *session,
 		session, "uid", uid, "url", url, NULL);
 
 	/* The hash table takes ownership of the new CamelService. */
-	if (service != NULL)
+	if (service != NULL) {
+		camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
+
 		g_hash_table_insert (
 			session->priv->services,
 			g_strdup (uid), service);
 
+		camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
+	}
+
 	camel_url_free (url);
 
 	return service;
@@ -535,13 +540,9 @@ camel_session_add_service (CamelSession *session,
 	class = CAMEL_SESSION_GET_CLASS (session);
 	g_return_val_if_fail (class->add_service != NULL, NULL);
 
-	camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
-
 	service = class->add_service (session, uid, uri_string, type, error);
 	CAMEL_CHECK_GERROR (session, add_service, service != NULL, error);
 
-	camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
-
 	return service;
 }
 



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