1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #43426 from thaJeztah/20.10_backport_info_counters_rwmutex

[20.10 backport] daemon: use RWMutex for stateCounter
This commit is contained in:
Tianon Gravi 2022-03-25 15:49:29 -07:00 committed by GitHub
commit 4e188b8a49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -65,7 +65,7 @@ func init() {
}
type stateCounter struct {
mu sync.Mutex
mu sync.RWMutex
states map[string]string
desc *prometheus.Desc
}
@ -78,8 +78,8 @@ func newStateCounter(desc *prometheus.Desc) *stateCounter {
}
func (ctr *stateCounter) get() (running int, paused int, stopped int) {
ctr.mu.Lock()
defer ctr.mu.Unlock()
ctr.mu.RLock()
defer ctr.mu.RUnlock()
states := map[string]int{
"running": 0,