Re: bug and possible patch for dbus DiscoverServices

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

 



Hi,

On Fri, Jun 11, 2010 at 1:19 AM, Luiz Augusto von Dentz
<luiz.dentz@xxxxxxxxx> wrote:
> Hi,
>
> On Thu, Jun 10, 2010 at 11:20 PM, Tim Renouf <tpr.vger@xxxxxxxxxxxx> wrote:
>> On Thu, Jun 10, 2010 at 04:48:58PM +0300, Luiz Augusto von Dentz wrote:
>>> I would just rework it a bit to make the tmp_records to always store
>>> the last search, something like the following:
>>>
>>> -       if (device->tmp_records && req->records) {
>>> +       if (device->tmp_records)
>>>                 sdp_list_free(device->tmp_records,
>>>                                         (sdp_free_func_t) sdp_record_free);
>>> -               device->tmp_records = req->records;
>>> -               req->records = NULL;
>>> -       }
>>> +
>>> +       device->tmp_records = req->records;
>>> +       req->records = NULL;
>>>
>>>         if (!req->profiles_added && !req->profiles_removed) {
>>>                 DBG("%s: No service update", device->path);
>>> @@ -1522,7 +1522,7 @@ send_reply:
>>>
>>>         if (dbus_message_is_method_call(req->msg, DEVICE_INTERFACE,
>>>                                         "DiscoverServices"))
>>> -               discover_services_reply(req, err, req->records);
>>> +               discover_services_reply(req, err, device->tmp_records);
>>>         else if (dbus_message_is_method_call(req->msg, ADAPTER_INTERFACE,
>>>                                                 "CreatePairedDevice"))
>>>                 create_device_reply(device, req);
>>>
>>> What do you think?
>>
>> Thanks, that looks good, I'll use that.
>>
>> What is the procedure to get it included in future versions of BlueZ ?
>> Does someone sweep this list for patches to review and possibly
>> include ?
>
> Similar to kernel. git format-patch or git pull request, be sure that
> it applies and compiles cleanly against git master.
>
> --
> Luiz Augusto von Dentz
> Computer Engineer
>

There were some problems with the changes I suggested previously,
basically  device_probe_drivers was freeing there records before we
return. The following patches should fix this issue and another one
with btd_device_get_record not looking into records storage when it is
missing on temporary cache.

-- 
Luiz Augusto von Dentz
Computer Engineer
From 25982ed3099f68de120ddf8b23086e3ac289ebd6 Mon Sep 17 00:00:00 2001
From: Luiz Augusto von Dentz <luiz.dentz-von@xxxxxxxxx>
Date: Fri, 11 Jun 2010 12:24:06 +0300
Subject: [PATCH 01/10] Fix DiscoverServices not retrieving any records

In the case that device->tmp_records was already set, req->records was
being set to NULL and so causes the empty array to be returned.

To fix that tmp_records now always has the latest discovered records and
it is used when repling to DiscoverServices.

Thanks to Tim Renouf <tpr.vger@xxxxxxxxxxxx> for figuring out where was
the problem.
---
 src/device.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/device.c b/src/device.c
index 5584de9..0863a79 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1267,12 +1267,6 @@ add_uuids:
 						g_strdup(list->data),
 						(GCompareFunc) strcasecmp);
 	}
-
-	if (device->tmp_records) {
-		sdp_list_free(device->tmp_records,
-				(sdp_free_func_t) sdp_record_free);
-		device->tmp_records = NULL;
-	}
 }
 
 static void device_remove_drivers(struct btd_device *device, GSList *uuids)
@@ -1493,12 +1487,12 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
 
 	update_services(req, recs);
 
-	if (device->tmp_records && req->records) {
+	if (device->tmp_records)
 		sdp_list_free(device->tmp_records,
 					(sdp_free_func_t) sdp_record_free);
-		device->tmp_records = req->records;
-		req->records = NULL;
-	}
+
+	device->tmp_records = req->records;
+	req->records = NULL;
 
 	if (!req->profiles_added && !req->profiles_removed) {
 		DBG("%s: No service update", device->path);
@@ -1522,7 +1516,7 @@ send_reply:
 
 	if (dbus_message_is_method_call(req->msg, DEVICE_INTERFACE,
 					"DiscoverServices"))
-		discover_services_reply(req, err, req->records);
+		discover_services_reply(req, err, device->tmp_records);
 	else if (dbus_message_is_method_call(req->msg, ADAPTER_INTERFACE,
 						"CreatePairedDevice"))
 		create_device_reply(device, req);
-- 
1.7.0.4

From 40afc7d29c1a56be67e7a117c22d6defb83f9e5e Mon Sep 17 00:00:00 2001
From: Luiz Augusto von Dentz <luiz.dentz-von@xxxxxxxxx>
Date: Fri, 11 Jun 2010 12:12:12 +0300
Subject: [PATCH 02/10] Fix not looking into storage when a record is not found in memory

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

diff --git a/src/device.c b/src/device.c
index 0863a79..6c085a3 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2415,8 +2415,13 @@ const sdp_record_t *btd_device_get_record(struct btd_device *device,
 {
 	bdaddr_t src;
 
-	if (device->tmp_records)
-		return find_record_in_list(device->tmp_records, uuid);
+	if (device->tmp_records) {
+		const sdp_record_t *record;
+
+		record = find_record_in_list(device->tmp_records, uuid);
+		if (record != NULL)
+			return record;
+	}
 
 	adapter_get_address(device->adapter, &src);
 
-- 
1.7.0.4


[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