[PATCH BlueZ v1] a2dp: Fix removing local cache on restart

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

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

Endpoint cache shall only be removed when the device is being removed
not when just because the service is being removed since that is also
done when bluetoothd is being restarted.

Fixes: https://github.com/bluez/bluez/issues/1146
---
 profiles/audio/a2dp.c | 40 ----------------------------------------
 src/device.c          |  1 +
 2 files changed, 1 insertion(+), 40 deletions(-)

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 81dbbfae39f6..0eac151db29d 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -880,44 +880,6 @@ static void store_remote_seps(struct a2dp_channel *chan)
 	g_key_file_free(key_file);
 }
 
-static void remove_endpoints_cache(struct btd_service *service)
-{
-	struct btd_device *device = btd_service_get_device(service);
-	char filename[PATH_MAX];
-	char dst_addr[18];
-	GKeyFile *key_file;
-	GError *gerr = NULL;
-	char *data;
-	gsize length = 0;
-
-	ba2str(device_get_address(device), dst_addr);
-
-	create_filename(filename, PATH_MAX, "/%s/cache/%s",
-		btd_adapter_get_storage_dir(device_get_adapter(device)),
-		dst_addr);
-
-	key_file = g_key_file_new();
-	if (!g_key_file_load_from_file(key_file, filename, 0, &gerr)) {
-		g_error_free(gerr);
-		g_key_file_free(key_file);
-		return;
-	}
-	g_key_file_remove_group(key_file, "Endpoints", NULL);
-
-	data = g_key_file_to_data(key_file, &length, NULL);
-	if (length > 0) {
-		create_file(filename, 0600);
-		if (!g_file_set_contents(filename, data, length, &gerr)) {
-			error("Unable set contents for %s: (%s)", filename,
-								gerr->message);
-			g_error_free(gerr);
-		}
-	}
-
-	g_free(data);
-	g_key_file_free(key_file);
-}
-
 static void invalidate_remote_cache(struct a2dp_setup *setup,
 						struct avdtp_error *err)
 {
@@ -3390,7 +3352,6 @@ static int a2dp_source_probe(struct btd_service *service)
 static void a2dp_source_remove(struct btd_service *service)
 {
 	source_unregister(service);
-	remove_endpoints_cache(service);
 }
 
 static int a2dp_sink_probe(struct btd_service *service)
@@ -3405,7 +3366,6 @@ static int a2dp_sink_probe(struct btd_service *service)
 static void a2dp_sink_remove(struct btd_service *service)
 {
 	sink_unregister(service);
-	remove_endpoints_cache(service);
 }
 
 static int a2dp_source_connect(struct btd_service *service)
diff --git a/src/device.c b/src/device.c
index 057d116be6fc..b82a905f9995 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4984,6 +4984,7 @@ static void device_remove_stored(struct btd_device *device)
 	}
 	g_key_file_remove_group(key_file, "ServiceRecords", NULL);
 	g_key_file_remove_group(key_file, "Attributes", NULL);
+	g_key_file_remove_group(key_file, "Endpoints", NULL);
 
 	data = g_key_file_to_data(key_file, &length, NULL);
 	if (length > 0) {
-- 
2.48.1





[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