diff mbox series

[BlueZ] device: delete cache file when device is removed

Message ID 20210825172936.2691027-1-david@lechnology.com (mailing list archive)
State Accepted
Delegated to: Luiz Von Dentz
Headers show
Series [BlueZ] device: delete cache file when device is removed | expand

Commit Message

David Lechner Aug. 25, 2021, 5:29 p.m. UTC
When a device is removed from BlueZ, it should be completely forgotten
so that when it is seen again, it behaves exactly the same as if this
was the first time the device was ever seen.

So instead of just deleting one section of the cache file, we delete
the entire file.

This fixes issues with the GATT cache being retained and used for
devices that don't have ServicesChanged or Database Hash characteristics
to indicate that the attributes on the device have changed.

Issue: https://github.com/bluez/bluez/issues/191
Signed-off-by: David Lechner <david@lechnology.com>
---
 src/device.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

Comments

bluez.test.bot@gmail.com Aug. 25, 2021, 5:57 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=537293

---Test result---

Test Summary:
CheckPatch                    PASS      0.28 seconds
GitLint                       PASS      0.10 seconds
Prep - Setup ELL              PASS      40.03 seconds
Build - Prep                  PASS      0.09 seconds
Build - Configure             PASS      7.02 seconds
Build - Make                  PASS      175.01 seconds
Make Check                    PASS      8.81 seconds
Make Distcheck                PASS      206.38 seconds
Build w/ext ELL - Configure   PASS      7.04 seconds
Build w/ext ELL - Make        PASS      164.16 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/src/device.c b/src/device.c
index 6d534c488..b51d9df4d 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4485,9 +4485,6 @@  static void device_remove_stored(struct btd_device *device)
 {
 	char device_addr[18];
 	char filename[PATH_MAX];
-	GKeyFile *key_file;
-	char *data;
-	gsize length = 0;
 
 	if (device->bredr_state.bonded)
 		device_remove_bonding(device, BDADDR_BREDR);
@@ -4511,19 +4508,7 @@  static void device_remove_stored(struct btd_device *device)
 	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s",
 				btd_adapter_get_storage_dir(device->adapter),
 				device_addr);
-
-	key_file = g_key_file_new();
-	g_key_file_load_from_file(key_file, filename, 0, NULL);
-	g_key_file_remove_group(key_file, "ServiceRecords", NULL);
-
-	data = g_key_file_to_data(key_file, &length, NULL);
-	if (length > 0) {
-		create_file(filename, 0600);
-		g_file_set_contents(filename, data, length, NULL);
-	}
-
-	g_free(data);
-	g_key_file_free(key_file);
+	unlink(filename);
 }
 
 void device_remove(struct btd_device *device, gboolean remove_stored)