[Sheepdog] [PATCH] zookeeper: switch gcc atomic builtins to atomic helpers

Yunkai Zhang yunkai.me at gmail.com
Tue May 8 14:21:21 CEST 2012


On Tue, May 8, 2012 at 7:48 PM, Christoph Hellwig <hch at infradead.org> wrote:
> On Tue, May 08, 2012 at 05:34:25PM +0800, Liu Yuan wrote:
>> +     if (!uatomic_add_return(&zk_notify_blocked, 0)
>> +             && uatomic_add_return(&nr_zk_levents, 0)) {
>
> Shouldn't these use uatomic_read?
>
>> +             nr_levents = uatomic_sub_return(&nr_zk_levents, 1) + 1;
>
> The combination of a read and an atomic_sub later looks racy to me, what
> prevents nr_zk_levents from changing between the two calls?

The watcher function was executed in another thread(create by
zookeeper_init() ), we should use atomic function to read/wirte
nr_zk_levents in any time.

>
>> +             if (uatomic_add_return(&nr_zk_levents, 0) || rc == ZOK) {
>
> uatomic_read again?
>
>> +     if (uatomic_add_return(&zk_notify_blocked, 0))
>
> here as well.
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



-- 
Yunkai Zhang
Work at Taobao



More information about the sheepdog mailing list