Skip to content

Commit

Permalink
use write lock when updating container stats
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Crosby <michael@thepasture.io>
  • Loading branch information
crosbymichael committed Nov 11, 2021
1 parent 195def1 commit 6765524
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/cri/store/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func (s *Store) List() []Container {
}

func (s *Store) UpdateContainerStats(id string, newContainerStats *stats.ContainerStats) error {
s.lock.RLock()
defer s.lock.RUnlock()
s.lock.Lock()
defer s.lock.Unlock()
id, err := s.idIndex.Get(id)
if err != nil {
if err == truncindex.ErrNotExist {
Expand Down

0 comments on commit 6765524

Please sign in to comment.