summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-07-07 01:02:26 -0700
committerMarcel Holtmann <marcel@holtmann.org>2009-07-07 01:02:26 -0700
commit2d5547560fdea3f1c053dd46d9fc7dfbf7d0923b (patch)
tree6b3195cec0fc6f7fc627342d78764818dd6cf465
parent41025b35a897dd5c6fe06efc4121e2f421cd2e43 (diff)
downloadconnman-2d5547560fdea3f1c053dd46d9fc7dfbf7d0923b.tar.gz
connman-2d5547560fdea3f1c053dd46d9fc7dfbf7d0923b.tar.bz2
connman-2d5547560fdea3f1c053dd46d9fc7dfbf7d0923b.zip
Make sure to trigger auto-connect when connection attempt fails
-rw-r--r--src/service.c104
1 files changed, 53 insertions, 51 deletions
diff --git a/src/service.c b/src/service.c
index 612424e9..6c027ff0 100644
--- a/src/service.c
+++ b/src/service.c
@@ -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