Commit 5aca334e authored by Michael Gratton's avatar Michael Gratton 🤞

Merge branch 'wip/227-validation-timeout' into 'master'

Use a substantially lower socket timeout when validating services

Closes #227

See merge request !119

(cherry picked from commit b7739634)

a268615d Use a substantially lower socket timeout when validating services
parent e741b934
Pipeline #60535 failed with stages
in 6 minutes and 50 seconds
......@@ -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
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment