Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
From: Scott Mertz <scottmertz2@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Scott Mertz <scottmertz2@gmail.com>
Subject: [PATCH] device: cancel connection request if browsing is cancelled
Date: Fri, 13 Sep 2019 12:00:41 -0700
Message-ID: <1568401241-24619-1-git-send-email-scottmertz2@gmail.com> (raw)

If a dbus client calls Connect before service discovery is complete,
then attempts to cancel that by calling Disconnect, the original
Connect request would never be completed.

This fixes the bug by cancelling the Connect call upon cancelling
the browse request, which is done when Disconnect is called.
---
 src/device.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/device.c b/src/device.c
index 263f60a..b8247cf 100644
--- a/src/device.c
+++ b/src/device.c
@@ -626,6 +626,12 @@ static void browse_request_cancel(struct browse_req *req)
 
 	attio_cleanup(device);
 
+	if (req->msg && dbus_message_is_method_call(req->msg, DEVICE_INTERFACE,
+								"Connect")) {
+		DBusMessage *reply = btd_error_failed(req->msg, "Cancelled");
+		g_dbus_send_message(dbus_conn, reply);
+	}
+
 	browse_request_free(req);
 }
 
-- 
2.7.4


                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically 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=1568401241-24619-1-git-send-email-scottmertz2@gmail.com \
    --to=scottmertz2@gmail.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

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org linux-bluetooth@archiver.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/ public-inbox