| 1135 | } |
| 1136 | |
| 1137 | func (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 | |
| 1158 | func (s *Server) removeConn(addr string, st transport.ServerTransport) { |
| 1159 | s.mu.Lock() |