mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver/stats: lock on leaderstats too
This commit is contained in:
parent
82023c591d
commit
da64e7509c
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user