Skip to content

Commit

Permalink
reader return io.EOF if writer stops
Browse files Browse the repository at this point in the history
  • Loading branch information
aojea committed Aug 30, 2022
1 parent 909f853 commit 32758d0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (c *RWConn) asyncRead() {
}
}
if err != nil {
close(c.rx)
c.Close()
return
}
Expand Down Expand Up @@ -140,16 +141,14 @@ func (c *RWConn) Read(data []byte) (int, error) {

switch {
case isClosedChan(c.done):
return 0, io.ErrClosedPipe
return 0, io.EOF
case isClosedChan(c.readDeadline.wait()):
return 0, os.ErrDeadlineExceeded
}

select {
case <-c.done:
// TODO: TestConn/BasicIO the other end stops writing and the http connection is closed
// closing this connection that is blocked on read.
return 0, io.EOF
return 0, io.ErrClosedPipe
case <-c.readDeadline.wait():
return 0, os.ErrDeadlineExceeded
case d, ok := <-c.rx:
Expand Down

0 comments on commit 32758d0

Please sign in to comment.