Pending Calls and Asynchronous functions

Alexander Larsson alexl at redhat.com
Thu Mar 25 02:07:36 PDT 2010


On Wed, 2010-03-24 at 09:51 -0700, jaikumar Ganesh wrote:
> Hello folks,
> 
> On Tue, Mar 23, 2010 at 3:52 PM, jaikumar Ganesh <jaikumarg at gmail.com>
> wrote:
>         Hello folks,
>             I have the following calls:
>         
>         
>                        reply = dbus_connection_send_with_reply(conn,
>         msg, &call,
>         
>                          timeout_ms);
>                        if (reply == TRUE) {
>         
>         dbus_pending_call_set_notify(call,
>         
>         callback,
>         
>         pending,
>         
>         NULL);
>                        }
>         
>         
>         So I get a reply from the other end (very quickly) and before
>         a pending function can get set in
>         dbus_pending_call_set_notify.
>         And thus when _dbus_pending_call_complete is called I don't
>         get the callback because pending->function is NULL.
>         
>         This is a race condition and I hit it 50 % of the times
>         depending on how loaded the system is.
>         
>         
>         Is there a better way to set the pending call ? Am I using it
>         wrongly ?
>         
>         Thanks
>         Jaikumar
> 
>    I see a similar thread way back
> http://marc.info/?l=freedesktop-dbus&m=117323278532868&w=2
>    Did we dix this ?

I don't think so. I have a workaround in gvfs:

http://git.gnome.org/browse/gvfs/tree/common/gdbusutils.c#n1316


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
       alexl at redhat.com            alexander.larsson at gmail.com 
He's a jaded flyboy cop moving from town to town, helping folk in trouble. 
She's a ditzy nymphomaniac lawyer with only herself to blame. They fight 
crime! 



More information about the dbus mailing list