MCPcopy Index your code
hub / github.com/coder/coder / trackConn

Method trackConn

agent/agentssh/agentssh.go:1120–1142  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1118//
1119//nolint:revive
1120func (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.

Callers 1

handleConnMethod · 0.95

Calls 4

AddMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
DoneMethod · 0.45

Tested by

no test coverage detected