From: Jaikumar Ganesh <jaikumar@google.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Update SDP storage records when a record is deleted.
Date: Thu, 29 Oct 2009 13:30:14 -0700 [thread overview]
Message-ID: <e8892a6a0910291330q2169e53pb30816dd24bf359d@mail.gmail.com> (raw)
In-Reply-To: <e8892a6a0910291142w7d3271d8v13ec5e35330821ac@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1268 bytes --]
Hi Johan:
On Thu, Oct 29, 2009 at 11:42 AM, Jaikumar Ganesh <jaikumar@google.com> wrote:
> Hi Johan:
>
> On Wed, Oct 28, 2009 at 5:15 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
>> Hi,
>>
>> On Wed, Oct 28, 2009, Jaikumar Ganesh wrote:
>>> > On Wed, Oct 28, 2009, Jaikumar Ganesh wrote:
>>> >> The SDP cache is removed when the device is removed. In fact, you
>>> >> fixed this a few days back.
>>> >
>>> > Which commit are you referring to?
>>>
>>> Commit number:
>>>
>>> 4bec43039626e853489e72149014868f8c8afedc
>>>
>>> http://git.kernel.org/?p=bluetooth/bluez.git;a=commit;h=4bec43039626e853489e72149014868f8c8afedc
>>
>> Ok, so we're talking about different things here. I was talking about
>> removing the records from /var/lib/bluetooth/...
>>
>>> We can also fix this by removing the on disk SDP records when the
>>> device is freed.
>>> (I think which is what you suggested - by cache I was interpreting it
>>> as in memory cache)
>>> Will submit a new patch. Let me know if I read you wrong.
>>
>> No, you're right. I was referring to the disk cache. I'm glad we have this
>> misunderstanding finally sorted out :)
>
> New patch attached.
The patch broken into 2 patches are attached.
>
>>
>> Johan
>>
>
[-- Attachment #2: 0001-When-a-device-is-removed-delete-the-SDP-records.patch --]
[-- Type: text/x-diff, Size: 2600 bytes --]
From edfa5d2aac3173964e914f9feea511e62025e051 Mon Sep 17 00:00:00 2001
From: Jaikumar Ganesh <jaikumar@google.com>
Date: Thu, 29 Oct 2009 13:19:51 -0700
Subject: [PATCH 1/2] When a device is removed delete the SDP records.
This fixes the issues of stale SDP records, when the
SDP records are modified on the remote end, before the next
connection. Since we are going to perform SDP on the next connection
anyway, this doesn't introduce any new overheads.
---
src/device.c | 2 ++
src/storage.c | 20 ++++++++++++++++++++
src/storage.h | 1 +
3 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/device.c b/src/device.c
index 6cb9641..5585271 100644
--- a/src/device.c
+++ b/src/device.c
@@ -937,10 +937,12 @@ static void device_remove_stored(struct btd_device *device)
adapter_get_address(device->adapter, &src);
ba2str(&device->bdaddr, addr);
+
if (device->paired)
device_remove_bonding(device);
delete_entry(&src, "profiles", addr);
delete_entry(&src, "trusts", addr);
+ delete_all_records(&src, &device->bdaddr);
}
void device_remove(struct btd_device *device, gboolean remove_stored)
diff --git a/src/storage.c b/src/storage.c
index 5760656..cd33206 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -913,6 +913,26 @@ static void create_stored_records_from_keys(char *key, char *value,
rec_list->recs = sdp_list_append(rec_list->recs, rec);
}
+void delete_all_records(bdaddr_t *src, bdaddr_t *dst)
+{
+ sdp_list_t *records, *seq;
+ sdp_record_t *rec;
+ char srcaddr[18], dstaddr[18];
+
+ ba2str(src, srcaddr);
+ ba2str(dst, dstaddr);
+
+ records = read_records(src, dst);
+
+ for (seq = records; seq; seq = seq->next) {
+ rec = seq->data;
+ delete_record(srcaddr, dstaddr, rec->handle);
+ }
+
+ if (records)
+ sdp_list_free(records, (sdp_free_func_t) sdp_record_free);
+}
+
sdp_list_t *read_records(bdaddr_t *src, bdaddr_t *dst)
{
char filename[PATH_MAX + 1];
diff --git a/src/storage.h b/src/storage.h
index 3159f2a..6e40151 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -63,6 +63,7 @@ int store_record(const gchar *src, const gchar *dst, sdp_record_t *rec);
sdp_record_t *record_from_string(const gchar *str);
sdp_record_t *fetch_record(const gchar *src, const gchar *dst, const uint32_t handle);
int delete_record(const gchar *src, const gchar *dst, const uint32_t handle);
+void delete_all_records(bdaddr_t *src, bdaddr_t *dst);
sdp_list_t *read_records(bdaddr_t *src, bdaddr_t *dst);
sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid);
int store_device_id(const gchar *src, const gchar *dst,
--
1.6.2.3
[-- Attachment #3: 0002-Fix-handling-of-SDP-records.patch --]
[-- Type: text/x-diff, Size: 1858 bytes --]
From 1b901dabde304237dc1ca05eb17a42137a650e16 Mon Sep 17 00:00:00 2001
From: Jaikumar Ganesh <jaikumar@google.com>
Date: Thu, 29 Oct 2009 13:24:05 -0700
Subject: [PATCH 2/2] Fix handling of SDP records.
We were deleting the SDP records only if a device
was registered for those UUIDs. With this change,
we delete the SDP records even if there are no
drivers registered.
---
src/device.c | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/src/device.c b/src/device.c
index 5585271..760e661 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1136,8 +1136,6 @@ static void device_remove_drivers(struct btd_device *device, GSList *uuids)
next = list->next;
for (uuid = driver->uuids; *uuid; uuid++) {
- sdp_record_t *rec;
-
if (!g_slist_find_custom(uuids, *uuid,
(GCompareFunc) strcasecmp))
continue;
@@ -1150,24 +1148,27 @@ static void device_remove_drivers(struct btd_device *device, GSList *uuids)
driver_data);
g_free(driver_data);
- rec = find_record_in_list(records, *uuid);
- if (!rec)
- break;
+ break;
+ }
+ }
- delete_record(srcaddr, dstaddr, rec->handle);
+ for (list = uuids; list; list = list->next) {
+ device->uuids = g_slist_remove(device->uuids, list->data);
- records = sdp_list_remove(records, rec);
- sdp_record_free(rec);
+ sdp_record_t *rec;
+ rec = find_record_in_list(records, list->data);
+ if (!rec)
+ continue;
+
+ delete_record(srcaddr, dstaddr, rec->handle);
+
+ records = sdp_list_remove(records, rec);
+ sdp_record_free(rec);
- break;
- }
}
if (records)
sdp_list_free(records, (sdp_free_func_t) sdp_record_free);
-
- for (list = uuids; list; list = list->next)
- device->uuids = g_slist_remove(device->uuids, list->data);
}
static void services_changed(struct btd_device *device)
--
1.6.2.3
next prev parent reply other threads:[~2009-10-29 20:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-22 23:19 [PATCH] Update SDP storage records when a record is deleted Jaikumar Ganesh
2009-10-22 23:58 ` Johan Hedberg
2009-10-23 13:49 ` Luiz Augusto von Dentz
2009-10-23 15:17 ` Jaikumar Ganesh
2009-10-23 17:44 ` Luiz Augusto von Dentz
2009-10-26 15:20 ` Jaikumar Ganesh
2009-10-28 19:00 ` jaikumar Ganesh
2009-10-28 23:34 ` Johan Hedberg
2009-10-28 23:45 ` Jaikumar Ganesh
2009-10-28 23:54 ` Johan Hedberg
2009-10-29 0:02 ` Jaikumar Ganesh
2009-10-29 0:15 ` Johan Hedberg
2009-10-29 18:42 ` Jaikumar Ganesh
2009-10-29 20:30 ` Jaikumar Ganesh [this message]
2009-10-29 20:34 ` Luiz Augusto von Dentz
2009-10-29 21:04 ` Jaikumar Ganesh
2009-10-29 21:13 ` Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e8892a6a0910291330q2169e53pb30816dd24bf359d@mail.gmail.com \
--to=jaikumar@google.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox