Bug #705617 - Failed connection hides offline data in online mode
authorMilan Crha <mcrha@redhat.com>
Thu, 8 Aug 2013 11:46:44 +0000 (13:46 +0200)
committerMilan Crha <mcrha@redhat.com>
Thu, 8 Aug 2013 11:46:44 +0000 (13:46 +0200)
Do not call "connect" when changing online state in 'connecting' state,
and similar for "disconnect", to prevent a deadlock, if this change is
called within "connect" or "disconnect" function itself.

camel/camel-offline-store.c

index 280dbcb..edb1418 100644 (file)
@@ -178,8 +178,10 @@ camel_offline_store_set_online_sync (CamelOfflineStore *store,
 
                g_object_notify (G_OBJECT (store), "online");
 
-               return camel_service_connect_sync (
-                       service, cancellable, error);
+               if (camel_service_get_connection_status (service) == CAMEL_SERVICE_CONNECTING)
+                       return TRUE;
+
+               return camel_service_connect_sync (service, cancellable, error);
        }
 
        /* network available -> network unavailable */
@@ -214,8 +216,10 @@ camel_offline_store_set_online_sync (CamelOfflineStore *store,
                        CAMEL_STORE (store), FALSE, cancellable, NULL);
        }
 
-       success = camel_service_disconnect_sync (
-               service, network_available, cancellable, error);
+       if (camel_service_get_connection_status (service) == CAMEL_SERVICE_DISCONNECTING)
+               success = TRUE;
+       else
+               success = camel_service_disconnect_sync (service, network_available, cancellable, error);
 
        store->priv->online = online;