device: Unregister Record before Device
authorSamuel Ortiz <sameo@linux.intel.com>
Sun, 10 Nov 2013 16:20:30 +0000 (17:20 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 10 Nov 2013 16:57:09 +0000 (17:57 +0100)
When a Device is leaving the field, it makes more sense to unregister
its associated records before the Device itself.

src/device.c

index dba0efe..9a3e48c 100644 (file)
@@ -66,6 +66,9 @@ static void free_device(gpointer data)
 
        near_ndef_records_free(device->records);
 
+       g_dbus_unregister_interface(connection, device->path,
+                                               NFC_DEVICE_INTERFACE);
+
        g_free(device->path);
        g_free(device->data);
        g_free(device);
@@ -234,15 +237,9 @@ void __near_device_remove(struct near_device *device)
 
        DBG("path %s", device->path);
 
-       if (!g_hash_table_lookup(device_hash, device->path))
-               return;
-
        if (device->push_msg)
                push_cb(device->adapter_idx, device->target_idx, EIO);
 
-       g_dbus_unregister_interface(connection, device->path,
-                                               NFC_DEVICE_INTERFACE);
-
        g_hash_table_remove(device_hash, path);
 }