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

Change Mutex to RWMutex for connectivityStateManager #3682

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func getChainStreamer(interceptors []StreamClientInterceptor, curr int, finalStr
// connectivityStateManager keeps the connectivity.State of ClientConn.
// This struct will eventually be exported so the balancers can access it.
type connectivityStateManager struct {
mu sync.Mutex
mu sync.RWMutex
state connectivity.State
notifyChan chan struct{}
channelzID int64
Expand Down Expand Up @@ -431,8 +431,8 @@ func (csm *connectivityStateManager) updateState(state connectivity.State) {
}

func (csm *connectivityStateManager) getState() connectivity.State {
csm.mu.Lock()
defer csm.mu.Unlock()
csm.mu.RLock()
defer csm.mu.RUnlock()
return csm.state
}

Expand Down