dbus_connection_send_with_reply_and_block and unrelated messages

Thiago Macieira thiago.macieira at trolltech.com
Sun May 28 06:22:01 PDT 2006


I've noticed a problem when debugging some initial KDE tests, which is the 
fact that dbus_connection_send_with_reply_and_block (henceforth "the 
function") may receive more messages other than the reply it was waiting 
for. The binding never gets notified of the existance of such messages.

So I have to ask: shouldn't "the function" queue an immediate timer to 
notify of the existance of such data? Or should the binding poll the 
connection (dbus_connection_dispatch) to make sure that the queue is 
empty? If the latter, should this polling be done periodically, or just 
after a call to "the function"?

The reason I'm asking is that I'm making a call to 
org.freedesktop.DBus.RequestName. Before the reply comes in, we get two 
signals. This means those two signals will be in the dispatcher queue. 
But the Qt bindings won't see them until there's activity again in the 
D-BUS socket.

Here's the verbose trace of such a call (the waiting half of it). The 
application is in an idle loop, doing nothing. The signals have not been 
delivered yet.

4072: do_reading: fd = 8
4072: check_read_watch: fd = 8
4072:   setting read watch enabled = 1
4072:   UNLOCK: protected_change_watch
4072:   LOCK: protected_change_watch
4072:  read 478 bytes
4072: have 478 bytes, need body 47 + header 160 = 207
4072: validating body from pos 0 len 478 sig 'yyyyuua(yv)'
4072: p = 0x80a90b1 end = 0x80a91f6 claimed_len 3
4072: initially caching field 1
4072: initially caching field 2
4072: initially caching field 3
4072: initially caching field 7
4072: initially caching field 8
4072: validating body from pos 160 len 47 sig 'sss'
4072: Loaded message 0x80c2fc0
4072: have 271 bytes, need body 27 + header 160 = 187
4072: validating body from pos 0 len 271 sig 'yyyyuua(yv)'
4072: p = 0x80a9097 end = 0x80a9127 claimed_len 1
4072: initially caching field 1
4072: initially caching field 2
4072: initially caching field 3
4072: initially caching field 6
4072: initially caching field 8
4072: initially caching field 7
4072: validating body from pos 160 len 27 sig 's'
4072: Loaded message 0x80be6a0
4072: have 84 bytes, need body 4 + header 80 = 84
4072: validating body from pos 0 len 84 sig 'yyyyuua(yv)'
4072: p = 0x80a9047 end = 0x80a906c claimed_len 1
4072: initially caching field 6
4072: initially caching field 5
4072: initially caching field 8
4072: initially caching field 7
4072: validating body from pos 80 len 4 sig 'u'
4072: Loaded message 0x80be7c8
4072: queueing received message 0x80c2fc0
4072: Message 0x80c2fc0 (4 /org/freedesktop/DBus org.freedesktop.DBus 
NameOwnerChanged 'sss' reply to 0) added to incoming queue 0x80b4b88, 2 
incoming
4072: queueing received message 0x80be6a0
4072: Message 0x80be6a0 (4 /org/freedesktop/DBus org.freedesktop.DBus 
NameAcquired 's' reply to 0) added to incoming queue 0x80b4b88, 3 
incoming
4072: queueing received message 0x80be7c8
4072:   UNLOCK: protected_change_timeout
4072:   LOCK: protected_change_timeout
4072: Message 0x80be7c8 (2 no path no interface no member 'u' reply to 5) 
added to incoming queue 0x80b4b88, 4 incoming
4072: check_read_watch: fd = 8
4072:   setting read watch enabled = 1
4072:   UNLOCK: protected_change_watch
4072:   LOCK: protected_change_watch
4072: check_write_watch(): needed = 0 on connection 0x80b4b88 watch 
0x80ac9d8 fd = 8 outgoing messages exist 0
4072:   UNLOCK: protected_change_watch
4072:   LOCK: protected_change_watch
4072:  ... leaving do_iteration()
4072: _dbus_transport_do_iteration end
4072: _dbus_connection_release_io_path locking io_path_mutex
4072: _dbus_connection_release_io_path start connection->io_path_acquired 
= 1
4072: _dbus_connection_release_io_path unlocking io_path_mutex
4072: _dbus_connection_do_iteration_unlocked end
4072: _dbus_connection_block_pending_call top of recheck
4072: check_for_reply_and_update_dispatch_unlocked checked for reply
4072: dbus_connection_send_with_reply_and_block(): got reply
4072:   handing message 0x80be7c8 (method return) to pending call serial 5
4072:   UNLOCK: _dbus_connection_detach_pending_call_and_unlock
4072:   LOCK: check_for_reply_and_update_dispatch_unlocked
4072:   UNLOCK: _dbus_connection_update_dispatch_status_and_unlock
4072: Freeing slot 0 on allocator 0xb688de40 total 1 allocated 1 used

-- 
Thiago José Macieira - thiago.macieira AT trolltech.com
Trolltech AS - Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20060528/1ed3fd97/attachment.pgp


More information about the dbus mailing list