thread-safety of counters
simon.mcvittie at collabora.co.uk
Mon Feb 23 08:19:04 PST 2015
On 23/02/15 15:38, Adrian Szyndela wrote:
> I do not see a place where any of connection mutexes could be used,
> especially for unrefs.
> W dniu 23.02.2015 o 13:56, Simon McVittie pisze:
>> This seems reasonable, but it would be good to know whether the
>> counter is meant to be protected by a mutex. If so, why was that mutex
>> not sufficient here? and if not, how do we avoid getting an incorrect
>> value in the counter via concurrent access from different threads?
... but if they aren't protected by any mutex, then I don't see how
these counters can ever have worked correctly in any threaded situation.
If we have public APIs that use them (which we do), then we should
probably make them atomic too (throwing away even more CPU caches in the
process... but that's the price you pay for trying to be thread-safe).
As it happens, their main (only?) user is dbus-daemon (for its
configurable resource limits), and dbus-daemon is single-threaded...
Do you see what I mean about libdbus trying to be all things to all
people, and only succeeding in doing them all badly? :-)
Could you open a bug on bugs.freedesktop.org to track this, please?
Ideally please attach your proposed patch, and if you could do a new
patch to make the counters themselves atomic, that would also be great.
Collabora Ltd. <http://www.collabora.com/>
More information about the dbus