When clearing a service in error state, set both ipconfigs to idle causing
the service states in both ipconfig and service to be reset. Save the
D-Bus id before setting the service to idle and restore it afterwards so
that a possible D-Bus client won't be informed of a connection error which
actually never happened.

Clean up unnecessary checks at the same time.
---
 src/service.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/service.c b/src/service.c
index e284e92..ac7d49f 100644
--- a/src/service.c
+++ b/src/service.c
@@ -5491,6 +5491,8 @@ int __connman_service_indicate_error(struct 
connman_service *service,
 
 int __connman_service_clear_error(struct connman_service *service)
 {
+       DBusMessage *pending, *provider_pending;
+
        DBG("service %p", service);
 
        if (!service)
@@ -5499,25 +5501,23 @@ int __connman_service_clear_error(struct 
connman_service *service)
        if (service->state != CONNMAN_SERVICE_STATE_FAILURE)
                return -EINVAL;
 
-       service->state_ipv4 = service->state_ipv6 =
-                                               CONNMAN_SERVICE_STATE_UNKNOWN;
-       set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
+       pending = service->pending;
+       service->pending = NULL;
+       provider_pending = service->provider_pending;
+       service->provider_pending = NULL;
 
        __connman_service_ipconfig_indicate_state(service,
-                                       CONNMAN_SERVICE_STATE_IDLE,
-                                       CONNMAN_IPCONFIG_TYPE_IPV6);
-
-       /*
-        * Toggling the IPv6 state to IDLE could trigger the auto connect
-        * machinery and consequently the IPv4 state.
-        */
-       if (service->state_ipv4 != CONNMAN_SERVICE_STATE_UNKNOWN &&
-                       service->state_ipv4 != CONNMAN_SERVICE_STATE_FAILURE)
-               return 0;
+                                               CONNMAN_SERVICE_STATE_IDLE,
+                                               CONNMAN_IPCONFIG_TYPE_IPV6);
 
-       return __connman_service_ipconfig_indicate_state(service,
+       __connman_service_ipconfig_indicate_state(service,
                                                CONNMAN_SERVICE_STATE_IDLE,
                                                CONNMAN_IPCONFIG_TYPE_IPV4);
+
+       service->pending = pending;
+       service->provider_pending = provider_pending;
+
+       return 0;
 }
 
 int __connman_service_indicate_default(struct connman_service *service)
-- 
1.9.1

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

Reply via email to