TUN-6646: Add support to SafeStreamCloser to close only write side of stream

This commit is contained in:
João Oliveirinha 2022-08-10 14:21:55 +01:00
parent 91eba53035
commit 9de4e88ca6
1 changed files with 11 additions and 0 deletions

View File

@ -41,3 +41,14 @@ func (s *SafeStreamCloser) Close() error {
s.stream.CancelRead(0)
return s.stream.Close()
}
func (s *SafeStreamCloser) CloseWrite() error {
s.lock.Lock()
defer s.lock.Unlock()
// As documented by the quic-go library, this doesn't actually close the entire stream.
// It prevents further writes, which in turn will result in an EOF signal being sent the other side of stream when
// reading.
// We can still read from this stream.
return s.stream.Close()
}