DBusGConnection attached to two difrent contexts

Thiago Macieira thiago at kde.org
Tue Sep 18 08:19:28 PDT 2012


On terça-feira, 18 de setembro de 2012 14.37.47, Simon McVittie wrote:
> > During the execution of a dbus callback method I need to start a 10
> > seconds timer to make some aditional checks and after those 10
> > seconds I can exit the callback.
> 
> You probably want to implement the method asynchronously instead:
> receive parameters including a DBusGMethodInvocation, go back to your
> main loop, and 10 seconds later (or whenever you find out what the
> result should be), call dbus_g_method_return() or
> dbus_g_method_return_error(). To do this with the dbus-glib code
> generation, you need to mark the method as asynchronous in the input
> XML. Have a look at the AsyncIncrement and AsyncThrowError methods in
> test/core/test-service-glib.xml, in dbus-glib's source tree.

Also note that you should avoid designing a method that takes this long to 
execute.

If your method is run on a slower system and/or under heavy load, 10 seconds 
can easily become 20 or 30 seconds. And then you've passed the 25-second 
timeout limit on the caller.

If you're going to design a method that takes several seconds to return under 
optimal conditions, you need to ensure that every caller is increasing the 
timeout limits in their calls. And by that, I mean EVERY caller.

And note that the D-Bus daemon imposes an upper limit of 5 minutes on a call, 
so you should not design methods that can take over a minute to execute under 
optimal conditions.

Instead, return immediately indicating that you received the request and 
everything is ok, then send a signal once the operation has completed.
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20120918/d57827bb/attachment.pgp>


More information about the dbus mailing list