diff mbox series

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

Message ID 20201028154914.Bluez.1.I8216fab388e34d8a1373efc71a252c2c5a085564@changeid (mailing list archive)
State New, archived
Headers show
Series [Bluez] adapter: Use initial temporary status to decide device removal | expand

Commit Message

Daniel Winkler Oct. 28, 2020, 10:50 p.m. UTC
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@chromium.org>
---

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

Comments

bluez.test.bot@gmail.com Oct. 28, 2020, 11:33 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=372435

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS



---
Regards,
Linux Bluetooth
diff mbox series

Patch

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);
 }