DBus Specification questions

Thiago Macieira thiago at kde.org
Fri Apr 3 00:37:11 UTC 2020


On Tuesday, 31 March 2020 00:07:02 -03 Robert Middleton wrote:
> Hi all,
> 
> I'm working on updating some DBus bindings, and part of that effort
> involves reimplementing libdbus.  With that, I've come across some
> questions as to how to handle certain situations that may arise.
> 
> 1. Is it possible to have multiple interfaces with the same name on
> the same path?  I would assume at that point that the introspection
> XML would look something like the following:
> <node>
>   <interface name="foo.bar">
>     <method name="example" />
>   </interface>
>   <interface name="foo.bar">
>     <method name="exampleOther" />
>   </interface>
> </node>
> 
> The spec seems to imply that this is valid, but I don't see it
> specified one way or the other.

Yes, so long as it's the *same* interface (same content), which means it's 
pointless to specify it more than once. 

The same interface with different content, whether it is in the same object or 
different ones (same connection or not) is a recipe for trouble. Don't do it.

> 2. Even though it is valid to have a METHOD_CALL without an interface,
> is it valid to disregard messages that don't have an interface, or
> should an effort be made to do something with the message?  Would it
> be valid to return an error in this case?

Disregarding or returning an is not correct. You should match to a method that 
one of the interfaces provides. If more than one matches, it's unspecified 
which one gets called.

> 3. Who processes METHOD_CALL timeouts?  From my use of dbus-java I
> believe that this is always handled by the sender, but the
> specification does not mention anything about it.

The daemon and the reference library both. So if your implementation does not 
use the reference library, you should implement timing out by yourself. 
Relying on the bus replying back to you is unwise. See Simon's reply.

> 4. Do any sort of compliance checks exist at the moment?  I want to to
> try and define as many unit tests as possible to ensure that erroneous
> conditions are properly dealt with / invalid data doesn't get sent.

Not that I know of. At best, we have interop testing.

> 5. If a call has the NO_REPLY_EXPECTED flag set, does sending a
> response or an error back constitute an invalid action?  The
> specification states that "the application receiving the method should
> not send the reply message", but I wasn't sure if it is valid to send
> a response anyway.

No. Replying to a method call is fine, though unnecessary, whether a reply was 
expected or not. Not replying to one that did expect a response is a problem.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products





More information about the dbus mailing list