aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2024-03-18 16:04:59 +0000
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2024-03-18 16:10:20 +0000
commit8060d1208673826665b7297c27aa75003521b52a (patch)
treed37dfb603d901197f17c57c5c496914d484f7e66
parent84628e5d109cbec0bbd515c12c4b5224380784fe (diff)
device: Fix device_is_connected checking for services being connected
Change 44d3f67277f83983e1e9697eda7b9aeb40ca231d seems to have introduced quite a few bugs related to device_is_connected return true which prevents proper cleanup of connection. Fixes: https://github.com/bluez/bluez/issues/774 Fixes: https://github.com/bluez/bluez/issues/778 Fixes: https://github.com/bluez/bluez/issues/783 Fixes: https://github.com/bluez/bluez/issues/784
-rw-r--r--src/device.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/device.c b/src/device.c
index aecceb1007..b5b5742334 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3324,22 +3324,24 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type,
"Connected");
}
+static bool device_service_connected(struct btd_device *dev)
+{
+ if (find_service_with_state(dev->services,
+ BTD_SERVICE_STATE_CONNECTING))
+ return true;
+
+ return find_service_with_state(dev->services,
+ BTD_SERVICE_STATE_CONNECTED);
+}
+
static bool device_disappeared(gpointer user_data)
{
struct btd_device *dev = user_data;
- if (btd_device_is_connected(dev)) {
- char addr[18];
- ba2str(&dev->bdaddr, addr);
- DBG("Device %s is marked as connected", dev->path);
- return TRUE;
- }
-
- /* If there are services connecting restart the timer to give more time
+ /* If there are services connected restart the timer to give more time
* for the service to either complete the connection or disconnect.
*/
- if (find_service_with_state(dev->services,
- BTD_SERVICE_STATE_CONNECTING))
+ if (device_service_connected(dev))
return TRUE;
dev->temporary_timer = 0;