MCPcopy
hub / github.com/cloudflare/cloudflared / Close

Method Close

quic/safe_stream.go:74–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72}
73
74func (s *SafeStreamCloser) Close() error {
75 // Set this stream to a closing state.
76 s.closing.Store(true)
77
78 // Make sure a possible writer does not block the lock forever. We need it, so we can close the writer
79 // side of the stream safely.
80 _ = s.stream.SetWriteDeadline(time.Now())
81
82 // This lock is eventually acquired despite Write also acquiring it, because we set a deadline to writes.
83 s.lock.Lock()
84 defer s.lock.Unlock()
85
86 // We have to clean up the receiving stream ourselves since the Close in the bottom does not handle that.
87 s.stream.CancelRead(0)
88 return s.stream.Close()
89}
90
91func (s *SafeStreamCloser) CloseWrite() error {
92 s.lock.Lock()

Callers 4

closeUDPSessionMethod · 0.95
runStreamMethod · 0.95
quicClientFunction · 0.95
quicServerFunction · 0.95

Calls 2

SetWriteDeadlineMethod · 0.80
CloseMethod · 0.65

Tested by 2

quicClientFunction · 0.76
quicServerFunction · 0.76