All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] a2dp: Fix removing local cache on restart
@ 2025-03-28 14:44 Luiz Augusto von Dentz
  2025-03-28 16:12 ` [BlueZ,v1] " bluez.test.bot
  2025-03-28 18:00 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2025-03-28 14:44 UTC (permalink / raw)
  To: linux-bluetooth

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

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-28 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-28 14:44 [PATCH BlueZ v1] a2dp: Fix removing local cache on restart Luiz Augusto von Dentz
2025-03-28 16:12 ` [BlueZ,v1] " bluez.test.bot
2025-03-28 18:00 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.