[network-manager-openvpn] service: lower the connect timeout if there are multiple remotes



commit b7195649ffdb66c8b9f4dbae6b868d797dd29406
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Fri Jan 19 10:54:39 2018 +0100

    service: lower the connect timeout if there are multiple remotes
    
    NM waits at most 60 seconds for the connection to be established:
    lower the connect timeout if there are multiple remotes, so that we
    try at least 3 of them.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792252

 src/nm-openvpn-service.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
index 921050f..4f81565 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -1300,6 +1300,7 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
        gint64 v_int64;
        char sbuf_64[65];
        OpenvpnBinaryVersion openvpn_binary_version = OPENVPN_BINARY_VERSION_INVALID;
+       guint num_remotes = 0;
 
        s_vpn = nm_connection_get_setting_vpn (connection);
        if (!s_vpn) {
@@ -1381,6 +1382,7 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
                        if (eidx >= 0)
                                continue;
 
+                       num_remotes++;
                        add_openvpn_arg (args, "--remote");
                        add_openvpn_arg (args, host);
                        if (port) {
@@ -1549,6 +1551,13 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
                                     tmp);
                        return FALSE;
                }
+       } else if (num_remotes > 1) {
+               /* NM waits at most 60 seconds: lower the connect timeout if
+                * there are multiple remotes, so that we try at least 3 of them.
+                */
+               add_openvpn_arg (args, "--connect-timeout");
+               g_ptr_array_add (args,
+                                g_strdup_printf ("%u", NM_MAX (60 / num_remotes, 20U)));
        }
 
        add_openvpn_arg (args, "--nobind");


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