All of lore.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@codecoup.pl>
To: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] device: Fix Connect and ConnectProfile returing InProgress error
Date: Fri, 19 Jan 2018 14:33:35 +0100	[thread overview]
Message-ID: <1653790.0KfTnuoApE@ix> (raw)
In-Reply-To: <20180118163753.9084-1-szymon.janc@codecoup.pl>

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



      reply	other threads:[~2018-01-19 13:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-18 16:37 [PATCH] device: Fix Connect and ConnectProfile returing InProgress error Szymon Janc
2018-01-19 13:33 ` Szymon Janc [this message]

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=1653790.0KfTnuoApE@ix \
    --to=szymon.janc@codecoup.pl \
    --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 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.