Fix rearming the scan trigger if a device got disabled
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 23 Jul 2009 07:24:30 +0000 (09:24 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 23 Jul 2009 07:24:30 +0000 (09:24 +0200)
src/device.c

index 48aca8b..0e94999 100644 (file)
@@ -86,12 +86,17 @@ static gboolean device_scan_trigger(gpointer user_data)
        return TRUE;
 }
 
-static void reset_scan_trigger(struct connman_device *device)
+static void clear_scan_trigger(struct connman_device *device)
 {
        if (device->scan_timeout > 0) {
                g_source_remove(device->scan_timeout);
                device->scan_timeout = 0;
        }
+}
+
+static void reset_scan_trigger(struct connman_device *device)
+{
+       clear_scan_trigger(device);
 
        if (device->scan_interval > 0) {
                guint interval = device->scan_interval;
@@ -312,6 +317,8 @@ static int set_powered(struct connman_device *device, connman_bool_t powered)
                } else
                        err = -EINVAL;
        } else {
+               clear_scan_trigger(device);
+
                g_hash_table_remove_all(device->networks);
 
                set_carrier(device, FALSE);
@@ -1304,6 +1311,8 @@ int __connman_device_disable(struct connman_device *device)
        if (device->powered == FALSE)
                return -ENOLINK;
 
+       clear_scan_trigger(device);
+
        g_hash_table_remove_all(device->networks);
 
        err = device->driver->disable(device);