wifi: Fixing autoscan device unref issues
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Tue, 24 Apr 2012 15:10:00 +0000 (18:10 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 24 Apr 2012 15:09:50 +0000 (17:09 +0200)
- stop_autoscan() should unref the device only when relevant, i.e. when
interval and/or timeout have been set.
- autoscan_scan_callback() should unref the device since it has been
referenced in throw_wifi_scan()

plugins/wifi.c

index 28b3563..9ce380b 100644 (file)
@@ -214,8 +214,10 @@ static void stop_autoscan(struct connman_device *device)
 
        autoscan = wifi->autoscan;
 
-       if (autoscan->timeout > 0)
-               g_source_remove(autoscan->timeout);
+       if (autoscan->timeout == 0 && autoscan->interval == 0)
+               return;
+
+       g_source_remove(autoscan->timeout);
 
        autoscan->timeout = 0;
        autoscan->interval = 0;
@@ -281,6 +283,7 @@ static void autoscan_scan_callback(int result,
        DBG("");
 
        connman_device_set_scanning(device, FALSE);
+       connman_device_unref(device);
 }
 
 static gboolean autoscan_timeout(gpointer data)