Re: DBUS - Is it possible to have 2 instance of session bus or something similar?‏

Simon McVittie simon.mcvittie at collabora.co.uk
Fri Dec 7 03:49:03 PST 2012


On 07/12/12 06:09, Manoj.Sing wrote:
> (For ex) Node-A and Node-B both emits SIGNAL-1 and Node-X and Node-Y
> both would like to receive SIGNAL-1 (they have registered for SIGNAL-1
> by dbus_add_match() call), 
> Now, if once the signal-1 gets emitted, the dbus daemon will deliver it
> to both Node-X and Node-Y. 
> Where as my requirement is Node-A's signal-1 should be received by
> Node-X and Node-B's SINGAL-1 should be receieved by Node-B

That's all pretty vague. Without knowing what you want to achieve, I
can't give very good advice.

Would you be equally happy with A's signal being received by Y and B's
signal being received by X (i.e. each signal goes to an arbitrarily
chosen recipient), or is there something specific that ties together
(A,X) and (B,Y)?

If there is something special about the pairs (A,X) and (B,Y), then A
and B could use different well-known bus names, and X and Y should each
AddMatch() for their corresponding service.

Using a private bus or private connection for each pair is only
desirable if you're doing something quite strange (either not
conceptually part of "the session" or "the system", or sufficiently
high-data-rate that doing it on the session bus would be a problem - but
if your task is that high-data-rate, then D-Bus is not really designed
for it).

> 1. dbus_connection_open_private() - Not much help, not sure on usage
> part as limited documentation is available.

Using an out-of-band connection is not recommended unless you're
(willing to become) a D-Bus expert; but if it's what you need, here is
an outline of how to do it:

* in A and B, use DBusServer to listen on a "vague" address, probably
  unix:tmpdir=/tmp or nonce-tcp:host=127.0.0.1

* get the "connectable" address of that DBusServer from
  dbus_server_get_address()

* in X and Y, connect to it with dbus_connection_open_private()

* it's a direct peer-to-peer connection, not a bus connection,
  so there is no name ownership and there are no broadcasts

(Some of the libdbus regression tests do this.)

Another way to do similarly is to have a private session-like bus by
running a dbus-daemon with your own configuration (--config
/etc/dbus-1/something.conf, where something.conf is provided by you and
resembles session.conf, instead of --session), capturing its address
using a pipe and the --print-address parameter, and connecting to that
with dbus_connection_open_private() followed by dbus_bus_register(). I
think this is how AT-SPI, as used in current GNOME, works.

    S


More information about the dbus mailing list