Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Mikel Astiz <mikel.astiz.oss@gmail.com>
Cc: linux-bluetooth@vger.kernel.org, Mikel Astiz <mikel.astiz@bmw-carit.de>
Subject: Re: [PATCH v0] core: Fix racy D-Bus service name request
Date: Wed, 06 Feb 2013 09:39:59 +0200	[thread overview]
Message-ID: <1360136399.15783.1.camel@aeonflux> (raw)
In-Reply-To: <1360076455-32716-1-git-send-email-mikel.astiz.oss@gmail.com>

Hi Mikel,

> The ObjectManager interface should already be ready by the time the
> D-Bus service name is owned. Hence, use g_dbus_request_name() explicitly
> once g_dbus_attach_object_manager() has finished.
> 
> Without this patch, clients relying on the presence of the ObjectManager
> could potentially face a race condition.

I almost expected that someone sooner or later will run into this issue.

> ---
>  src/main.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/main.c b/src/main.c
> index 1e40ebc..12ae3d9 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -424,7 +424,7 @@ static int connect_dbus(void)
>  
>  	dbus_error_init(&err);
>  
> -	conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, BLUEZ_NAME, &err);
> +	conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &err);
>  	if (!conn) {
>  		if (dbus_error_is_set(&err)) {
>  			g_printerr("D-Bus setup failed: %s\n", err.message);
> @@ -439,6 +439,12 @@ static int connect_dbus(void)
>  	g_dbus_set_disconnect_function(conn, disconnected_dbus, NULL, NULL);
>  	g_dbus_attach_object_manager(conn);
>  
> +	if (!g_dbus_request_name(conn, BLUEZ_NAME, &err)) {
> +		g_printerr("D-Bus service name request failed: %s\n",
> +								err.message);
> +		return -EIO;
> +	}
> +

The only thing that I do not really like here is that the request name
is actually a blocking call. If we are trying to fix this, then we might
actually really do this async.

Regards

Marcel



  reply	other threads:[~2013-02-06  7:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-05 15:00 [PATCH v0] core: Fix racy D-Bus service name request Mikel Astiz
2013-02-06  7:39 ` Marcel Holtmann [this message]
2013-02-06  8:08   ` 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=1360136399.15783.1.camel@aeonflux \
    --to=marcel@holtmann.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mikel.astiz.oss@gmail.com \
    --cc=mikel.astiz@bmw-carit.de \
    /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