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

Manoj.Sing manoj.sing at aol.in
Mon Dec 10 04:46:55 PST 2012


Hi Simon,
 
Thanks for detailed reply.  I tried couple of options, still no luck. Let me first give you more detailed description of the requirement:
 
In my main application: there are multiple apps (nodes) communication via dbus, with signals (messages) - both broadcast messages and peer-to-peer messages. This is all working fine. Also, the applications(nodes) are duplicated, to form two logical set of applications.
 Set 1 -> Node A ----communicate -----Node X
 Set 2 -> Node B ----communicate -----Node Y
 
Here, the message names and node names are same while registering on to dbus. So, Still Node X and Y, both has subscribed to same message which Node A and B will emit. What I want to achieve is, a possibility of 2 Private Bus, 
on PrivateBus -1 , Only Node A and Node X exists
and on PrivateBus-2 , Only Node B and Node Y exists. Something similar to what you have expalined in last paragraph of your reply.
 
 What I have done till now:
1) Created private1.conf and private2.conf under /etc/dbus-1/ folder.
2) changed path for both the conf files like: unix:abstract=/tmp/private_1 and unix:abstract=/tmp/private_2
3) Generated unique uuid and Set machine-id-1 and machine-id-2 under /var/run/dbus and /var/lib/dbus.
4) created private1 and private2 folders under /root/.dbus/ folder.
5) Started dbus-daemon for both private configuration :
dbus-daemon --fork --print-address --config-file=/etc/dbus-1/private-1.conf
6) Set the DBUS_PRIVATE_1_BUS_ADDRESS with /tmp/private_1 content
7) Source code changes (added DBUS_BUS_PRIVATE in dbus_shared.h and modified the enum N_BUS_TYPE 5 in dbus-bus.c
 
All the above mentioned steps were executed successfully, no issues till now. Now in my source I tried to get on to my Private Bus i.e dbus_bus_get(DBUS_BUS_PRIVATE, &error) and this also worked fine. Now, I am not sure if all the above mentioned steps are in right directions or not but my nodes (sender and receiver) are running and able to communicate on Private BUS(which i hope i have set it up correctly :) ).
 
The Current issue:
I have added 1 Sender node and 2 receiver nodes on to bus(private), just to check if private bus configuration is working fine. Out of 2 receiver nodes, one is on SESSION BUS and another is on PRIVATE BUS and both registered for the same message from same sender. When I am sending the message, it is been received by both the receiver node. This is quite strange behaviour and looks like both are  still on one bus and my private bus is just an alias of original session bus.
 
I did recompiled the dbus source(for one change in dbus-bus.c file) and copied the new binaries in appropriate place. Faced some expected behaviour (system crash) and recovered from there.
 
I need help on following points:
1) Am  i going in right direction? or anything i am missing in here..
2) Alternate approaches, mentioned by you looks bit complex (though can be attempted in order to become DBus expert :) ) and I am looking for some simple solution.
3) I have no clue on these steps and most of experiments are from my learning by working with Dbus in last 6 months. So, I am desperately looking for some help here.
 
The DbusServer based approach can be one possible solution but its something I will try if I don't have any alternate left. Reason: Where ever possible, I am trying not to touch DBus Source and try with setting config n similar stuff to get my work done. I do agree that my requirement is strange and out of the box, but I would like to achieve this as it looks like possible.
  
Thanks,
Manoj Singh
-----Original Message-----
From: Simon McVittie <simon.mcvittie at collabora.co.uk>
To: dbus <dbus at lists.freedesktop.org>
Sent: Fri, Dec 7, 2012 5:19 pm
Subject: Re: DBUS - Is it possible to have 2 instance of session bus or something similar?‏


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
an't give very good advice.
Would you be equally happy with A's signal being received by Y and B's
ignal being received by X (i.e. each signal goes to an arbitrarily
hosen 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
nd B could use different well-known bus names, and X and Y should each
ddMatch() for their corresponding service.
Using a private bus or private connection for each pair is only
esirable if you're doing something quite strange (either not
onceptually part of "the session" or "the system", or sufficiently
igh-data-rate that doing it on the session bus would be a problem - but
f your task is that high-data-rate, then D-Bus is not really designed
or 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
n 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
unning a dbus-daemon with your own configuration (--config
etc/dbus-1/something.conf, where something.conf is provided by you and
esembles session.conf, instead of --session), capturing its address
sing a pipe and the --print-address parameter, and connecting to that
ith dbus_connection_open_private() followed by dbus_bus_register(). I
hink this is how AT-SPI, as used in current GNOME, works.
    S
______________________________________________
bus mailing list
bus at lists.freedesktop.org
ttp://lists.freedesktop.org/mailman/listinfo/dbus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20121210/53e65b38/attachment.html>


More information about the dbus mailing list