Send connman mailing list submissions to
        connman@lists.01.org

To subscribe or unsubscribe via email, send a message with subject or
body 'help' to
        connman-requ...@lists.01.org

You can reach the person managing the list at
        connman-ow...@lists.01.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."

Today's Topics:

   1. [PATCH 2/2] wispr: Update service state on connection loss
      (VAUTRIN Emmanuel (Canal Plus Prestataire))


----------------------------------------------------------------------

Date: Tue, 2 Feb 2021 17:50:22 +0000
From: "VAUTRIN Emmanuel (Canal Plus Prestataire)"
        <emmanuel.vaut...@cpexterne.org>
Subject: [PATCH 2/2] wispr: Update service state on connection loss
To: "connman@lists.01.org" <connman@lists.01.org>
Message-ID:  <pr1pr02mb4794f4fd6e275cf9e2eac28993...@pr1pr02mb4794.eur
        prd02.prod.outlook.com>
Content-Type: text/plain; charset="iso-8859-1"

Keep checking Internet connection availability when online, and update
the service state to ready on connection loss.
---
 src/connman.h |  5 +++--
 src/service.c | 20 ++++++++++++++++----
 src/wispr.c   | 12 ++++--------
 3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 17452a76..b964a25d 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -726,8 +726,9 @@ int __connman_service_set_mdns(struct connman_service 
*service,
 
 void __connman_service_set_string(struct connman_service *service,
                                        const char *key, const char *value);
-int __connman_service_online_check_failed(struct connman_service *service,
-                                       enum connman_ipconfig_type type);
+void __connman_service_online_check(struct connman_service *service,
+                                       enum connman_ipconfig_type type,
+                                       bool success);
 int __connman_service_ipconfig_indicate_state(struct connman_service *service,
                                        enum connman_service_state new_state,
                                        enum connman_ipconfig_type type);
diff --git a/src/service.c b/src/service.c
index b3294478..cb52e360 100644
--- a/src/service.c
+++ b/src/service.c
@@ -6246,11 +6246,13 @@ static gboolean redo_wispr_ipv6(gpointer user_data)
        return FALSE;
 }
 
-int __connman_service_online_check_failed(struct connman_service *service,
-                                       enum connman_ipconfig_type type)
+void __connman_service_online_check(struct connman_service *service,
+                                       enum connman_ipconfig_type type,
+                                       bool success)
 {
        GSourceFunc redo_func;
        int *interval;
+       enum connman_service_state current_state;
 
        if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
                interval = &service->online_check_interval_ipv4;
@@ -6260,6 +6262,18 @@ int __connman_service_online_check_failed(struct 
connman_service *service,
                redo_func = redo_wispr_ipv6;
        }
 
+       if (success) {
+               *interval = online_check_max_interval;
+       } else {
+               current_state = service->state;
+               downgrade_state(service);
+               if (current_state != service->state)
+                       *interval = online_check_initial_interval;
+               if (service != connman_service_get_default()) {
+                       return;
+               }
+       }
+
        DBG("service %p type %s interval %d", service,
                __connman_ipconfig_type2string(type), *interval);
 
@@ -6271,8 +6285,6 @@ int __connman_service_online_check_failed(struct 
connman_service *service,
         */
        if (*interval < online_check_max_interval)
                (*interval)++;
-
-       return EAGAIN;
 }
 
 int __connman_service_ipconfig_indicate_state(struct connman_service *service,
diff --git a/src/wispr.c b/src/wispr.c
index b107f929..69fe2879 100644
--- a/src/wispr.c
+++ b/src/wispr.c
@@ -450,10 +450,10 @@ static void portal_manage_status(GWebResult *result,
                                &str))
                connman_info("Client-Timezone: %s", str);
 
-       free_connman_wispr_portal_context(wp_context);
-
        __connman_service_ipconfig_indicate_state(service,
                                        CONNMAN_SERVICE_STATE_ONLINE, type);
+
+       __connman_service_online_check(service, type, true);
 }
 
 static bool wispr_route_request(const char *address, int ai_family,
@@ -773,12 +773,8 @@ static bool wispr_portal_web_result(GWebResult *result, 
gpointer user_data)
                goto done;
        case 400:
        case 404:
-               if (__connman_service_online_check_failed(wp_context->service,
-                                               wp_context->type) == 0) {
-                       wispr_portal_error(wp_context);
-                       free_connman_wispr_portal_context(wp_context);
-                       return false;
-               }
+               __connman_service_online_check(wp_context->service,
+                                               wp_context->type, false);
 
                break;
        case 505:
-- 
2.25.1

------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list -- connman@lists.01.org
To unsubscribe send an email to connman-le...@lists.01.org


------------------------------

End of connman Digest, Vol 64, Issue 1
**************************************

Reply via email to