Disable technology when removing device
authorSamuel Ortiz <sameo@linux.intel.com>
Fri, 13 Aug 2010 17:41:29 +0000 (19:41 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 13 Aug 2010 17:41:29 +0000 (19:41 +0200)
If device_disable() returns being in progress, the technology has to be
disabled. Some technologies like 3G will call remove_device directly when
unplugging a modem and without disabling the corresponding technology,
the notifier enabled refcounts will get out pf sync.

src/device.c
src/technology.c

index fcbfd86..1ab2c3a 100644 (file)
@@ -595,9 +595,13 @@ static void probe_driver(struct connman_element *element, gpointer user_data)
 
 static void remove_device(struct connman_device *device)
 {
+       int err;
+
        DBG("device %p", device);
 
-       __connman_device_disable(device);
+       err = __connman_device_disable(device);
+       if (err < 0 && err == -EINPROGRESS)
+               __connman_technology_disable_device(device);
 
        switch (device->mode) {
        case CONNMAN_DEVICE_MODE_UNKNOWN:
index 47ce692..46fb23f 100644 (file)
@@ -525,7 +525,6 @@ int __connman_technology_remove_device(struct connman_device *device)
        DBG("device %p", device);
 
        type = __connman_device_get_service_type(device);
-       __connman_notifier_disable(type);
        __connman_notifier_unregister(type);
 
        technology = g_hash_table_lookup(device_table, device);