device: Cancel pending trigger when device is removed
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Mon, 31 Oct 2011 19:30:16 +0000 (20:30 +0100)
committerDaniel Wagner <wagi@monom.org>
Mon, 31 Oct 2011 19:33:09 +0000 (20:33 +0100)
connmand[28326]: src/device.c:device_destruct() device 0x6b97c0 name candlejack.bmw-carit.intra-1
connmand[28326]: plugins/bluetooth.c:powered_reply()
connmand[28326]: Name "org.bluez" does not exist
connmand[28326]: src/device.c:device_pending_reset() device 0x6b97c0

src/device.c

index fedd581..9ba7caf 100644 (file)
@@ -96,6 +96,14 @@ static void clear_scan_trigger(struct connman_device *device)
        }
 }
 
+static void clear_pending_trigger(struct connman_device *device)
+{
+       if (device->pending_timeout > 0) {
+               g_source_remove(device->pending_timeout);
+               device->pending_timeout = 0;
+       }
+}
+
 static void reset_scan_trigger(struct connman_device *device)
 {
        clear_scan_trigger(device);
@@ -438,6 +446,7 @@ static void device_destruct(struct connman_device *device)
 {
        DBG("device %p name %s", device, device->name);
 
+       clear_pending_trigger(device);
        clear_scan_trigger(device);
 
        g_free(device->ident);
@@ -663,11 +672,7 @@ int connman_device_set_powered(struct connman_device *device,
        if (device->powered == powered)
                return -EALREADY;
 
-       if (device->pending_timeout) {
-               /* Reset pending request */
-               g_source_remove(device->pending_timeout);
-               device->pending_timeout = 0;
-       }
+       clear_pending_trigger(device);
 
        device->powered_pending = PENDING_NONE;