Re: thread-safety of counters

Adrian Szyndela <[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Message-ID <[email protected]>
W dniu 23.02.2015 o 17:19, Simon McVittie pisze:
>> 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).

Oh, now I understand, you talk about safety of actual values in a
counter object, not only about the reference count.

> Do you see what I mean about libdbus trying to be all things to all
> people, and only succeeding in doing them all badly? :-)

I am not there yet, but I think I am getting closer :-)

> Could you open a bug on bugs.freedesktop.org to track this, please?
> Ideally please attach your proposed patch,

Sure. Will do.

> and if you could do a new
> patch to make the counters themselves atomic, that would also be great.

If I dig into libdbus deep enough to understand it sufficiently, a patch
will probably 'emerge'.

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