trackConn registers the connection with the server. If the server is closed or the listener is closed, the connection is not registered and should be closed. nolint:revive
(l net.Listener, c net.Conn, add bool)
| 1118 | // |
| 1119 | //nolint:revive |
| 1120 | func (s *Server) trackConn(l net.Listener, c net.Conn, add bool) (ok bool) { |
| 1121 | s.mu.Lock() |
| 1122 | defer s.mu.Unlock() |
| 1123 | if add { |
| 1124 | found := false |
| 1125 | for ll := range s.listeners { |
| 1126 | if l == ll { |
| 1127 | found = true |
| 1128 | break |
| 1129 | } |
| 1130 | } |
| 1131 | if s.closing != nil || !found { |
| 1132 | // Server or listener closed. |
| 1133 | return false |
| 1134 | } |
| 1135 | s.wg.Add(1) |
| 1136 | s.conns[c] = struct{}{} |
| 1137 | return true |
| 1138 | } |
| 1139 | s.wg.Done() |
| 1140 | delete(s.conns, c) |
| 1141 | return true |
| 1142 | } |
| 1143 | |
| 1144 | // trackSession registers the session with the server. If the server is |
| 1145 | // closing, the session is not registered and should be closed. |
no test coverage detected