diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2016-08-17 17:42:10 +0300 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2016-08-17 17:42:10 +0300 |
commit | c665919a09fa8c482fc1df08ca8911d5d50f3e39 (patch) | |
tree | 0acc37826acba0f8a0399c9d984457b0ec597e46 /fasthttputil | |
parent | do not compress response body again if Content-Encoding is set (diff) | |
download | fasthttp-c665919a09fa8c482fc1df08ca8911d5d50f3e39.tar.gz fasthttp-c665919a09fa8c482fc1df08ca8911d5d50f3e39.tar.bz2 fasthttp-c665919a09fa8c482fc1df08ca8911d5d50f3e39.zip |
Fixed a race when reading data from pipe. This fixes flacky tests involving fasthttputil.PipeConns: TestResponseGzipStream and TestWorkerPoolMaxWorkersCountSerial
Diffstat (limited to 'fasthttputil')
-rw-r--r-- | fasthttputil/pipeconns.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fasthttputil/pipeconns.go b/fasthttputil/pipeconns.go index 15a8f02..d45210e 100644 --- a/fasthttputil/pipeconns.go +++ b/fasthttputil/pipeconns.go @@ -150,7 +150,13 @@ func (c *pipeConn) readNextByteBuffer(mayBlock bool) error { select { case c.b = <-c.rCh: case <-c.pc.stopCh: - return io.EOF + // rCh may containg data when stopCh is closed. + // Read the data before returning EOF. + select { + case c.b = <-c.rCh: + default: + return io.EOF + } } } |