[evolution-data-server] Bug #650671 - Service connect/disconnect not cancelled properly



commit 89d6972ff8f446ab65d31c52992e90bcfd2b6b7d
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jul 1 20:00:57 2011 +0200

    Bug #650671 - Service connect/disconnect not cancelled properly

 camel/camel-operation.c |   35 +++++++++++++++++++++++++----------
 1 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/camel/camel-operation.c b/camel/camel-operation.c
index 35dfd52..d97ba86 100644
--- a/camel/camel-operation.c
+++ b/camel/camel-operation.c
@@ -154,6 +154,27 @@ operation_flush_msgport (CamelOperation *operation)
 }
 
 static void
+operation_cancelled (GCancellable *cancellable)
+{
+	CamelOperation *operation;
+	CamelMsg *msg;
+
+	g_return_if_fail (cancellable != NULL);
+	g_return_if_fail (CAMEL_IS_OPERATION (cancellable));
+
+	operation = CAMEL_OPERATION (cancellable);
+	g_return_if_fail (operation != NULL);
+	g_return_if_fail (operation->priv != NULL);
+
+	LOCK ();
+
+	msg = g_malloc0 (sizeof (CamelMsg));
+	camel_msgport_push (operation->priv->cancel_port, msg);
+
+	UNLOCK ();
+}
+
+static void
 operation_finalize (GObject *object)
 {
 	CamelOperationPrivate *priv;
@@ -182,12 +203,16 @@ static void
 camel_operation_class_init (CamelOperationClass *class)
 {
 	GObjectClass *object_class;
+	GCancellableClass *cancellable_class;
 
 	g_type_class_add_private (class, sizeof (CamelOperationPrivate));
 
 	object_class = G_OBJECT_CLASS (class);
 	object_class->finalize = operation_finalize;
 
+	cancellable_class = G_CANCELLABLE_CLASS (class);
+	cancellable_class->cancelled = operation_cancelled;
+
 	signals[STATUS] = g_signal_new (
 		"status",
 		G_TYPE_FROM_CLASS (class),
@@ -242,19 +267,9 @@ void
 camel_operation_cancel (CamelOperation *operation)
 {
 	if (operation != NULL) {
-		CamelMsg *msg;
-
 		g_return_if_fail (CAMEL_IS_OPERATION (operation));
 
-		LOCK ();
-
-		msg = g_malloc0 (sizeof (CamelMsg));
-		camel_msgport_push (operation->priv->cancel_port, msg);
-
-		UNLOCK ();
-
 		g_cancellable_cancel (G_CANCELLABLE (operation));
-
 	} else {
 		GList *link;
 



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