Re: thread-safety of counters

Simon McVittie <simon.mcvittie-ZGY8ohtN/[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Organization Collabora Ltd.
Message-ID <[email protected]>
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.

I agree...

> 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.

-- 
Simon McVittie
Collabora Ltd. <http://www.collabora.com/>

_______________________________________________
dbus mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dbus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.