From 32758d0b7ad4b954f59f2954f7b03f6c2c896d20 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Tue, 30 Aug 2022 10:31:41 +0200 Subject: [PATCH] reader return io.EOF if writer stops --- conn.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/conn.go b/conn.go index a0cff03..facbfd9 100644 --- a/conn.go +++ b/conn.go @@ -81,6 +81,7 @@ func (c *RWConn) asyncRead() { } } if err != nil { + close(c.rx) c.Close() return } @@ -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: