[systemd-devel] dbus-1/kdbus - question about 'queued owners'

Lukasz Skalski l.skalski at samsung.com
Mon Apr 13 04:56:38 PDT 2015


On 04/13/2015 01:46 PM, Daniel Mack wrote:
> Hi Lukasz,
> 

Hi,

> [+dbus ML]
> 
> On 04/10/2015 04:20 PM, Lukasz Skalski wrote:
>> Currently I'm working on some testsuite (let's call it dbus1-spec-test)
>> for dbus-1 specification. My idea is to test dbus-1 specification
>> coverage on systems with dbus-daemon and on systems without dbus-daemon
>> (but with latest systemd, bus-proxyd and kdbus) which will allow us (and
>> all userspace apps) to smoothly switch to kdbus. First results of tests
>> are really good:
> 
> Nice, thanks a lot for doing this!
> 
>> My testsuite have found only one inconsistency between dbus-1 and
>> kdbus-enabled system. Problematic testcase (this one tests rather some
>> dbus-daemon/bus-proxyd behaviors than specification) is as follow:
>>
>> test_request_name_6 (void)
>> {
>>   GDBusConnection *connection_a;
>>   GDBusConnection *connection_b;
>>
>>   BusRequestNameFlagsReply request_reply;
>>   BusReleaseNameFlagsReply release_reply;
>>
>>   /* connect and set up two D-Bus client connections */
>>   connection_a = connect_to_bus();
>>   connection_b = connect_to_bus();
>>
>>   /* 'connection_a' - synchronously acquire name on the bus */
>>   request_reply = request_name (connection_a, "org.my.busname",
>>                                 DBUS_NAME_FLAG_REPLACE_EXISTING |
>>                                 DBUS_NAME_FLAG_DO_NOT_QUEUE);
>>
>>   /* 'connection_a' should be primary owner */
>>   CU_ASSERT (request_reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
>>
>>   /* 'connection_b' tries to own the same well-known name */
>>   request_reply = request_name (connection_b, "org.my.busname",
>>                                 DBUS_NAME_FLAG_REPLACE_EXISTING);
>>
>>   /* 'connection_b' should be appended to the queue */
>>   CU_ASSERT (request_reply == DBUS_REQUEST_NAME_REPLY_IN_QUEUE);
>>
>>   /* once again 'connection_b' tries to own the same name */
>>   request_reply = request_name (connection_b, "org.my.busname",
>>                                 DBUS_NAME_FLAG_REPLACE_EXISTING);
>>
>>   /* and once again we should get the same return code */
>>   CU_ASSERT (request_reply == DBUS_REQUEST_NAME_REPLY_IN_QUEUE);
> 
> The D-Bus spec isn't totally clear about the return code here, but it is
> about what should happen:
> 
> "If replacement is not possible, *and the method caller is currently not
> in the queue*, the method caller is appended to the queue."
> 
> dbus-daemon seems to return IN_QUEUE to inform the caller that the name
> is in the queue, no matter if the call it replies to was responsible for
> creating the queue entry or if that was already the case.
> 
>>   /* 'connection_a' releases name */
>>   release_reply = release_name (connection_a, "org.my.busname");
>>   CU_ASSERT (release_reply == DBUS_RELEASE_NAME_REPLY_RELEASED);
>>
>>   /* 'connection_b' (now primary owner) also release name
>>   release_reply = release_name (connection_b, "org.my.busname");
>>   CU_ASSERT (release_reply == DBUS_RELEASE_NAME_REPLY_RELEASED);
>>
>>   /* 'connection_b' tries to release once again the same name */
>>   release_reply = release_name (connection_b, "org.my.busname");
>>
>>   /* This assert is source of failure - what we should get
>>      here: REPLY_RELEASED or NON_EXISTENT ? */
>>   CU_ASSERT (release_reply == DBUS_RELEASE_NAME_REPLY_NON_EXISTENT);
> 
> As per the spec, the same connection can only be queued up once for a
> given well-known name, so the correct error code should be NON_EXISTENT.
> 
>> Which solution, kdbus or dbus-daemon, do it correctly?
> 
> kdbus is wrong here IMO. The kernel patch you sent me offlist looks
> resonable. Care to rebase and post it to LKML?

Sure. Thanks for clarification!

> 
> 
> Thanks,
> Daniel
> 
> 

Cheers,
-- 
Lukasz Skalski
Samsung R&D Institute Poland
Samsung Electronics
l.skalski at samsung.com


More information about the systemd-devel mailing list