[geary/wip/266-dns-errors] Fix spurious "Can't reach host" running under Flatpak, maybe elsewhere



commit b7d0f073d278c9da3b9e68778598835413ca5c8d
Author: Michael Gratton <mike vee net>
Date:   Mon Mar 4 15:52:26 2019 +1100

    Fix spurious "Can't reach host" running under Flatpak, maybe elsewhere
    
    When offline, the GLib.NetworkMonitor portal implementation will throw a
    GLib.IOError.HOST_UNREACHABLE error instead of returning false. Handle
    this case explicitly and treat it as being unreachable, not an error.
    
    See #266

 src/engine/util/util-connectivity-manager.vala | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/src/engine/util/util-connectivity-manager.vala b/src/engine/util/util-connectivity-manager.vala
index 6ec07ac0..9dc0f068 100644
--- a/src/engine/util/util-connectivity-manager.vala
+++ b/src/engine/util/util-connectivity-manager.vala
@@ -115,6 +115,23 @@ public class Geary.ConnectivityManager : BaseObject {
             );
         } catch (GLib.IOError.CANCELLED err) {
             // User cancelled, so leave as unreachable
+        } catch (GLib.IOError.HOST_UNREACHABLE err) {
+            // Despite returning a boolean, per its API docs
+            // NetworkMonitor.can_reach() should never actually return
+            // false under Vala since it will throw an error instead,
+            // and usually this one. While that's not 100% always the
+            // case, we do need to treat this error as meaning
+            // unreachable.
+            //
+            // However if the monitor says there actually is a network
+            // available, we may be running under Flatpak with Network
+            // Manager connectivity checking enabled and hitting issue
+            // GNOME/glib#1705. Pull this debug logging out once that
+            // is fixed.
+            if (this.monitor.network_available) {
+                debug("Assuming %s is unreachable, despite network availability",
+                      endpoint);
+            }
         } catch (GLib.DBusError err) {
             // Running under Flatpak can cause a DBus error if the
             // portal is malfunctioning (e.g. Geary #97 & #82 and


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