From 3aa815a31017e8793b030b04ef704ce85455b9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Fri, 24 Apr 2020 01:32:43 +0200 Subject: [PATCH] device: Return error when ConnectProfile DBus method fails Without this patch ConnectProfile DBus method does not return failure if profile connection failed and some other profile was already connected. This is not correct behavior as ConnectProfile DBus method should always return error when specified profile failed to connect. This patch fixes this it. --- src/device.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/device.c b/src/device.c index a8d95346a..c2de7b3b9 100644 --- a/src/device.c +++ b/src/device.c @@ -1626,15 +1626,19 @@ done: if (!dev->connect) return; - if (!err && dbus_message_is_method_call(dev->connect, DEVICE_INTERFACE, - "Connect")) - dev->general_connect = TRUE; + if (dbus_message_is_method_call(dev->connect, DEVICE_INTERFACE, + "Connect")) { + if (!err) + dev->general_connect = TRUE; + else if (!find_service_with_state(dev->services, + BTD_SERVICE_STATE_CONNECTED)) + /* Reset error if there are services connected */ + err = 0; + } DBG("returning response to %s", dbus_message_get_sender(dev->connect)); - l = find_service_with_state(dev->services, BTD_SERVICE_STATE_CONNECTED); - - if (err && l == NULL) { + if (err) { /* Fallback to LE bearer if supported */ if (err == -EHOSTDOWN && dev->le && !dev->le_state.connected) { err = device_connect_le(dev); -- 2.47.3