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 2/2] device: reply to connect/disconnect requests on removal
Date: Fri, 13 Sep 2019 12:03:28 -0700
Message-ID: <1568401408-24751-1-git-send-email-scottmertz2@gmail.com> (raw)

Replying here prevents the client from getting a DBus
NoReply when the device is removed.
---
 src/device.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/device.c b/src/device.c
index b8247cf..f42271c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -650,6 +650,7 @@ static void svc_dev_remove(gpointer user_data)
 static void device_free(gpointer user_data)
 {
 	struct btd_device *device = user_data;
+	DBusMessage *reply;
 
 	btd_gatt_client_destroy(device->client_dbus);
 	device->client_dbus = NULL;
@@ -677,11 +678,17 @@ static void device_free(gpointer user_data)
 	if (device->discov_timer)
 		g_source_remove(device->discov_timer);
 
-	if (device->connect)
+	if (device->connect) {
+		reply = btd_error_failed(device->connect, "Device removed");
+		g_dbus_send_message(dbus_conn, reply);
 		dbus_message_unref(device->connect);
+	}
 
-	if (device->disconnect)
+	if (device->disconnect) {
+		reply = btd_error_failed(device->disconnect, "Device removed");
+		g_dbus_send_message(dbus_conn, reply);
 		dbus_message_unref(device->disconnect);
+	}
 
 	DBG("%p", device);
 
-- 
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=1568401408-24751-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


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