Fix detection of association errors from supplicant
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 16 Jul 2009 04:31:08 +0000 (06:31 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 16 Jul 2009 04:31:08 +0000 (06:31 +0200)
src/network.c
src/service.c

index 58dfea5..42148a7 100644 (file)
@@ -782,10 +782,11 @@ int connman_network_set_connected(struct connman_network *network,
 
        DBG("network %p connected %d", network, connected);
 
-       if (connected == FALSE && network->connecting == TRUE) {
+       if ((network->connecting || network->associating == TRUE) &&
+                                                       connected == FALSE) {
                connman_element_set_error(&network->element,
                                        CONNMAN_ELEMENT_ERROR_CONNECT_FAILED);
-               network->connecting = FALSE;
+               __connman_network_disconnect(network);
        }
 
        if (network->connected == connected)
@@ -890,7 +891,8 @@ int __connman_network_disconnect(struct connman_network *network)
 
        DBG("network %p", network);
 
-       if (network->connected == FALSE && network->connecting == FALSE)
+       if (network->connected == FALSE && network->connecting == FALSE &&
+                                               network->associating == FALSE)
                return -ENOTCONN;
 
        if (network->driver == NULL)
index b6e049f..38f553b 100644 (file)
@@ -973,6 +973,10 @@ int __connman_service_indicate_state(struct connman_service *service,
        if (service->state == state)
                return -EALREADY;
 
+       if (service->state == CONNMAN_SERVICE_STATE_FAILURE &&
+                               state == CONNMAN_SERVICE_STATE_IDLE)
+               return -EINVAL;
+
        if (service->state == CONNMAN_SERVICE_STATE_IDLE &&
                                state == CONNMAN_SERVICE_STATE_DISCONNECT)
                return -EINVAL;