[35fae39286f862cb505a3f0cac0b0d506f9a407cf9227d3c2ae2c67d5ec0d0f5/wip/mcrha/office365] Correct CamelService::connect_sync() implementations



commit a81b315694d67fd901e36b028b763db8485fd05d
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jul 8 12:04:01 2020 +0200

    Correct CamelService::connect_sync() implementations

 src/Office365/camel/camel-o365-store.c     | 10 +++++++---
 src/Office365/camel/camel-o365-transport.c | 10 +++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/Office365/camel/camel-o365-store.c b/src/Office365/camel/camel-o365-store.c
index c54af794..101d74b9 100644
--- a/src/Office365/camel/camel-o365-store.c
+++ b/src/Office365/camel/camel-o365-store.c
@@ -521,11 +521,15 @@ o365_store_connect_sync (CamelService *service,
        cnc = camel_o365_store_ref_connection (o365_store);
 
        if (!cnc) {
-               LOCK (o365_store);
+               cnc = camel_o365_utils_new_connection (service, NULL);
 
-               o365_store->priv->cnc = camel_o365_utils_new_connection (service, NULL);
+               if (cnc) {
+                       LOCK (o365_store);
 
-               UNLOCK (o365_store);
+                       o365_store->priv->cnc = g_object_ref (cnc);
+
+                       UNLOCK (o365_store);
+               }
        }
 
        if (cnc) {
diff --git a/src/Office365/camel/camel-o365-transport.c b/src/Office365/camel/camel-o365-transport.c
index 985a4efa..6e8b0071 100644
--- a/src/Office365/camel/camel-o365-transport.c
+++ b/src/Office365/camel/camel-o365-transport.c
@@ -170,11 +170,15 @@ o365_transport_connect_sync (CamelService *service,
        cnc = o365_transport_ref_connection (o365_transport);
 
        if (!cnc) {
-               LOCK (o365_transport);
+               cnc = camel_o365_utils_new_connection (service, NULL);
 
-               o365_transport->priv->cnc = camel_o365_utils_new_connection (service, NULL);
+               if (cnc) {
+                       LOCK (o365_transport);
 
-               UNLOCK (o365_transport);
+                       o365_transport->priv->cnc = g_object_ref (cnc);
+
+                       UNLOCK (o365_transport);
+               }
        }
 
        if (cnc) {


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