mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon: use RWMutex for stateCounter
Use an RWMutex to allow concurrent reads of these counters Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
67b4b032f3
commit
699174347c
1 changed files with 3 additions and 3 deletions
|
|
@ -65,7 +65,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
type stateCounter struct {
|
type stateCounter struct {
|
||||||
mu sync.Mutex
|
mu sync.RWMutex
|
||||||
states map[string]string
|
states map[string]string
|
||||||
desc *prometheus.Desc
|
desc *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
@ -78,8 +78,8 @@ func newStateCounter(desc *prometheus.Desc) *stateCounter {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctr *stateCounter) get() (running int, paused int, stopped int) {
|
func (ctr *stateCounter) get() (running int, paused int, stopped int) {
|
||||||
ctr.mu.Lock()
|
ctr.mu.RLock()
|
||||||
defer ctr.mu.Unlock()
|
defer ctr.mu.RUnlock()
|
||||||
|
|
||||||
states := map[string]int{
|
states := map[string]int{
|
||||||
"running": 0,
|
"running": 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue