[geary/wip/ubuntu-1804-network-unreachable] 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] Retry using IPv4 only when connecting to an endpoint fails
- Date: Mon, 18 Feb 2019 23:19:57 +0000 (UTC)
commit 7fe445a9c1c51d21b25e0695bbe974e720669053
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 | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/src/engine/api/geary-endpoint.vala b/src/engine/api/geary-endpoint.vala
index 4968751a..c7fbc444 100644
--- a/src/engine/api/geary-endpoint.vala
+++ b/src/engine/api/geary-endpoint.vala
@@ -119,8 +119,41 @@ 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
+ // NETWORK_UNREACHABLE when an AAAA record was resolved for
+ // host name but no valid IPv6 network was available. Work
+ // around by re-attempting manually resolving and selecting an
+ // address to use. See issue #217.
+ GLib.SocketAddressEnumerator addrs = this.remote.enumerate();
+ GLib.SocketAddress? addr = yield addrs.next_async(cancellable);
+ while (addr != null) {
+ GLib.InetSocketAddress? inet_addr = addr as GLib.InetSocketAddress;
+ if (inet_addr != null) {
+ try {
+ return yield client.connect_async(
+ new GLib.InetSocketAddress(
+ inet_addr.address, (uint16) inet_addr.port
+ ),
+ cancellable
+ );
+ } catch (GLib.IOError.NETWORK_UNREACHABLE err) {
+ // Keep going
+ }
+ }
+ addr = yield addrs.next_async(cancellable);
+ }
+
+ 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]