[evolution-data-server] EAuthenticationMediator: Resolve some thread-safety issues.



commit 41edd64ede0f0f219779464a2431a54169c93b7a
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Jun 6 11:46:57 2012 -0400

    EAuthenticationMediator: Resolve some thread-safety issues.
    
    The D-Bus method handlers in EAuthenticationMediator run in separate
    threads because we set possibly the longest enum value ever:
    
    G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD
    
    Connect to the signals with g_signal_connect_object() so the handlers
    will not be dispatched after the mediator is finalized (hopefully...
    still not sure if it's 100% thread-safe).

 libebackend/e-authentication-mediator.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/libebackend/e-authentication-mediator.c b/libebackend/e-authentication-mediator.c
index 8658615..386cc24 100644
--- a/libebackend/e-authentication-mediator.c
+++ b/libebackend/e-authentication-mediator.c
@@ -738,21 +738,32 @@ e_authentication_mediator_init (EAuthenticationMediator *mediator)
 		G_DBUS_INTERFACE_SKELETON (mediator->priv->interface),
 		G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
 
-	g_signal_connect (
+	/* These signal handlers run in separate threads, so
+	 * use g_signal_connect_object() to hopefully prevent
+	 * the signal handler from being dispatched after the
+	 * mediator is finalized.
+	 *
+	 * XXX Not certain if this is fully thread-safe. */
+
+	g_signal_connect_object (
 		mediator->priv->interface, "handle-ready",
-		G_CALLBACK (authentication_mediator_handle_ready), mediator);
+		G_CALLBACK (authentication_mediator_handle_ready),
+		mediator, 0);
 
-	g_signal_connect (
+	g_signal_connect_object (
 		mediator->priv->interface, "handle-cancel",
-		G_CALLBACK (authentication_mediator_handle_cancel), mediator);
+		G_CALLBACK (authentication_mediator_handle_cancel),
+		mediator, 0);
 
-	g_signal_connect (
+	g_signal_connect_object (
 		mediator->priv->interface, "handle-accepted",
-		G_CALLBACK (authentication_mediator_handle_accepted), mediator);
+		G_CALLBACK (authentication_mediator_handle_accepted),
+		mediator, 0);
 
-	g_signal_connect (
+	g_signal_connect_object (
 		mediator->priv->interface, "handle-rejected",
-		G_CALLBACK (authentication_mediator_handle_rejected), mediator);
+		G_CALLBACK (authentication_mediator_handle_rejected),
+		mediator, 0);
 }
 
 /**



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