Skip to content

Commit 32758d0

Browse files
committed
reader return io.EOF if writer stops
1 parent 909f853 commit 32758d0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

conn.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func (c *RWConn) asyncRead() {
8181
}
8282
}
8383
if err != nil {
84+
close(c.rx)
8485
c.Close()
8586
return
8687
}
@@ -140,16 +141,14 @@ func (c *RWConn) Read(data []byte) (int, error) {
140141

141142
switch {
142143
case isClosedChan(c.done):
143-
return 0, io.ErrClosedPipe
144+
return 0, io.EOF
144145
case isClosedChan(c.readDeadline.wait()):
145146
return 0, os.ErrDeadlineExceeded
146147
}
147148

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

0 commit comments

Comments
 (0)