Including the originating PID in every message?
havoc.pennington at gmail.com
Fri Apr 17 15:12:04 PDT 2009
On Fri, Apr 17, 2009 at 9:42 AM, Markku Savela <msa at moth.iki.fi> wrote:
> [Currently, getting PID requires complicated round-trip query, which
> I'm not quite sure would work for all types of messages and signals.]
You can assume that all messages (at least all 4 current message
types) have a sender field set to the unique bus name of the sender.
Then as David says you only have to do the round-trip query one time
per sender, and keep the PID cached. There's no way the PID can change
for a unique bus name. (It can change for a well-known bus name.)
> Unfortunately, this would mean that dbus would need to modify every
> message that passes through it. As I understand, it currently does
> this unmarshal/marshal already for all messages, and thus adding new
> field to header would not be much extra... ...but, maybe that will not
> be true always in future?
dbus-daemon already modifies every message to set the sender field to
the unique bus name, thus guaranteeing that you can reliably get the
pid. Part of the reason the sender is set to the unique name is to
enable you to associate the message with a particular peer, not just a
well-known name, so you can track something like the pid.
It is guaranteed that the sender field is a unique bus name, that it
is the accurate unique bus name of the sender (it's set by the bus,
not the sender, so can't be "spoofed"), and it's guaranteed that
unique bus names are never recycled so always refer to the same remote
More information about the dbus