All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH] device: Fix calling DisconnectProfile DBus call with disconnected profile UUID
Date: Mon, 27 Apr 2020 20:07:07 +0200	[thread overview]
Message-ID: <20200427180707.62igtkaz255viyj6@pali> (raw)
In-Reply-To: <CABBYNZKJUw2PL3vK5xLq9RDQ+V8sW4D9dP-Eh9m=0SXgChcagQ@mail.gmail.com>

On Monday 27 April 2020 09:37:39 Luiz Augusto von Dentz wrote:
> Hi Pali,
> 
> On Sun, Apr 26, 2020 at 2:05 PM Pali Rohár <pali@kernel.org> wrote:
> >
> > 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;
> 
> Have you checked if there are no side effects of this change? Since
> you have a call to btd_service_get_service I wonder if this is really
> necessary or you want to change the behavior to not return an error
> even in case of disconnecting state? But even in that case you are
> checking if for -EALREADY and returning no error.

Same logic is used in btd_service_connect() function. When service is in
disconnecting state then it will receive state change to disconnected.
So returning zero is should same as issuing disconnect request again.

> >         case BTD_SERVICE_STATE_CONNECTING:
> >         case BTD_SERVICE_STATE_CONNECTED:
> >                 break;
> > --
> > 2.20.1
> >
> 
> 
> -- 
> Luiz Augusto von Dentz

  reply	other threads:[~2020-04-27 18:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26 21:02 [PATCH] device: Fix calling DisconnectProfile DBus call with disconnected profile UUID Pali Rohár
2020-04-27 16:37 ` Luiz Augusto von Dentz
2020-04-27 18:07   ` Pali Rohár [this message]
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=20200427180707.62igtkaz255viyj6@pali \
    --to=pali@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /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.