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

Method addConn

server.go:1137–1156  ·  view source on GitHub ↗
(addr string, st transport.ServerTransport)

Source from the content-addressed store, hash-verified

1135}
1136
1137func (s *Server) addConn(addr string, st transport.ServerTransport) bool {
1138 s.mu.Lock()
1139 defer s.mu.Unlock()
1140 if s.conns == nil {
1141 st.Close(errors.New("Server.addConn called when server has already been stopped"))
1142 return false
1143 }
1144 if s.drain {
1145 // Transport added after we drained our existing conns: drain it
1146 // immediately.
1147 st.Drain("")
1148 }
1149
1150 if s.conns[addr] == nil {
1151 // Create a map entry if this is the first connection on this listener.
1152 s.conns[addr] = make(map[transport.ServerTransport]bool)
1153 }
1154 s.conns[addr][st] = true
1155 return true
1156}
1157
1158func (s *Server) removeConn(addr string, st transport.ServerTransport) {
1159 s.mu.Lock()

Callers 2

handleRawConnMethod · 0.95
ServeHTTPMethod · 0.95

Calls 4

CloseMethod · 0.65
DrainMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected