From 72c68c7c45492cd6c2369f5c0f5b9f36107ea3a0 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 24 Jul 2009 01:22:43 +0200 Subject: [PATCH] Add timeout for technology enable and disable operation --- src/manager.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/manager.c b/src/manager.c index e55c676..c318be1 100644 --- a/src/manager.c +++ b/src/manager.c @@ -391,9 +391,17 @@ static DBusConnection *connection = NULL; static enum connman_service_type technology_type; static connman_bool_t technology_enabled; static DBusMessage *technology_pending = NULL; +static guint technology_timeout = 0; static void technology_reply(int error) { + DBG(""); + + if (technology_timeout > 0) { + g_source_remove(technology_timeout); + technology_timeout = 0; + } + if (technology_reply != NULL) { if (error > 0) { DBusMessage *reply; @@ -413,6 +421,17 @@ static void technology_reply(int error) technology_type = CONNMAN_SERVICE_TYPE_UNKNOWN; } +static gboolean technology_abort(gpointer user_data) +{ + DBG(""); + + technology_timeout = 0; + + technology_reply(ETIMEDOUT); + + return FALSE; +} + static void technology_notify(enum connman_service_type type, connman_bool_t enabled) { @@ -466,6 +485,9 @@ static DBusMessage *enable_technology(DBusConnection *conn, err = __connman_element_enable_technology(type); if (err < 0 && err != -EINPROGRESS) technology_reply(-err); + else + technology_timeout = g_timeout_add_seconds(15, + technology_abort, NULL); return NULL; } @@ -508,6 +530,9 @@ static DBusMessage *disable_technology(DBusConnection *conn, err = __connman_element_disable_technology(type); if (err < 0 && err != -EINPROGRESS) technology_reply(-err); + else + technology_timeout = g_timeout_add_seconds(10, + technology_abort, NULL); return NULL; } -- 2.7.4