etcdserver/stats: lock on leaderstats too

release-2.0
Jonathan Boulle 2014-10-17 00:11:25 -07:00
parent 82023c591d
commit da64e7509c
1 changed files with 4 additions and 1 deletions

View File

@ -27,7 +27,10 @@ func NewLeaderStats(id string) *LeaderStats {
}
func (ls *LeaderStats) JSON() []byte {
b, err := json.Marshal(ls)
ls.Lock()
stats := *ls
ls.Unlock()
b, err := json.Marshal(stats)
// TODO(jonboulle): appropriate error handling?
if err != nil {
log.Printf("error marshalling leader stats: %v", err)