Skip to contentSkip to conversation

device: reply to connect/disconnect requests on removal

PATCH New Scott Mertz 1 participant 1 message Sep 13, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 device: reply to connect/disconnect requests on removal

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(-)
src/device.c +9 -2
index b8247cf..f42271c 100644
@@ -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);
 
Signature · 1 line
2.7.4