[evolution-ews] Avoid unref of EEwsConnection in ews_connection_scheduled_cb()



commit 8fed2d404e281903e32e383c1ea8ea86725443b3
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jul 18 15:54:55 2012 +0200

    Avoid unref of EEwsConnection in ews_connection_scheduled_cb()
    
    If that's the last reference, then the e_ews_connection_dispose() will try
    to wait for the soup_thread, but this is run in soup_thread, thus it cannot
    be done and application is aborted on checking for deadlock.

 src/server/e-ews-connection.c |   35 ++++++++++++++++++-----------------
 1 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 4fc3159..5d48e37 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -134,6 +134,22 @@ ews_connection_error_quark (void)
 	return quark;
 }
 
+static gpointer
+ews_unref_in_thread_func (gpointer data)
+{
+	g_object_unref (G_OBJECT (data));
+
+	return NULL;
+}
+
+static void
+ews_unref_in_thread (gpointer object)
+{
+	g_return_if_fail (G_IS_OBJECT (object));
+
+	g_thread_create (ews_unref_in_thread_func, object, FALSE, NULL);
+}
+
 static void
 async_data_free (EwsAsyncData *async_data)
 {
@@ -244,7 +260,8 @@ ews_connection_scheduled_cb (gpointer user_data)
 
 	if (sd->message)
 		g_object_unref (sd->message);
-	g_object_unref (sd->cnc);
+	/* in case this is the last reference */
+	ews_unref_in_thread (sd->cnc);
 	g_free (sd);
 
 	return FALSE;
@@ -367,22 +384,6 @@ ews_trigger_next_request (EEwsConnection *cnc)
 	g_source_attach (source, cnc->priv->soup_context);
 }
 
-static gpointer
-ews_unref_in_thread_func (gpointer data)
-{
-	g_object_unref (G_SIMPLE_ASYNC_RESULT (data));
-
-	return NULL;
-}
-
-static void
-ews_unref_in_thread (GSimpleAsyncResult *simple)
-{
-	g_return_if_fail (G_IS_SIMPLE_ASYNC_RESULT (simple));
-
-	g_thread_create (ews_unref_in_thread_func, simple, FALSE, NULL);
-}
-
 /**
  * ews_active_job_done
  * @cnc:



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