[geary/wip/ubuntu-1804-network-unreachable: 1/2] Retry using IPv4 only when connecting to an endpoint fails
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/ubuntu-1804-network-unreachable: 1/2] Retry using IPv4 only when connecting to an endpoint fails
- Date: Mon, 18 Feb 2019 23:00:32 +0000 (UTC)
commit f881fad3783619a501b698961e89d3552d23aa8f
Author: Michael Gratton <mike vee net>
Date: Mon Feb 18 22:42:11 2019 +1100
Retry using IPv4 only when connecting to an endpoint fails
Ubuntu 18.04 for some reason started throwing "Network unavailable"
errors when an AAAA record was resolved for host name but no valid IPv6
network was available. Work around by re-attempting once using IPv4
only.
See issue #217.
src/engine/api/geary-endpoint.vala | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/engine/api/geary-endpoint.vala b/src/engine/api/geary-endpoint.vala
index 4968751a..e408c1b3 100644
--- a/src/engine/api/geary-endpoint.vala
+++ b/src/engine/api/geary-endpoint.vala
@@ -119,8 +119,28 @@ public class Geary.Endpoint : BaseObject {
this.tls_method = method;
}
- public async SocketConnection connect_async(Cancellable? cancellable = null) throws Error {
- return yield get_socket_client().connect_async(this.remote, cancellable);
+ public async GLib.SocketConnection connect_async(GLib.Cancellable? cancellable = null)
+ throws GLib.Error {
+ GLib.SocketClient client = get_socket_client();
+ GLib.IOError? connect_error = null;
+ try {
+ return yield client.connect_async(this.remote, cancellable);
+ } catch (GLib.IOError.NETWORK_UNREACHABLE err) {
+ connect_error = err;
+ }
+
+ // Ubuntu 18.04 for some reason started throwing these errors
+ // when an AAAA record was resolved for host name but no valid
+ // IPv6 network was available. Work around by re-attempting
+ // once using IPv4 only. See issue #217.
+ client.family = GLib.SocketFamily.IPV4;
+ try {
+ return yield client.connect_async(this.remote, cancellable);
+ } catch (GLib.Error err) {
+ debug("Connect error while working around network unavailable: %s",
+ err.message);
+ throw connect_error;
+ }
}
public async TlsClientConnection starttls_handshake_async(IOStream base_stream,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]