[Bluez PATCH] adapter: Use initial temporary status to decide device removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When a connection fails, the temporary attribute of the device is used
to decide if the device should be removed altogether. However, a recent
change to device_bonding_complete resets the temporary attribute so that
it will be treated as a new device which will eventually time out. A
side effect, though, is that the device will now always be removed in
connect_failed_callback immediately, regardless of whether the device
was marked as temporary to begin with.

This change stores the device's temporary attribute before
device_bonding_complete is called to ensure it is only removed if the
device was temporary to begin with. Otherwise it will timeout, as I
think the author intended.

Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@xxxxxxxxxxxx>
---

 src/adapter.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index c0053000a..9eb60ba03 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -8877,6 +8877,7 @@ static void connect_failed_callback(uint16_t index, uint16_t length,
 	struct btd_adapter *adapter = user_data;
 	struct btd_device *device;
 	char addr[18];
+	bool initially_temporary = true;
 
 	if (length < sizeof(*ev)) {
 		btd_error(adapter->dev_id, "Too small connect failed event");
@@ -8897,6 +8898,11 @@ static void connect_failed_callback(uint16_t index, uint16_t length,
 		 * request structure. */
 		if (device_is_bonding(device, NULL))
 			device_cancel_authentication(device, FALSE);
+
+		/* Store whether device is temporary before the attribute is
+		 * cleared in bonding_attempt_complete
+		 */
+		initially_temporary = device_is_temporary(device);
 	}
 
 	/* In the case of security mode 3 devices */
@@ -8914,8 +8920,7 @@ static void connect_failed_callback(uint16_t index, uint16_t length,
 
 	/* In the case the bonding was canceled or did exists, remove the device
 	 * when it is temporary. */
-	if (device && !device_is_bonding(device, NULL)
-						&& device_is_temporary(device))
+	if (device && !device_is_bonding(device, NULL) && initially_temporary)
 		btd_adapter_remove_device(adapter, device);
 }
 
-- 
2.29.1.341.ge80a0c044ae-goog




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux