Check if there are any connected services available before
trying to connect a VPN provider. With this check we avoid
lengthy timeout as the provider cannot be connected anyway
in this case.
---
 src/service.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/service.c b/src/service.c
index 469140a..bccee94 100644
--- a/src/service.c
+++ b/src/service.c
@@ -5641,6 +5641,14 @@ static void prepare_8021x(struct connman_service 
*service)
                                                        service->phase2);
 }
 
+static connman_bool_t is_any_connection_available(void)
+{
+       if (current_default == NULL)
+               return FALSE;
+
+       return TRUE;
+}
+
 static int service_connect(struct connman_service *service)
 {
        int err;
@@ -5739,9 +5747,12 @@ static int service_connect(struct connman_service 
*service)
 
                err = __connman_network_connect(service->network);
        } else if (service->type == CONNMAN_SERVICE_TYPE_VPN &&
-                                       service->provider != NULL)
-               err = __connman_provider_connect(service->provider);
-       else
+                                               service->provider != NULL) {
+               if (is_any_connection_available() == TRUE)
+                       err = __connman_provider_connect(service->provider);
+               else
+                       err = -ENOLINK;
+       } else
                return -EOPNOTSUPP;
 
        if (err < 0) {
-- 
1.7.11.4

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to