summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-07-17 18:23:15 +0200
committerMarcel Holtmann <marcel@holtmann.org>2009-07-17 18:23:15 +0200
commit34e6a5e79321d56421739631a43034b822838985 (patch)
tree5c4af5bbc8e6044ef02b09d02441cf406f2c130e
parent6a70ddabb056d5ca6cb6f65191c75be930258b0e (diff)
downloadconnman-34e6a5e79321d56421739631a43034b822838985.tar.gz
connman-34e6a5e79321d56421739631a43034b822838985.tar.bz2
connman-34e6a5e79321d56421739631a43034b822838985.zip
Remove delay when removing services since it causes trouble
-rw-r--r--src/service.c90
1 files changed, 29 insertions, 61 deletions
diff --git a/src/service.c b/src/service.c
index e334deee..09963d2e 100644
--- a/src/service.c
+++ b/src/service.c
@@ -495,6 +495,30 @@ void __connman_service_auto_connect(void)
__connman_service_connect(service);
}
+static void reply_pending(struct connman_service *service, int error)
+{
+ if (service->timeout > 0) {
+ g_source_remove(service->timeout);
+ service->timeout = 0;
+ }
+
+ if (service->pending != NULL) {
+ if (error > 0) {
+ DBusMessage *reply;
+
+ reply = __connman_error_failed(service->pending,
+ error);
+ if (reply != NULL)
+ g_dbus_send_message(connection, reply);
+ } else
+ g_dbus_send_reply(connection, service->pending,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_unref(service->pending);
+ service->pending = NULL;
+ }
+}
+
static gboolean connect_timeout(gpointer user_data)
{
struct connman_service *service = user_data;
@@ -591,19 +615,7 @@ static DBusMessage *disconnect_service(DBusConnection *conn,
DBG("service %p", service);
if (service->pending != NULL) {
- DBusMessage *reply;
-
- if (service->timeout > 0) {
- g_source_remove(service->timeout);
- service->timeout = 0;
- }
-
- reply = __connman_error_operation_aborted(service->pending);
- if (reply != NULL)
- g_dbus_send_message(conn, reply);
-
- dbus_message_unref(service->pending);
- service->pending = NULL;
+ reply_pending(service, ECONNABORTED);
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
@@ -735,20 +747,12 @@ static void service_free(gpointer user_data)
g_hash_table_remove(service_hash, service->identifier);
- if (service->timeout > 0) {
- g_source_remove(service->timeout);
- service->timeout = 0;
- }
-
- if (service->pending != NULL) {
- dbus_message_unref(service->pending);
- service->pending = NULL;
- }
+ reply_pending(service, ENOENT);
service->path = NULL;
if (path != NULL) {
- __connman_profile_changed(TRUE);
+ __connman_profile_changed(FALSE);
g_dbus_unregister_interface(connection, path,
CONNMAN_SERVICE_INTERFACE);
@@ -767,39 +771,6 @@ static void service_free(gpointer user_data)
g_free(service);
}
-static void reply_pending(struct connman_service *service, int error)
-{
- if (service->timeout > 0) {
- g_source_remove(service->timeout);
- service->timeout = 0;
- }
-
- if (service->pending != NULL) {
- if (error > 0) {
- DBusMessage *reply;
-
- reply = __connman_error_failed(service->pending,
- error);
- if (reply != NULL)
- g_dbus_send_message(connection, reply);
- } else
- g_dbus_send_reply(connection, service->pending,
- DBUS_TYPE_INVALID);
-
- dbus_message_unref(service->pending);
- service->pending = NULL;
- }
-}
-
-static gboolean remove_timeout(gpointer user_data)
-{
- GSequenceIter *iter = user_data;
-
- g_sequence_remove(iter);
-
- return FALSE;
-}
-
/**
* __connman_service_put:
* @service: service structure
@@ -815,9 +786,7 @@ void __connman_service_put(struct connman_service *service)
iter = g_hash_table_lookup(service_hash, service->identifier);
if (iter != NULL) {
- guint interval = 1;
-
- reply_pending(service, EIO);
+ reply_pending(service, ENOENT);
__connman_service_disconnect(service);
@@ -825,8 +794,7 @@ void __connman_service_put(struct connman_service *service)
service->error = CONNMAN_SERVICE_ERROR_OUT_OF_RANGE;
state_changed(service);
- service->timeout = g_timeout_add_seconds(interval,
- remove_timeout, iter);
+ g_sequence_remove(iter);
} else
service_free(service);
}