Selaa lähdekoodia

pkg/metrics: protect global vars in reset func

Yicheng Qin 11 vuotta sitten
vanhempi
commit
8c932ff719
1 muutettua tiedostoa jossa 2 lisäystä ja 0 poistoa
  1. 2 0
      pkg/metrics/metrics.go

+ 2 - 0
pkg/metrics/metrics.go

@@ -158,6 +158,8 @@ func Do(f func(expvar.KeyValue)) {
 
 
 // for test only
 // for test only
 func reset() {
 func reset() {
+	mutex.Lock()
+	defer mutex.Unlock()
 	vars = make(map[string]expvar.Var)
 	vars = make(map[string]expvar.Var)
 	varKeys = nil
 	varKeys = nil
 }
 }