Make sure to trigger auto-connect when connection attempt fails
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 7 Jul 2009 08:02:26 +0000 (01:02 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 7 Jul 2009 08:02:26 +0000 (01:02 -0700)
src/service.c

index 612424e957ea29ae35139df389bf227f2b4e160e..6c027ff022afef42d7de13b371da13b6fd3adf3e 100644 (file)
@@ -417,6 +417,57 @@ static DBusMessage *clear_property(DBusConnection *conn,
        return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
+static connman_bool_t is_connecting(struct connman_service *service)
+{
+       switch (service->state) {
+       case CONNMAN_SERVICE_STATE_UNKNOWN:
+       case CONNMAN_SERVICE_STATE_IDLE:
+       case CONNMAN_SERVICE_STATE_CARRIER:
+       case CONNMAN_SERVICE_STATE_FAILURE:
+       case CONNMAN_SERVICE_STATE_DISCONNECT:
+       case CONNMAN_SERVICE_STATE_READY:
+               break;
+       case CONNMAN_SERVICE_STATE_ASSOCIATION:
+       case CONNMAN_SERVICE_STATE_CONFIGURATION:
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
+static void __connman_service_auto_connect(void)
+{
+       struct connman_service *service;
+       GSequenceIter *iter;
+
+       DBG("");
+
+       iter = g_sequence_get_begin_iter(service_list);
+       if (g_sequence_iter_is_end(iter) == TRUE)
+               return;
+
+       service = g_sequence_get(iter);
+
+       while (service->state == CONNMAN_SERVICE_STATE_FAILURE) {
+               iter = g_sequence_iter_next(iter);
+               if (g_sequence_iter_is_end(iter))
+                       return;
+               service = g_sequence_get(iter);
+       }
+
+       if (service->favorite == FALSE)
+               return;
+
+       if (service->state == CONNMAN_SERVICE_STATE_READY)
+               return;
+
+       if (is_connecting(service) == TRUE)
+               return;
+
+       if (service->state == CONNMAN_SERVICE_STATE_IDLE)
+               __connman_service_connect(service);
+}
+
 static gboolean connect_timeout(gpointer user_data)
 {
        struct connman_service *service = user_data;
@@ -463,6 +514,8 @@ static gboolean connect_timeout(gpointer user_data)
        __connman_service_indicate_state(service,
                                        CONNMAN_SERVICE_STATE_FAILURE);
 
+       __connman_service_auto_connect();
+
        return FALSE;
 }
 
@@ -1110,57 +1163,6 @@ static int service_register(struct connman_service *service)
        return 0;
 }
 
-static connman_bool_t is_connecting(struct connman_service *service)
-{
-       switch (service->state) {
-       case CONNMAN_SERVICE_STATE_UNKNOWN:
-       case CONNMAN_SERVICE_STATE_IDLE:
-       case CONNMAN_SERVICE_STATE_CARRIER:
-       case CONNMAN_SERVICE_STATE_FAILURE:
-       case CONNMAN_SERVICE_STATE_DISCONNECT:
-       case CONNMAN_SERVICE_STATE_READY:
-               break;
-       case CONNMAN_SERVICE_STATE_ASSOCIATION:
-       case CONNMAN_SERVICE_STATE_CONFIGURATION:
-               return TRUE;
-       }
-
-       return FALSE;
-}
-
-static void __connman_service_auto_connect(void)
-{
-       struct connman_service *service;
-       GSequenceIter *iter;
-
-       DBG("");
-
-       iter = g_sequence_get_begin_iter(service_list);
-       if (g_sequence_iter_is_end(iter) == TRUE)
-               return;
-
-       service = g_sequence_get(iter);
-
-       while (service->state == CONNMAN_SERVICE_STATE_FAILURE) {
-               iter = g_sequence_iter_next(iter);
-               if (g_sequence_iter_is_end(iter))
-                       return;
-               service = g_sequence_get(iter);
-       }
-
-       if (service->favorite == FALSE)
-               return;
-
-       if (service->state == CONNMAN_SERVICE_STATE_READY)
-               return;
-
-       if (is_connecting(service) == TRUE)
-               return;
-
-       if (service->state == CONNMAN_SERVICE_STATE_IDLE)
-               __connman_service_connect(service);
-}
-
 /**
  * connman_service_lookup_from_device:
  * @device: device structure