linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikel Astiz <mikel.astiz.oss@gmail.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ 1/2] core/service: Make sure service is disconnected before shutdown
Date: Mon, 8 Jul 2013 13:46:08 +0200	[thread overview]
Message-ID: <CANT-zCUN8L_iVyPmXchmunoKwxt72KR7ZYhbQYtCBwUpxSWbJQ@mail.gmail.com> (raw)
In-Reply-To: <1373033022-11180-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Fri, Jul 5, 2013 at 4:03 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This ensures that the service is disconnected before setting the state
> to unavailable.
> ---
>  src/service.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/service.c b/src/service.c
> index 83e1c1a..dce5c05 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -170,6 +170,7 @@ int service_probe(struct btd_service *service)
>
>  void service_shutdown(struct btd_service *service)
>  {
> +       btd_service_disconnect(service);
>         change_state(service, BTD_SERVICE_STATE_UNAVAILABLE, 0);
>         service->profile->device_remove(service);
>         service->device = NULL;
> --
> 1.8.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

I'm not a big fan of this approach. The service should already be
disconnected by the time it's shut down, so this additional transition
should not be needed.

Having a look at the current code paths leading to service_shutdown(),
one tricky case I can think of is the call to
device_remove_profiles(), specially from search_cb(). I have my doubts
whether a service shutdown makes sense if it's connected, but in case
yes, I'd add the disconnection code to device_remove_profiles().

Or do you have some other examples where the disconnection is not triggered?

Adding one more side effect to service_shutdown() is IMO undesirable,
where the transitional DISCONNECTED state would be artificially
introduced. Think about an external profile being unregistered while
connected devices exist: not only calling
Profile.RequestDisconnection() doesn't make any sense, but a
transition such as STATE_CONNECTED->STATE_UNAVAILABLE is probably what
you want to observe. This can be different from a graceful
disconnection, and a policy module could use this distinction to
reconnect the service once the external profile gets registered.

Cheers,
Mikel

  parent reply	other threads:[~2013-07-08 11:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-05 14:03 [PATCH BlueZ 1/2] core/service: Make sure service is disconnected before shutdown Luiz Augusto von Dentz
2013-07-05 14:03 ` [PATCH BlueZ 2/2] core/device: Fix crash while freeing services list Luiz Augusto von Dentz
2013-07-08 11:46 ` Mikel Astiz [this message]
2013-07-08 12:50   ` [PATCH BlueZ 1/2] core/service: Make sure service is disconnected before shutdown Luiz Augusto von Dentz
2013-07-08 14:13     ` Mikel Astiz
2013-07-08 14:52       ` Luiz Augusto von Dentz
2013-07-08 15:18         ` 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=CANT-zCUN8L_iVyPmXchmunoKwxt72KR7ZYhbQYtCBwUpxSWbJQ@mail.gmail.com \
    --to=mikel.astiz.oss@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).