Skip to content

Commit 9de4e88

Browse files
committed
TUN-6646: Add support to SafeStreamCloser to close only write side of stream
1 parent 91eba53 commit 9de4e88

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

quic/safe_stream.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,14 @@ func (s *SafeStreamCloser) Close() error {
4141
s.stream.CancelRead(0)
4242
return s.stream.Close()
4343
}
44+
45+
func (s *SafeStreamCloser) CloseWrite() error {
46+
s.lock.Lock()
47+
defer s.lock.Unlock()
48+
49+
// As documented by the quic-go library, this doesn't actually close the entire stream.
50+
// It prevents further writes, which in turn will result in an EOF signal being sent the other side of stream when
51+
// reading.
52+
// We can still read from this stream.
53+
return s.stream.Close()
54+
}

0 commit comments

Comments
 (0)