[evolution-data-server] CamelSession: Avoid camel_session_lock/unlock().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] CamelSession: Avoid camel_session_lock/unlock().
- Date: Sun, 12 Aug 2012 20:07:17 +0000 (UTC)
commit cc7b1bf6b2cbea9afa0dac5e0f46989753d6e0f3
Author: Matthew Barnes <mbarnes redhat com>
Date: Sun Aug 12 08:05:08 2012 -0400
CamelSession: Avoid camel_session_lock/unlock().
Use an internal mutex to guard the services hash table.
camel/camel-session.c | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/camel/camel-session.c b/camel/camel-session.c
index 4b479cd..1af8b75 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -68,6 +68,8 @@ struct _CamelSessionPrivate {
gchar *user_cache_dir;
GHashTable *services;
+ GMutex *services_lock;
+
GHashTable *junk_headers;
CamelJunkFilter *junk_filter;
@@ -369,6 +371,8 @@ session_finalize (GObject *object)
g_mutex_free (priv->lock);
g_mutex_free (priv->thread_lock);
+ g_mutex_free (priv->services_lock);
+
if (priv->junk_headers) {
g_hash_table_remove_all (priv->junk_headers);
g_hash_table_destroy (priv->junk_headers);
@@ -426,13 +430,13 @@ session_add_service (CamelSession *session,
/* The hash table takes ownership of the new CamelService. */
if (service != NULL) {
- camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
+ g_mutex_lock (session->priv->services_lock);
g_hash_table_insert (
session->priv->services,
g_strdup (uid), service);
- camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
+ g_mutex_unlock (session->priv->services_lock);
}
return service;
@@ -444,12 +448,12 @@ session_remove_service (CamelSession *session,
{
const gchar *uid;
- camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
+ g_mutex_lock (session->priv->services_lock);
uid = camel_service_get_uid (service);
g_hash_table_remove (session->priv->services, uid);
- camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
+ g_mutex_unlock (session->priv->services_lock);
}
static void
@@ -864,6 +868,7 @@ camel_session_init (CamelSession *session)
session->priv->lock = g_mutex_new ();
session->priv->thread_lock = g_mutex_new ();
session->priv->services = services;
+ session->priv->services_lock = g_mutex_new ();
session->priv->junk_headers = NULL;
session->priv->main_context = g_main_context_ref_thread_default ();
@@ -1019,11 +1024,11 @@ camel_session_get_service (CamelSession *session,
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
g_return_val_if_fail (uid != NULL, NULL);
- camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
+ g_mutex_lock (session->priv->services_lock);
service = g_hash_table_lookup (session->priv->services, uid);
- camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
+ g_mutex_unlock (session->priv->services_lock);
return service;
}
@@ -1121,11 +1126,11 @@ camel_session_list_services (CamelSession *session)
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
- camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
+ g_mutex_lock (session->priv->services_lock);
list = g_hash_table_get_values (session->priv->services);
- camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
+ g_mutex_unlock (session->priv->services_lock);
return list;
}
@@ -1147,11 +1152,11 @@ camel_session_remove_services (CamelSession *session)
{
g_return_if_fail (CAMEL_IS_SESSION (session));
- camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
+ g_mutex_lock (session->priv->services_lock);
g_hash_table_remove_all (session->priv->services);
- camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
+ g_mutex_unlock (session->priv->services_lock);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]