aboutsummaryrefslogtreecommitdiff
path: root/fasthttputil
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-08-17 17:42:10 +0300
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-08-17 17:42:10 +0300
commitc665919a09fa8c482fc1df08ca8911d5d50f3e39 (patch)
tree0acc37826acba0f8a0399c9d984457b0ec597e46 /fasthttputil
parentdo not compress response body again if Content-Encoding is set (diff)
downloadfasthttp-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.go8
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
+ }
}
}