Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20.10 backport] daemon: use RWMutex for stateCounter #43426

Merged
merged 1 commit into from Mar 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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