Skip to content

Commit

Permalink
prevent sending more data in passive closing
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Aug 30, 2024
1 parent a9a927f commit d245826
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ func (s *Stream) Write(b []byte) (n int, err error) {

// check if stream has closed
select {
case <-s.chFinEvent: // passive closing
return 0, io.EOF
case <-s.die:
return 0, io.ErrClosedPipe
default:
Expand Down Expand Up @@ -382,6 +384,8 @@ func (s *Stream) writeV2(b []byte) (n int, err error) {

// check if stream has closed
select {
case <-s.chFinEvent:
return 0, io.EOF
case <-s.die:
return 0, io.ErrClosedPipe
default:
Expand Down

0 comments on commit d245826

Please sign in to comment.