Blocking behavior of synchronous calls

Thiago Macieira thiago at kde.org
Sat Nov 22 04:17:22 PST 2008


Schmottlach, Glenn wrote:
>I have been studying the DBus implementation trying to gain a deeper
>understanding of the control flow through the library. In particular, it
>appears that the Glib binding implements synchronous calls (with
>timeouts) to remote services via dbus_connection_send_with_reply() and
>then blocks on dbus_pending_call_block().
>
>The comments in the code seem to indicate that dbus_pending_call_block()
>does not re-enter the mainloop or process other messages. If this is
>true, how does the message loop continue to process incoming signals and
>responses? Does the DBus library own a dedicated thread (e.g. mainloop)
>that polls/selects the transport file descriptors looking for incoming
>messages (and optionally) sending out-going messages if they're queued
>up? While a user's code is blocked on dbus_pending_call_block() can the
>DBus library still receive signals and dispatch them to registered
>callbacks? If that's possible, what would happen if a signal handler
>made a blocking call to a remote service? Would that block this main
>loop?

Hello Glenn

The D-Bus library does not have any particular threads. When any of the 
blocking functions are called (dbus_connection_send_with_reply_and_block 
or dbus_pending_call_block), the library will block on a select/poll on 
the file descriptor for the socket. That's the only event that will be 
processed. The function will pop any incoming messages from the bus and, 
if they're not the reply it's looking for, it will put them in a queue for 
later. Nothing will be dispatched.

Once the function returns, the application's main loop should call the D-
Bus library's functions for doing the dispatching of queued messages.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freedesktop.org/archives/dbus/attachments/20081122/9522397e/attachment.pgp 


More information about the dbus mailing list