implementing IN_PROGRESS
Havoc Pennington
hp at redhat.com
Sat Feb 25 14:01:29 PST 2006
Oh wait, in the shower just now I decided you're essentially right. The
behavior you proposed can be accomplished by just using a recursive lock
instead of a regular lock.
That will prevent two threads from dispatching at once, but allow
recursive dispatch in the same thread.
For some reason I was thinking this would be bad, but now that I spelled
everything out in long emails I don't think there's any reason it's
bad.
The "bad reentrancy" would only happen if the app programmer or binding
called the main loop reentrantly on purpose, and even then a main loop
with a no recurse feature could prevent it. So a recursive dispatch lock
in DBusConnection will just serve to make things like
block_pending_call() work properly, and make recursive mainloops work
properly (when they are intentional)
We would need to do two things:
- add recursive locks support to DBusThreadFunctions
and update all bindings to provide them
- audit the code that holds the dispatch lock to be
sure it's safe against same-thread reentrancy
(e.g. messages being removed from the queue from
an application callback)
Havoc
More information about the dbus
mailing list