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

Christoph Hellwig hch at infradead.org
Tue May 8 17:36:32 CEST 2012


On Tue, May 08, 2012 at 11:20:18PM +0800, Yunkai Zhang wrote:
> On Tue, May 8, 2012 at 11:06 PM, Christoph Hellwig <hch at infradead.org> wrote:
> > On Tue, May 08, 2012 at 11:01:53PM +0800, Yunkai Zhang wrote:
> >> It works well now, I don't know what you worry about?
> >
> > It works most of the time, but not always. ?Even worse the reace is
> > small enough that you won't find it during most testing, and only run
> > into it on some heavily loaded production system once in a while.
> 
> Producer: watcher thread
> Consumer: main thread
> 
> 1) watcher thread:
> When sheep leave, /sheepdog/member/<nodeid_to_str> was deleted by
> zookeeper server, watcher() will forge an LEAVE event, and:
> atomic_add_and_return(&nr_zk_levents, 1)
> 
> 2) main thread:
> Check if atomic_read(&nr_zk_levents) > 0; if so, call
> atomic_sub_and_return(&nr_zk_levents, 1), and processes this LEAVE
> event.
> 
> What is the problem you worry about? Can you give me an example?

You're right - there is a strict relation.  Care to add the above
explanation as a comment?




More information about the sheepdog mailing list