* [PATCH] device: Fix Connect and ConnectProfile returing InProgress error
@ 2018-01-18 16:37 Szymon Janc
2018-01-19 13:33 ` Szymon Janc
0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2018-01-18 16:37 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Calling Connect or ConnectProfile for device without resolved services
results in doing SDP browse first. After search is complete code was
suppose to continue with profile connection but was always returning
"InProgress" error due to browsing request not being cleared yet.
---
src/device.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/device.c b/src/device.c
index 72f18b309..1acecce33 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2230,6 +2230,7 @@ static void browse_request_complete(struct browse_req *req, uint8_t type,
{
struct btd_device *dev = req->device;
DBusMessage *reply = NULL;
+ DBusMessage *msg;
if (req->type != type)
return;
@@ -2266,19 +2267,31 @@ static void browse_request_complete(struct browse_req *req, uint8_t type,
goto done;
}
- if (dbus_message_is_method_call(req->msg, DEVICE_INTERFACE, "Connect"))
- reply = dev_connect(dbus_conn, req->msg, dev);
- else if (dbus_message_is_method_call(req->msg, DEVICE_INTERFACE,
+ /* if successfully resolved services we need to free browsing request
+ * before passing message back to connect functions, otherwise
+ * device->browse is set and "InProgress" error is returned instead
+ * of actually connecting services
+ */
+ msg = dbus_message_ref(req->msg);
+ browse_request_free(req);
+ req = NULL;
+
+ if (dbus_message_is_method_call(msg, DEVICE_INTERFACE, "Connect"))
+ reply = dev_connect(dbus_conn, msg, dev);
+ else if (dbus_message_is_method_call(msg, DEVICE_INTERFACE,
"ConnectProfile"))
- reply = connect_profile(dbus_conn, req->msg, dev);
+ reply = connect_profile(dbus_conn, msg, dev);
else
- reply = g_dbus_create_reply(req->msg, DBUS_TYPE_INVALID);
+ reply = g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+
+ dbus_message_unref(msg);
done:
if (reply)
g_dbus_send_message(dbus_conn, reply);
- browse_request_free(req);
+ if (req)
+ browse_request_free(req);
}
static void device_set_svc_refreshed(struct btd_device *device, bool value)
--
2.14.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] device: Fix Connect and ConnectProfile returing InProgress error
2018-01-18 16:37 [PATCH] device: Fix Connect and ConnectProfile returing InProgress error Szymon Janc
@ 2018-01-19 13:33 ` Szymon Janc
0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2018-01-19 13:33 UTC (permalink / raw)
To: linux-bluetooth
On Thursday, 18 January 2018 17:37:53 CET Szymon Janc wrote:
> Calling Connect or ConnectProfile for device without resolved services
> results in doing SDP browse first. After search is complete code was
> suppose to continue with profile connection but was always returning
> "InProgress" error due to browsing request not being cleared yet.
> ---
> src/device.c | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/src/device.c b/src/device.c
> index 72f18b309..1acecce33 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -2230,6 +2230,7 @@ static void browse_request_complete(struct browse_req
> *req, uint8_t type, {
> struct btd_device *dev = req->device;
> DBusMessage *reply = NULL;
> + DBusMessage *msg;
>
> if (req->type != type)
> return;
> @@ -2266,19 +2267,31 @@ static void browse_request_complete(struct
> browse_req *req, uint8_t type, goto done;
> }
>
> - if (dbus_message_is_method_call(req->msg, DEVICE_INTERFACE, "Connect"))
> - reply = dev_connect(dbus_conn, req->msg, dev);
> - else if (dbus_message_is_method_call(req->msg, DEVICE_INTERFACE,
> + /* if successfully resolved services we need to free browsing request
> + * before passing message back to connect functions, otherwise
> + * device->browse is set and "InProgress" error is returned instead
> + * of actually connecting services
> + */
> + msg = dbus_message_ref(req->msg);
> + browse_request_free(req);
> + req = NULL;
> +
> + if (dbus_message_is_method_call(msg, DEVICE_INTERFACE, "Connect"))
> + reply = dev_connect(dbus_conn, msg, dev);
> + else if (dbus_message_is_method_call(msg, DEVICE_INTERFACE,
> "ConnectProfile"))
> - reply = connect_profile(dbus_conn, req->msg, dev);
> + reply = connect_profile(dbus_conn, msg, dev);
> else
> - reply = g_dbus_create_reply(req->msg, DBUS_TYPE_INVALID);
> + reply = g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
> +
> + dbus_message_unref(msg);
>
> done:
> if (reply)
> g_dbus_send_message(dbus_conn, reply);
>
> - browse_request_free(req);
> + if (req)
> + browse_request_free(req);
> }
>
> static void device_set_svc_refreshed(struct btd_device *device, bool value)
Applied.
--
pozdrawiam
Szymon Janc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-19 13:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-18 16:37 [PATCH] device: Fix Connect and ConnectProfile returing InProgress error Szymon Janc
2018-01-19 13:33 ` Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox