MCPcopy
hub / github.com/grpc/grpc-go / updateState

Method updateState

clientconn.go:607–626  ·  view source on GitHub ↗

updateState updates the connectivity.State of ClientConn. If there's a change it notifies goroutines waiting on state change to happen.

(state connectivity.State)

Source from the content-addressed store, hash-verified

605// If there's a change it notifies goroutines waiting on state change to
606// happen.
607func (csm *connectivityStateManager) updateState(state connectivity.State) {
608 csm.mu.Lock()
609 defer csm.mu.Unlock()
610 if csm.state == connectivity.Shutdown {
611 return
612 }
613 if csm.state == state {
614 return
615 }
616 csm.state = state
617 csm.channelz.ChannelMetrics.State.Store(&state)
618 csm.pubSub.Publish(state)
619
620 channelz.Infof(logger, csm.channelz, "Channel Connectivity change to %v", state)
621 if csm.notifyChan != nil {
622 // There are other goroutines waiting on this channel.
623 close(csm.notifyChan)
624 csm.notifyChan = nil
625 }
626}
627
628func (csm *connectivityStateManager) getState() connectivity.State {
629 csm.mu.Lock()

Callers 5

exitIdleModeMethod · 0.45
enterIdleModeMethod · 0.45
applyFailingLBLockedMethod · 0.45
CloseMethod · 0.45

Calls 4

InfofFunction · 0.92
PublishMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected