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)
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)
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;