Skip to content

Commit

Permalink
Merge pull request #43426 from thaJeztah/20.10_backport_info_counters…
Browse files Browse the repository at this point in the history
…_rwmutex

[20.10 backport] daemon: use RWMutex for stateCounter
  • Loading branch information
tianon committed Mar 25, 2022
2 parents 339d7bd + 32fe0bb commit 4e188b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions daemon/metrics.go
Expand Up @@ -65,7 +65,7 @@ func init() {
}

type stateCounter struct {
mu sync.Mutex
mu sync.RWMutex
states map[string]string
desc *prometheus.Desc
}
Expand All @@ -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,
Expand Down

0 comments on commit 4e188b8

Please sign in to comment.