All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] device: Fix calling DisconnectProfile DBus call with disconnected profile UUID
Date: Sun, 26 Apr 2020 23:02:02 +0200	[thread overview]
Message-ID: <20200426210202.700-1-pali@kernel.org> (raw)

When DisconnectProfile is called with disconnected UUID, bluetooth daemon
often returned error "Operation already in progress". This change fixed it
and no error message is returned for this case.
---
 src/device.c  | 5 +++++
 src/service.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index 149c45160..229579378 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2054,6 +2054,9 @@ static DBusMessage *disconnect_profile(DBusConnection *conn, DBusMessage *msg,
 	if (dev->disconnect)
 		return btd_error_in_progress(msg);
 
+	if (btd_service_get_state(service) == BTD_SERVICE_STATE_DISCONNECTED)
+		return dbus_message_new_method_return(msg);
+
 	dev->disconnect = dbus_message_ref(msg);
 
 	err = btd_service_disconnect(service);
@@ -2065,6 +2068,8 @@ static DBusMessage *disconnect_profile(DBusConnection *conn, DBusMessage *msg,
 
 	if (err == -ENOTSUP)
 		return btd_error_not_supported(msg);
+	else if (err == -EALREADY)
+		return dbus_message_new_method_return(msg);
 
 	return btd_error_failed(msg, strerror(-err));
 }
diff --git a/src/service.c b/src/service.c
index c14ee0aca..e4d747a6e 100644
--- a/src/service.c
+++ b/src/service.c
@@ -281,8 +281,9 @@ int btd_service_disconnect(struct btd_service *service)
 	case BTD_SERVICE_STATE_UNAVAILABLE:
 		return -EINVAL;
 	case BTD_SERVICE_STATE_DISCONNECTED:
-	case BTD_SERVICE_STATE_DISCONNECTING:
 		return -EALREADY;
+	case BTD_SERVICE_STATE_DISCONNECTING:
+		return 0;
 	case BTD_SERVICE_STATE_CONNECTING:
 	case BTD_SERVICE_STATE_CONNECTED:
 		break;
-- 
2.20.1


             reply	other threads:[~2020-04-26 21:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26 21:02 Pali Rohár [this message]
2020-04-27 16:37 ` [PATCH] device: Fix calling DisconnectProfile DBus call with disconnected profile UUID Luiz Augusto von Dentz
2020-04-27 18:07   ` Pali Rohár
2020-04-29  0:37     ` Luiz Augusto von Dentz

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=20200426210202.700-1-pali@kernel.org \
    --to=pali@kernel.org \
    --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.