Disable ipconfig in states 'Idle' and 'Failure' and let this service
state transition disable ipconfigs when a connection fails during
connection establishment, in response to a connection timeout or in
response to lower down being signalled.

Also remove the idle state checking function as it now became obsolete.
---
 src/service.c | 41 ++++++++++-------------------------------
 1 file changed, 10 insertions(+), 31 deletions(-)

diff --git a/src/service.c b/src/service.c
index 153fafb..ca9fee4 100644
--- a/src/service.c
+++ b/src/service.c
@@ -903,25 +903,6 @@ static bool is_connected_state(const struct 
connman_service *service,
        return false;
 }
 
-static bool is_idle_state(const struct connman_service *service,
-                               enum connman_service_state state)
-{
-       switch (state) {
-       case CONNMAN_SERVICE_STATE_UNKNOWN:
-       case CONNMAN_SERVICE_STATE_ASSOCIATION:
-       case CONNMAN_SERVICE_STATE_CONFIGURATION:
-       case CONNMAN_SERVICE_STATE_READY:
-       case CONNMAN_SERVICE_STATE_ONLINE:
-       case CONNMAN_SERVICE_STATE_DISCONNECT:
-       case CONNMAN_SERVICE_STATE_FAILURE:
-               break;
-       case CONNMAN_SERVICE_STATE_IDLE:
-               return true;
-       }
-
-       return false;
-}
-
 static bool is_connecting(struct connman_service *service)
 {
        return is_connecting_state(service, service->state);
@@ -3948,9 +3929,6 @@ static gboolean connect_timeout(gpointer user_data)
        else if (service->provider)
                connman_provider_disconnect(service->provider);
 
-       __connman_ipconfig_disable(service->ipconfig_ipv4);
-       __connman_ipconfig_disable(service->ipconfig_ipv6);
-
        __connman_stats_service_unregister(service);
 
        if (service->pending) {
@@ -5752,7 +5730,6 @@ int __connman_service_ipconfig_indicate_state(struct 
connman_service *service,
 
        switch (new_state) {
        case CONNMAN_SERVICE_STATE_UNKNOWN:
-       case CONNMAN_SERVICE_STATE_IDLE:
        case CONNMAN_SERVICE_STATE_ASSOCIATION:
                break;
        case CONNMAN_SERVICE_STATE_CONFIGURATION:
@@ -5776,7 +5753,11 @@ int __connman_service_ipconfig_indicate_state(struct 
connman_service *service,
                        service_rp_filter(service, false);
 
                break;
+
+       case CONNMAN_SERVICE_STATE_IDLE:
        case CONNMAN_SERVICE_STATE_FAILURE:
+               __connman_ipconfig_disable(ipconfig);
+
                break;
        }
 
@@ -5965,8 +5946,12 @@ static int service_connect(struct connman_service 
*service)
 
        if (err < 0) {
                if (err != -EINPROGRESS) {
-                       __connman_ipconfig_disable(service->ipconfig_ipv4);
-                       __connman_ipconfig_disable(service->ipconfig_ipv6);
+                       __connman_service_ipconfig_indicate_state(service,
+                                               CONNMAN_SERVICE_STATE_FAILURE,
+                                               CONNMAN_IPCONFIG_TYPE_IPV4);
+                       __connman_service_ipconfig_indicate_state(service,
+                                               CONNMAN_SERVICE_STATE_FAILURE,
+                                               CONNMAN_IPCONFIG_TYPE_IPV6);
                        __connman_stats_service_unregister(service);
                }
        }
@@ -6301,12 +6286,6 @@ static void service_lower_down(struct connman_ipconfig 
*ipconfig,
 
        DBG("%s lower down", ifname);
 
-       if (!is_idle_state(service, service->state_ipv4))
-               __connman_ipconfig_disable(service->ipconfig_ipv4);
-
-       if (!is_idle_state(service, service->state_ipv6))
-               __connman_ipconfig_disable(service->ipconfig_ipv6);
-
        stats_stop(service);
        service_save(service);
 }
-- 
2.1.4

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

Reply via email to