MCPcopy
hub / github.com/coder/websocket / prepareRead

Method prepareRead

read.go:221–240  ·  view source on GitHub ↗

prepareRead sets the read timeout and checks whether the connection is closed.

(ctx context.Context)

Source from the content-addressed store, hash-verified

219
220// prepareRead sets the read timeout and checks whether the connection is closed.
221func (c *Conn) prepareRead(ctx context.Context) (bool, error) {
222 select {
223 case <-c.closed:
224 return false, net.ErrClosed
225 default:
226 }
227 timeoutSet := c.setupReadTimeout(ctx)
228
229 c.closeStateMu.Lock()
230 closeReceivedErr := c.closeReceivedErr
231 c.closeStateMu.Unlock()
232 if closeReceivedErr != nil {
233 if timeoutSet {
234 c.clearReadTimeout()
235 }
236 return false, closeReceivedErr
237 }
238
239 return timeoutSet, nil
240}
241
242// finishRead clears the read timeout and reports whether the connection or
243// operation context ended while the read was in progress.

Callers 2

readFrameHeaderMethod · 0.95
readFramePayloadMethod · 0.95

Calls 3

setupReadTimeoutMethod · 0.95
clearReadTimeoutMethod · 0.95
LockMethod · 0.45

Tested by

no test coverage detected