[geary/geary-0.13] Merge branch 'wip/227-validation-timeout' into 'master'



commit 5aca334ed01f9e059bf1ae3ce0006810654f4e14
Author: Michael Gratton <mike vee net>
Date:   Tue Feb 19 07:20:18 2019 +0000

    Merge branch 'wip/227-validation-timeout' into 'master'
    
    Use a substantially lower socket timeout when validating services
    
    Closes #227
    
    See merge request GNOME/geary!119
    
    (cherry picked from commit b7739634ac071c4500f83b15d5e81394c129d029)
    
    a268615d Use a substantially lower socket timeout when validating services

 src/engine/api/geary-engine.vala | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/src/engine/api/geary-engine.vala b/src/engine/api/geary-engine.vala
index 6dea9e7c..4b947802 100644
--- a/src/engine/api/geary-engine.vala
+++ b/src/engine/api/geary-engine.vala
@@ -18,6 +18,11 @@
 public class Geary.Engine : BaseObject {
 
 
+    // Set low to avoid leaving the user hanging too long when
+    // validating a service.
+    private const uint VALIDATION_TIMEOUT = 15;
+
+
     public static Engine instance {
         get {
             return (_instance != null) ? _instance : (_instance = new Engine());
@@ -197,8 +202,10 @@ public class Geary.Engine : BaseObject {
                                     GLib.Cancellable? cancellable = null)
         throws GLib.Error {
         check_opened();
-        Endpoint endpoint = get_shared_endpoint(
-            account.service_provider, service
+
+        // Use a new endpoint since we use a different socket timeout
+        Endpoint endpoint = new_endpoint(
+            account.service_provider, service, VALIDATION_TIMEOUT
         );
         ulong untrusted_id = endpoint.untrusted_host.connect(
             (security, cx) => account.untrusted_host(service, security, cx)
@@ -246,8 +253,10 @@ public class Geary.Engine : BaseObject {
                                     GLib.Cancellable? cancellable = null)
         throws GLib.Error {
         check_opened();
-        Endpoint endpoint = get_shared_endpoint(
-            account.service_provider, service
+
+        // Use a new endpoint since we use a different socket timeout
+        Endpoint endpoint = new_endpoint(
+            account.service_provider, service, VALIDATION_TIMEOUT
         );
         ulong untrusted_id = endpoint.untrusted_host.connect(
             (security, cx) => account.untrusted_host(service, security, cx)
@@ -440,11 +449,7 @@ public class Geary.Engine : BaseObject {
                 ? Imap.ClientConnection.RECOMMENDED_TIMEOUT_SEC
                 : Smtp.ClientConnection.DEFAULT_TIMEOUT_SEC;
 
-            shared = new Endpoint(
-                new NetworkAddress(service.host, service.port),
-                service.transport_security,
-                timeout
-            );
+            shared = new_endpoint(provider, service, timeout);
 
             // XXX this is pretty hacky, move this back into the
             // OutlookAccount somehow
@@ -465,4 +470,14 @@ public class Geary.Engine : BaseObject {
         return shared;
     }
 
+    private inline Geary.Endpoint new_endpoint(ServiceProvider provider,
+                                               ServiceInformation service,
+                                               uint timeout) {
+        return new Endpoint(
+            new NetworkAddress(service.host, service.port),
+            service.transport_security,
+            timeout
+        );
+    }
+
 }


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