dbus_bus_get VS dbus_connection_open

Havoc Pennington hp at redhat.com
Fri Sep 1 12:11:03 PDT 2006


frederic heem wrote:
> Hi,
> Using dbus_connection_open  instead of dbus_bus_get results in significant 
> differences. dbus_connection_open is used to avoid using the already running  
> system and session bus.
> The problem is the that "org_freedesktop_DBus_request_name" method returns the 
> following error: "Client tried to send a message other than Hello without 
> being registered". Digging into the code shows that the client code that 
> uses "dbus_connection_open" also needs to call "dbus_bus_register". Using 
> dbus_bus_get internally calls dbus_connection_open and dbus_bus_register.
> Why not invoking dbus_bus_register inside dbus_connection_open ? 

The bus is only one possible remote process; you can also just open a 
connection to some random app, if you like. dbus_bus_get pretty much 
_is_ dbus_connection_open + dbus_bus_register.

> Also, dbus-send and dbus-monitor have been modified to accept an address name 
> to use with dbus_connection_open. The path contains this modifications.

Thanks for the patch, some comments:
  - CLI_OPTION_DBUS_ADDRESS probably shouldn't be a #define if none of
    the other options are, I don't think it makes things clearer
  - the variables pcAddress, pcBus, etc. have the wrong naming convention
    (fooBar vs. foo_bar)
  - rather than == FALSE should use !
  - s/examples invocation/example invocations/
  - I believe the code crashes if --address has no '=' after it?
  - "return (-1)" should be "exit (1)" to match the other code

Havoc


More information about the dbus mailing list