bus_name_has_owner in python
h at realh.co.uk
Sat Mar 17 14:59:16 PDT 2007
In <45FC1C27.3090203 at redhat.com>, Havoc Pennington wrote:
> 1) you should not use bus_name_has_owner() for this because you're
> creating a race condition. Instead, you need to write the code as follows:
> - try to request the name
> - if the request *fails* due to an existing owner, then exit
> - otherwise, you are the unique instance and can continue
> This guarantees that you either have the name or someone else does.
> Also, this way uses fewer round trips and is thus a bit faster.
Thanks. It definitely makes more sense to do it that way; I hadn't
thought about the race condition before or noticed how useful were the
return codes and flags for dbus_bus_request_name(). I've got a C program
that uses D-BUS too and when I originally wrote the code for that the
function was still called dbus_bus_acquire_service(). Did its API get
extended or the documentation for it get improved at some point?
TH * http://www.realh.co.uk
More information about the dbus