Is dbus_pending_call_set_notify() thread safe?

Havoc Pennington hp at redhat.com
Tue Jul 31 21:07:37 PDT 2007


Hi,

Simon McVittie wrote:
> On Tue, 31 Jul 2007 at 17:02:54 -0400, Havoc Pennington wrote:
>> That aside, I believe what should work is to set your notify, then call 
>> dbus_pending_call_steal_reply(). If the reply arrived before you set the 
>> notify, then it will be returned from steal_reply().
> 
> Surely that can result in the reply getting processed twice, in pathological
> cases?

I don't think so, because it's a steal_reply not a get_reply

> The C part of dbus-python contains a workaround for this race, so yes,
> bindings could benefit from an atomic API.

I'm curious, what did you do as a workaround if not the above?

I'm not opposed to the atomic API, it makes sense to have.

The only alternative I considered is making set_notify 
immediately/synchronously call the callback if the reply already 
arrived, but I think it's arguably an API change and surprising in a 
potentially dangerous way.

Havoc



More information about the dbus mailing list