best practice proposal: name locking and process exclusion

David Zeuthen zeuthen at gmail.com
Thu Apr 7 10:18:54 PDT 2011


Hey,

On Thu, Apr 7, 2011 at 12:43 PM, Colin Walters <walters at verbum.org> wrote:
> What I'd like to propose is simply a best practice for components and
> apps acting as services: use two names:  org.example.Foo.Lock for the
> first, and org.example.Foo for your well-known name.

So, just to get this right, this is primarily to avoid two instances
doing the same work and only one of them actually getting the name?

Random thought: Might be nice to be explicit and use
.InitializationLock instead of just .Lock. I don't know.

> If you're using a mainloop, we could actually wrap this up (well, in
> GLib), with a nice API like:
>
>  g_dbus_acquire_exclusive_service_name (MYAPP_NAME);

I think it would be nicer to just add a flag

 G_BUS_NAME_OWNER_FLAGS_EARLY_PROCESS_EXCLUSION

and stick with the existing g_bus_own_name() API.

(Implementation-wise, we'd say that if the
G_BUS_NAME_OWNER_FLAGS_EARLY_PROCESS_EXCLUSION flag was passed and the
.Lock name couldn't be obtained we call name_lost_handler() with a
non-NULL connection as the first thing.)

    David


More information about the dbus mailing list