[evolution-data-server] imapx_connect_sync: Use connection manager to connect to the server



commit 517ac5cab8f626993cb23ed0f64a5af7fc53d09d
Author: Milan Crha <mcrha redhat com>
Date:   Fri Apr 25 08:11:03 2014 +0200

    imapx_connect_sync: Use connection manager to connect to the server
    
    This function opened a new connection to the server, but immediately
    dropped it, which, apart of waste of resources, can cause trouble
    when other parts asked for the connection to the server, but those
    using the connection manager, which is the correct way of dealing
    with connections to the server now. The previous behaviour can cause
    a race condition on the imapx_store->priv->connecting_server, which
    led later to runtime warnings and misbehaviour in general.

 camel/providers/imapx/camel-imapx-store.c |   31 +++-------------------------
 1 files changed, 4 insertions(+), 27 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 97bcf09..789713f 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -769,37 +769,14 @@ imapx_connect_sync (CamelService *service,
                     GCancellable *cancellable,
                     GError **error)
 {
-       CamelIMAPXStorePrivate *priv;
+       CamelIMAPXStore *imapx_store;
        CamelIMAPXServer *imapx_server;
        gboolean success;
 
-       priv = CAMEL_IMAPX_STORE_GET_PRIVATE (service);
-
-       imapx_server = camel_imapx_server_new (CAMEL_IMAPX_STORE (service));
-
-       g_mutex_lock (&priv->server_lock);
-
-       /* We need to share the CamelIMAPXServer instance with the
-        * authenticate_sync() method, but we don't want other parts
-        * getting at it just yet.  So stash it in a special private
-        * variable while connecting to the IMAP server. */
-       g_warn_if_fail (priv->connecting_server == NULL);
-       priv->connecting_server = g_object_ref (imapx_server);
-
-       g_mutex_unlock (&priv->server_lock);
-
-       success = camel_imapx_server_connect (
-               imapx_server, cancellable, error);
-
-       g_mutex_lock (&priv->server_lock);
-
-       g_warn_if_fail (
-               priv->connecting_server == NULL ||
-               priv->connecting_server == imapx_server);
+       imapx_store = CAMEL_IMAPX_STORE (service);
 
-       g_clear_object (&priv->connecting_server);
-
-       g_mutex_unlock (&priv->server_lock);
+       imapx_server = camel_imapx_store_ref_server (imapx_store, NULL, FALSE, cancellable, error);
+       success = imapx_server != NULL;
 
        g_clear_object (&imapx_server);
 


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