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



commit fedfc8f0c0f4c5a5c4810e58399e9e48c57fe531
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 526a5a3..8bd0c9d 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]