Skip to content

Commit

Permalink
Merge pull request kubernetes#4724 from mikedanese/readiness-states-c…
Browse files Browse the repository at this point in the history
…leanup

Don't lock readinessStates on concurrent reads
  • Loading branch information
rjnagal committed Feb 23, 2015
2 parents cbcd355 + d6fb8ce commit b261d8c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/kubelet/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ func newReadinessStates() *readinessStates {
}

type readinessStates struct {
sync.Mutex
// guards states
sync.RWMutex
states map[string]bool
}

Expand All @@ -174,8 +175,8 @@ func (r *readinessStates) IsReady(c api.ContainerStatus) bool {
}

func (r *readinessStates) get(key string) bool {
r.Lock()
defer r.Unlock()
r.RLock()
defer r.RUnlock()
state, found := r.states[key]
return state && found
}
Expand Down

0 comments on commit b261d8c

Please sign in to comment.