summaryrefslogtreecommitdiff
path: root/plugins/wifi.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-12-13 15:50:25 +0100
committerMarcel Holtmann <marcel@holtmann.org>2008-12-13 15:50:25 +0100
commit06c0b8a9158bd5b0aad93dd9100ec0606ea894ac (patch)
tree19ba2d0c5b1e255d559ebe4e09c64c0c9c4497e6 /plugins/wifi.c
parentb7c6f712f25d665be9d6da257aa676fa2eb35d90 (diff)
downloadconnman-06c0b8a9158bd5b0aad93dd9100ec0606ea894ac.tar.gz
connman-06c0b8a9158bd5b0aad93dd9100ec0606ea894ac.tar.bz2
connman-06c0b8a9158bd5b0aad93dd9100ec0606ea894ac.zip
Add support for inactive and cleanup timers
Diffstat (limited to 'plugins/wifi.c')
-rw-r--r--plugins/wifi.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 533b035c..3fbed238 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -41,12 +41,14 @@
#include "inet.h"
#include "supplicant.h"
-#define CLEANUP_PENDING_TIMEOUT 8 /* in seconds */
+#define CLEANUP_TIMEOUT 8 /* in seconds */
+#define INACTIVE_TIMEOUT 12 /* in seconds */
struct wifi_data {
GSList *current;
GSList *pending;
- guint timer;
+ guint cleanup_timer;
+ guint inactive_timer;
gchar *identifier;
gboolean connected;
};
@@ -160,6 +162,25 @@ static struct connman_element *find_pending_element(struct wifi_data *data,
return NULL;
}
+static gboolean inactive_scan(gpointer user_data)
+{
+ struct connman_element *device = user_data;
+ struct wifi_data *data = connman_element_get_data(device);
+
+ DBG("");
+
+ if (data->cleanup_timer > 0) {
+ g_source_remove(data->cleanup_timer);
+ data->cleanup_timer = 0;
+ }
+
+ __supplicant_scan(device);
+
+ data->inactive_timer = 0;
+
+ return FALSE;
+}
+
static void state_change(struct connman_element *parent,
enum supplicant_state state)
{
@@ -168,6 +189,10 @@ static void state_change(struct connman_element *parent,
DBG("state %d", state);
+ if (state == STATE_INACTIVE && data->inactive_timer == 0)
+ data->inactive_timer = g_timeout_add_seconds(INACTIVE_TIMEOUT,
+ inactive_scan, parent);
+
if (data == NULL)
return;
@@ -212,7 +237,7 @@ static gboolean cleanup_pending(gpointer user_data)
g_slist_free(data->pending);
data->pending = NULL;
- data->timer = 0;
+ data->cleanup_timer = 0;
return FALSE;
}
@@ -227,8 +252,10 @@ static void clear_results(struct connman_element *parent)
data->pending = data->current;
data->current = NULL;
- if (data->timer == 0)
- data->timer = g_timeout_add_seconds(CLEANUP_PENDING_TIMEOUT,
+ if (data->cleanup_timer > 0)
+ return;
+
+ data->cleanup_timer = g_timeout_add_seconds(CLEANUP_TIMEOUT,
cleanup_pending, data);
}
@@ -378,9 +405,14 @@ static int wifi_disable(struct connman_element *element)
DBG("element %p name %s", element, element->name);
- if (data->timer > 0) {
- g_source_remove(data->timer);
- data->timer = 0;
+ if (data->cleanup_timer > 0) {
+ g_source_remove(data->cleanup_timer);
+ data->cleanup_timer = 0;
+ }
+
+ if (data->inactive_timer > 0) {
+ g_source_remove(data->inactive_timer);
+ data->inactive_timer = 0;
}
__supplicant_disconnect(element);