On Tue, May 8, 2012 at 8:24 PM, Liu Yuan <namei.unix at gmail.com> wrote: > On 05/08/2012 08:21 PM, Yunkai Zhang wrote: > >>> > 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. >> > > > Maybe you don't get Christoph. > > if (!uatomic_read(&zk_notify_blocked) && > uatomic_read(&nr_zk_levents)) { > nr_levents = uatomic_sub_return(&nr_zk_levents, 1) + 1; > > I guess he means the possible race between uatomic_read() and > uatomic_sub_return() on the same value. I have explained - when we are trying to subtract nr_zk_levents, it will be added by watcher() in another thread. > > Thanks, > Yuan -- Yunkai Zhang Work at Taobao |