Closed xiang90 closed 10 years ago
/cc @benbjohnson @unihorn
@xiangli-cmu Is this related to a bug? Does it pass the race detector? We need a lock around Server.peers
since that can be read by the application.
@benbjohnson It is a cleanup. I tried test -race and these changes did not introduce more races and not fix any either.
I think the peer lock is not related to this pull request. This pull request does not change that behavior.
@xiangli-cmu If you call Server.Peers()
while updateCurrentTerm()
is messing with the peers then you'll get a race error. We need the lock around there.
can i merge this one? i will try to fix data race after this.
@xiangli-cmu Sure. Go for it. Check it against the etcd functional tests with -race
set on the tests and on the build.
Our server is a single routine for loop. We have a lock to avoid "data-race" between the external function calls(read/write) and internal operations(write). So we can drop the extra lock when reading variables internally.