Pending Calls and Asynchronous functions

Havoc Pennington havoc.pennington at gmail.com
Tue Apr 13 19:51:34 PDT 2010


It seems like a fairly simple patch to add send_with_reply_notify
where the notify callback is passed in and set on the pending call
while locks are still held

Havoc

On Thu, Mar 25, 2010 at 5:07 AM, Alexander Larsson <alexl at redhat.com> wrote:
> 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!
>
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus
>


More information about the dbus mailing list