diff mbox series

[BlueZ] adapter: Don't remove temporary devices on disconnect

Message ID 20200718004942.326261-1-luiz.dentz@gmail.com (mailing list archive)
State New, archived
Headers show
Series [BlueZ] adapter: Don't remove temporary devices on disconnect | expand

Commit Message

Luiz Augusto von Dentz July 18, 2020, 12:49 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes the disconnect logic just update last seen field of the
device so in case it is temporary it would trigger its timer and be
removed after the timeout which is consistent with the discovery
session givin a grace time for application to react to such events.
---
 src/adapter.c | 7 -------
 src/device.c  | 2 ++
 2 files changed, 2 insertions(+), 7 deletions(-)

Comments

Luiz Augusto von Dentz July 23, 2020, 4:38 p.m. UTC | #1
Hi,

On Fri, Jul 17, 2020 at 5:50 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This makes the disconnect logic just update last seen field of the
> device so in case it is temporary it would trigger its timer and be
> removed after the timeout which is consistent with the discovery
> session givin a grace time for application to react to such events.
> ---
>  src/adapter.c | 7 -------
>  src/device.c  | 2 ++
>  2 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index c757447e2..5e896a9f0 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -6837,13 +6837,6 @@ static void adapter_remove_connection(struct btd_adapter *adapter,
>                 return;
>
>         adapter->connections = g_slist_remove(adapter->connections, device);
> -
> -       if (device_is_temporary(device) && !device_is_retrying(device)) {
> -               const char *path = device_get_path(device);
> -
> -               DBG("Removing temporary device %s", path);
> -               btd_adapter_remove_device(adapter, device);
> -       }
>  }
>
>  static void adapter_stop(struct btd_adapter *adapter)
> diff --git a/src/device.c b/src/device.c
> index 470596ee4..2237a7670 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -3039,6 +3039,8 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)
>         if (device->bredr_state.connected || device->le_state.connected)
>                 return;
>
> +       device_update_last_seen(device, bdaddr_type);
> +
>         g_dbus_emit_property_changed(dbus_conn, device->path,
>                                                 DEVICE_INTERFACE, "Connected");
>  }
> --
> 2.26.2

Applied.
diff mbox series

Patch

diff --git a/src/adapter.c b/src/adapter.c
index c757447e2..5e896a9f0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -6837,13 +6837,6 @@  static void adapter_remove_connection(struct btd_adapter *adapter,
 		return;
 
 	adapter->connections = g_slist_remove(adapter->connections, device);
-
-	if (device_is_temporary(device) && !device_is_retrying(device)) {
-		const char *path = device_get_path(device);
-
-		DBG("Removing temporary device %s", path);
-		btd_adapter_remove_device(adapter, device);
-	}
 }
 
 static void adapter_stop(struct btd_adapter *adapter)
diff --git a/src/device.c b/src/device.c
index 470596ee4..2237a7670 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3039,6 +3039,8 @@  void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)
 	if (device->bredr_state.connected || device->le_state.connected)
 		return;
 
+	device_update_last_seen(device, bdaddr_type);
+
 	g_dbus_emit_property_changed(dbus_conn, device->path,
 						DEVICE_INTERFACE, "Connected");
 }