Skip to content

Commit

Permalink
locally closed streams can still read
Browse files Browse the repository at this point in the history
Effectively reverts 912e296

Reasons to revert to locally closed streams being readable:

Matches libp2p's yamux fork:
https://github.com/libp2p/go-yamux/blob/master/stream.go#L95-L96

Both yamux and SPDY make it clear that a locally closed stream cannot
send more data.

SPDY explicitly supports unidirectional streams where one peer is closed
(readonly) from the beginning:

https://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3-1/#46-unidirectional-streams
  • Loading branch information
schmichael committed Aug 15, 2024
1 parent ab9c78c commit d96c90e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ func (s *Stream) StreamID() uint32 {
func (s *Stream) Read(b []byte) (n int, err error) {
defer asyncNotify(s.recvNotifyCh)
START:

// If the stream is closed and there's no data buffered, return EOF
s.stateLock.Lock()
switch s.state {
case streamLocalClose:
fallthrough
// LocalClose only prohibits further local writes. Handle reads normally.
case streamRemoteClose:
fallthrough
case streamClosed:
Expand Down

0 comments on commit d96c90e

Please sign in to comment.