[evolution-data-server/evolution-data-server-3-12] [CamelService] Connect/Disconnect rely on provided cancellable



commit 1c58bd8aedfb10d1f92e5bfdf644e4e8d209f306
Author: Milan Crha <mcrha redhat com>
Date:   Fri Oct 24 11:09:32 2014 +0200

    [CamelService] Connect/Disconnect rely on provided cancellable
    
    To properly react on Connect and Disconnect requests the cancellable
    for these should be provided, because the code relies on it and uses
    it to eventually cancel any pending connect or disconnect, but
    the cancellable is an optional parameter, thus always create one
    if necessary.

 camel/camel-service.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 38ab90d..c8e4a3b 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -1809,6 +1809,11 @@ camel_service_connect (CamelService *service,
 
        g_return_if_fail (CAMEL_IS_SERVICE (service));
 
+       if (cancellable)
+               g_object_ref (cancellable);
+       else
+               cancellable = g_cancellable_new ();
+
        task = g_task_new (service, cancellable, callback, user_data);
        g_task_set_source_tag (task, camel_service_connect);
        g_task_set_priority (task, io_priority);
@@ -1864,6 +1869,7 @@ camel_service_connect (CamelService *service,
 
        g_mutex_unlock (&service->priv->connection_lock);
 
+       g_object_unref (cancellable);
        g_object_unref (task);
 }
 
@@ -1975,6 +1981,11 @@ camel_service_disconnect (CamelService *service,
 
        g_return_if_fail (CAMEL_IS_SERVICE (service));
 
+       if (cancellable)
+               g_object_ref (cancellable);
+       else
+               cancellable = g_cancellable_new ();
+
        task = g_task_new (service, cancellable, callback, user_data);
        g_task_set_source_tag (task, camel_service_disconnect);
        g_task_set_priority (task, io_priority);
@@ -2038,6 +2049,7 @@ camel_service_disconnect (CamelService *service,
 
        g_mutex_unlock (&service->priv->connection_lock);
 
+       g_object_unref (cancellable);
        g_object_unref (task);
 }
 


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