From 36d0506a28a2413467d2c5e793d53c45b2183d34 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 20 Apr 2007 15:41:32 +0000 Subject: Check connection busy before removing it. --- network/connection.c | 11 +++++++++++ network/connection.h | 1 + network/manager.c | 3 +++ 3 files changed, 15 insertions(+) (limited to 'network') diff --git a/network/connection.c b/network/connection.c index c31c423a..e3b85929 100644 --- a/network/connection.c +++ b/network/connection.c @@ -698,3 +698,14 @@ int connection_find_data(DBusConnection *conn, return -1; } + +gboolean connection_has_pending(DBusConnection *conn, const char *path) +{ + struct network_conn *nc; + + if (!dbus_connection_get_object_path_data(conn, path, (void *) &nc)) + return FALSE; + + return (nc->state == CONNECTING); +} + diff --git a/network/connection.h b/network/connection.h index b03c3caa..205e44da 100644 --- a/network/connection.h +++ b/network/connection.h @@ -26,3 +26,4 @@ int connection_register(DBusConnection *conn, const char *path, bdaddr_t *src, int connection_store(DBusConnection *conn, const char *path); int connection_find_data(DBusConnection *conn, const char *path, const char *pattern); +gboolean connection_has_pending(DBusConnection *conn, const char *path); diff --git a/network/manager.c b/network/manager.c index 898a183b..65d8634b 100644 --- a/network/manager.c +++ b/network/manager.c @@ -164,6 +164,9 @@ static DBusHandlerResult remove_path(DBusConnection *conn, if (!l) return err_does_not_exist(conn, msg, "Path doesn't exist"); + if (*list == connection_paths && connection_has_pending (conn, path)) + return err_failed(conn, msg, "Connection is Busy"); + g_free(l->data); *list = g_slist_remove(*list, l->data); -- cgit