[evolution-data-server/evolution-data-server-3-12] Bug 701138 - Make e_cal_backend_sexp_match_comp() thread safe
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/evolution-data-server-3-12] Bug 701138 - Make e_cal_backend_sexp_match_comp() thread safe
- Date: Wed, 26 Nov 2014 18:28:24 +0000 (UTC)
commit cb54f200e5fc1f517b8e047a1b54c33c4b6ba18e
Author: Milan Crha <mcrha redhat com>
Date: Wed Nov 26 19:25:12 2014 +0100
Bug 701138 - Make e_cal_backend_sexp_match_comp() thread safe
calendar/libedata-cal/e-cal-backend-sexp.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/calendar/libedata-cal/e-cal-backend-sexp.c b/calendar/libedata-cal/e-cal-backend-sexp.c
index af30224..3e9eaf5 100644
--- a/calendar/libedata-cal/e-cal-backend-sexp.c
+++ b/calendar/libedata-cal/e-cal-backend-sexp.c
@@ -45,6 +45,7 @@ struct _ECalBackendSExpPrivate {
ESExp *search_sexp;
gchar *text;
SearchContext *search_context;
+ GMutex search_context_lock;
};
struct _SearchContext {
@@ -1104,6 +1105,7 @@ cal_backend_sexp_finalize (GObject *object)
e_sexp_unref (priv->search_sexp);
g_free (priv->text);
g_free (priv->search_context);
+ g_mutex_clear (&priv->search_context_lock);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (e_cal_backend_sexp_parent_class)->finalize (object);
@@ -1125,6 +1127,8 @@ e_cal_backend_sexp_init (ECalBackendSExp *sexp)
{
sexp->priv = E_CAL_BACKEND_SEXP_GET_PRIVATE (sexp);
sexp->priv->search_context = g_new (SearchContext, 1);
+
+ g_mutex_init (&sexp->priv->search_context_lock);
}
/* 'builtin' functions */
@@ -1254,6 +1258,8 @@ e_cal_backend_sexp_match_comp (ECalBackendSExp *sexp,
g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), FALSE);
g_return_val_if_fail (E_IS_TIMEZONE_CACHE (cache), FALSE);
+ g_mutex_lock (&sexp->priv->search_context_lock);
+
sexp->priv->search_context->comp = g_object_ref (comp);
sexp->priv->search_context->cache = g_object_ref (cache);
@@ -1266,6 +1272,8 @@ e_cal_backend_sexp_match_comp (ECalBackendSExp *sexp,
e_sexp_result_free (sexp->priv->search_sexp, r);
+ g_mutex_unlock (&sexp->priv->search_context_lock);
+
return retval;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]