[evolution-ews] Bug #671969 - Crash in g_thread_join, e_ews_connection_dispose
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug #671969 - Crash in g_thread_join, e_ews_connection_dispose
- Date: Tue, 3 Apr 2012 09:17:30 +0000 (UTC)
commit 6ee9d804523c5ce00b649c6d16838d6221abd823
Author: Milan Crha <mcrha redhat com>
Date: Tue Apr 3 11:17:01 2012 +0200
Bug #671969 - Crash in g_thread_join, e_ews_connection_dispose
src/server/e-ews-connection.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 082d418..b1f7763 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -316,6 +316,25 @@ static void ews_trigger_next_request (EEwsConnection *cnc)
g_source_attach (source, cnc->priv->soup_context);
}
+static gpointer
+ews_unref_in_thread_func (gpointer data)
+{
+ g_return_val_if_fail (data != NULL, NULL);
+
+ g_object_unref (data);
+
+ return NULL;
+}
+
+static void
+ews_unref_in_thread (GObject *object)
+{
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (G_IS_OBJECT (object));
+
+ g_thread_create (ews_unref_in_thread_func, object, FALSE, NULL);
+}
+
/**
* ews_active_job_done
* @cnc:
@@ -337,7 +356,10 @@ ews_active_job_done (EEwsConnection *cnc,
QUEUE_UNLOCK (cnc);
ews_trigger_next_request (cnc);
- g_object_unref (ews_node->simple);
+ /* the 'simple' holds reference on 'cnc' and this function
+ is called in a dedicated thread, which 'cnc' joins on dispose,
+ thus to avoid race condition, unref the object in its own thread */
+ ews_unref_in_thread (G_OBJECT (ews_node->simple));
g_free (ews_node);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]