OSDN Git Service

core: Fix manager_cleanup order
authorJohan Hedberg <johan.hedberg@intel.com>
Wed, 14 Nov 2012 08:58:08 +0000 (10:58 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Wed, 14 Nov 2012 08:58:08 +0000 (10:58 +0200)
This patch fixes the order in which things are cleaned up in
manager_cleanup. The profiles need to be cleaned up first (since they
are higher level constructs than adapters and devices) and we cannot
remove the adapter from the manager list before calling adapter_remove
since functions within adapter_remove may remove service records which
in turn relies on having the adapter present in the manager list.

src/manager.c

index 80b26e4..07f9482 100644 (file)
@@ -245,16 +245,16 @@ static void manager_remove_adapter(struct btd_adapter *adapter)
 
 void manager_cleanup(const char *path)
 {
+       btd_profile_cleanup();
+
        while (adapters) {
                struct btd_adapter *adapter = adapters->data;
 
-               adapters = g_slist_remove(adapters, adapter);
                adapter_remove(adapter);
+               adapters = g_slist_remove(adapters, adapter);
                btd_adapter_unref(adapter);
        }
 
-       btd_profile_cleanup();
-
        btd_start_exit_timer();
 
        g_dbus_unregister_interface(btd_get_dbus_connection(),