MCPcopy Index your code
hub / github.com/devspace-sh/devspace / readConn

Function readConn

helper/tunnel/server.go:143–177  ·  view source on GitHub ↗
(ctx context.Context, session *Session, sessions chan<- *Session)

Source from the content-addressed store, hash-verified

141}
142
143func readConn(ctx context.Context, session *Session, sessions chan<- *Session) {
144 for {
145 buff := make([]byte, BufferSize)
146 br, err := session.Conn.Read(buff)
147
148 select {
149 case <-ctx.Done():
150 stderrlog.Debugf("closing connection")
151 session.Close()
152 return
153 default:
154 session.Lock()
155 if err != nil {
156 if err != io.EOF {
157 stderrlog.Errorf("failed to read from conn: %v", err)
158 }
159
160 // setting Open to false triggers SendData() to
161 // send ShouldClose
162 session.Open = false
163 }
164
165 // write the data to the session buffer, if we have data
166 if br > 0 {
167 session.Buf.Write(buff[0:br])
168 }
169 session.Unlock()
170
171 sessions <- session
172 if !session.Open {
173 return
174 }
175 }
176 }
177}
178
179// Ping returns empty
180func (t *tunnelServer) Ping(context.Context, *remote.Empty) (*remote.Empty, error) {

Callers 1

InitTunnelMethod · 0.85

Calls 8

DebugfFunction · 0.92
ErrorfFunction · 0.92
LockMethod · 0.80
UnlockMethod · 0.80
DoneMethod · 0.65
CloseMethod · 0.65
ReadMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected