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

Method lock

conn.go:286–305  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

284}
285
286func (m *mu) lock(ctx context.Context) error {
287 select {
288 case <-m.c.closed:
289 return net.ErrClosed
290 case <-ctx.Done():
291 return fmt.Errorf("failed to acquire lock: %w", ctx.Err())
292 case m.ch <- struct{}{}:
293 // To make sure the connection is certainly alive.
294 // As it's possible the send on m.ch was selected
295 // over the receive on closed.
296 select {
297 case <-m.c.closed:
298 // Make sure to release.
299 m.unlock()
300 return net.ErrClosed
301 default:
302 }
303 return nil
304 }
305}
306
307func (m *mu) unlock() {
308 select {

Callers 8

waitCloseHandshakeMethod · 0.80
readerMethod · 0.80
ReadMethod · 0.80
resetMethod · 0.80
writeCompressedFrameMethod · 0.80
WriteMethod · 0.80
CloseMethod · 0.80
writeFrameMethod · 0.80

Calls 1

unlockMethod · 0.95

Tested by

no test coverage detected