Skipping the session bus hop for RPC

Andrew Sherk ASherk at qnx.com
Mon Feb 9 10:55:29 PST 2009


Hi,

I am trying to get a better idea of the D-Bus transport data flow.
Is there a way to use bindings and have method calls and method replies
traffic go from client directly to service without going through the
session bus once the service's location is known? (Idea: use session bus
to do the lookup and then bypass the session bus for further IPC between
service and client)

I start dbus-monitor --session

Then execute python code:

import dbus
bus = dbus.SessionBus()
rp = bus.get_object(
	'org.gnome.Rhythmbox', '/org/gnome/Rhythmbox/Player')
rp.setVolume(0.50)
print rp.getVolume()

Generated dbus-monitor output:

signal sender=org.freedesktop.DBus -> dest=(null destination)
path=/org/freedesktop/DBus; interface=org.freedesktop.DBus;
member=NameOwnerChanged
   string ":1.57"
   string ""
   string ":1.57"
method call sender=:1.57 -> dest=org.freedesktop.DBus
path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
method call sender=:1.57 -> dest=org.freedesktop.DBus
path=/org/freedesktop/DBus; interface=org.freedesktop.DBus;
member=GetNameOwner
   string "org.gnome.Rhythmbox"
method call sender=:1.57 -> dest=:1.32 path=/org/gnome/Rhythmbox/Player;
interface=org.freedesktop.DBus.Introspectable; member=Introspect
method return sender=:1.32 -> dest=:1.57 reply_serial=3
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object
Introspection 1.0//EN"
  <---rest of output cut for brevity--->

method call sender=:1.57 -> dest=:1.32 path=/org/gnome/Rhythmbox/Player;
interface=(null); member=getVolume
method return sender=:1.32 -> dest=:1.57 reply_serial=6
   double 0.5
method call sender=:1.57 -> dest=:1.32 path=/org/gnome/Rhythmbox/Player;
interface=(null); member=setVolume
   double 0.375
method return sender=:1.32 -> dest=:1.57 reply_serial=7


Since dbus-monitor can see the above traffic, it seems that every method
call (mc) and method return (mr) data goes through the session daemon
process.  If for example after the Introspect method call, all future
communication between my python object and the RhythmboxPlayer object
could go directly between the two  without the performance hit of going
through the session bus?  Since after first contact (session bus helps
here), my python object would know enough about Rhythmbox player to do
IPC with the player directly (skip the session bus).

Is it possible? I'm looking at ways to reduce IPC traffic. i.e. use
session bus as basic publish/subscribe and routing of first contact, but
have all subsequent mc's and mr's go between the processes without
overhead of context switch/copy forward of data by session bus.

Thanks,
Andy


More information about the dbus mailing list